Skip to content

Commit

Permalink
Version 210
Browse files Browse the repository at this point in the history
Merges
Added :serverlist
Added service.TaskScheduler
Made aliases accept position arguments designated using <someString> in the command string (:ff <args1> | :fire <args1> <args2>)
  • Loading branch information
Sceleratis committed Feb 23, 2021
1 parent ccbc957 commit a182dfa
Show file tree
Hide file tree
Showing 11 changed files with 534 additions and 311 deletions.
48 changes: 48 additions & 0 deletions MainModule/Client/Core/Service.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ return function(errorHandler, eventChecker, fenceSpecific)
local FilterCache = {}
local TrackedTasks = {}
local RunningLoops = {}
local TaskSchedulers = {}
local ServiceVariables = {}
local CreatedItems = setmetatable({},{__mode = "v"});
local Wrappers = setmetatable({},{__mode = "kv"});
Expand Down Expand Up @@ -125,6 +126,53 @@ return function(errorHandler, eventChecker, fenceSpecific)
GetTasks = function()
return TrackedTasks
end;

TaskScheduler = function(taskName, props)
local props = props or {};
if not props.Temporary and TaskSchedulers[taskName] then return TaskSchedulers[taskName] end

local new = {
Name = taskName;
Running = true;
Properties = props;
LinkedTasks = {};
RunnerEvent = service.New("BindableEvent");
}

function new:Trigger(self, ...)
self.Event:Fire(...)
end;

function new:Delete(self)
if not props.Temporary then
TaskSchedulers[taskName] = nil;
end

new.Running = false;
new.Event:Disconnect();
end;

new.Event = new.RunnerEvent.Event:Connect(function(...)
for i,v in next,new.LinkedTasks do
local ran,result = pcall(v);
if result then
table.remove(new.LinkedTasks, i);
end
end
end)

if props.Interval then
while wait(props.Interval) and new.Running do
new:Trigger(os.time());
end
end

if not props.Temporary then
TaskSchedulers[taskName] = new;
end

return new;
end;

Events = setmetatable({},{
__index = function(tab,ind)
Expand Down
15 changes: 14 additions & 1 deletion MainModule/Client/Dependencies/Changelog.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
return {
"Version: 209";
"Version: 210";
"*Click and drag edges to expand*";
"";
"[2.23.2021 18:13 EST]";
"*Added :serverlist (just shows servers byu jobid and number of players for now)";
"*Possibly fixed existing servers not updating to newest DataStore.SavedTables";
"*Aliases now support positional arguments";
"**Example: If \":ff <arg1> | :fire <arg1> <arg2>\" is bound to \":bob\" and you chat \":bob me Really red\", it will :ff you and give you really red fire";
"*Git merge:";
"(Git/EnderUwU) Added :joinserver <player> <jobid>";
"(Git/Awesomewebm) :pause, :resume, and changes to :music";
"(Git/Awesomewebm) Improvements to :taudio";
"(Git/p3tray) Fixed structuring of IsPlaceOwner";
"(Git/Cald-fan) Update WebPanel.lua";
"(Git/EnterUwU) Update UserPanel.lua";
"";
"[2.11.2021 14:42 EST]";
"*Added command/text aliases (Credit to Git/pbstFusion for some porting commits and spurring me to fully implment this)";
"*Git Merge:";
Expand Down
2 changes: 2 additions & 0 deletions MainModule/Client/Dependencies/Credits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ return {
{Text = "Rerumu (Shining_Diamando)",Desc = "Made the endless stairs place\nRerubi (No longer used)\nFiOne (Bytecode Interpreter)\nParser\nSteampunk theme"};
{Text = "Cald_fan", Desc = "Made the WebPanel"};
{Text = "joritochip", Desc = "WebPanel Contributor"};
{Text = "Coasterteam", Desc = "Development contributions (Kronos developer)"};
{Text = "", Desc = ""};
{Text = "~ GIT CONTRIBUTORS ~", Desc = ""};
{Text = "@GitHub MudockYatho", Desc = "GitHub Contributor"};
Expand All @@ -28,6 +29,7 @@ return {
{Text = "@GitHub policetonyR", Desc = "GitHub Contributor"};
{Text = "@GitHub enescglyn", Desc = "GitHub Contributor"};
{Text = "@GitHub EpicFazbear", Desc = "GitHub Contributor"};
{Text = "@GitHub p3tray", Desc = "GitHub Contributor"};
{Text = "", Desc = "Everyone else"};
{Text = "~ EVERYONE ELSE ~", Desc = ""};
{Text = "Stravant/JustAPerson/Jason Priest (?)", Desc = "Wrote LBI (No longer used)"};
Expand Down
58 changes: 43 additions & 15 deletions MainModule/Server/Core/Admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ return function(Vargs)
Variables.CachedDonors[tostring(player.UserId)] = tick()
end
end)

local function FormatAliasArgs(alias, aliasCmd, msg)
local uniqueArgs = {}
local argTab = {}
local numArgs = 0;

--local cmdArgs =
for arg in aliasCmd:gmatch("<(%S+)>") do
if arg ~= "" and arg ~= " " then
local arg = "<".. arg ..">"
if not uniqueArgs[arg] then --// Get only unique placeholder args, repeats will be matched to the same arg pos
numArgs = numArgs+1;
uniqueArgs[arg] = true; --// :cmd <arg1> <arg2>
table.insert(argTab, arg)
end
end
end

local suppliedArgs = Admin.GetArgs(msg, numArgs) -- User supplied args (when running :alias arg)
local out = aliasCmd;

for i,argType in next,argTab do
local replaceWith = suppliedArgs[i]
if replaceWith then
out = out:gsub(argType, replaceWith)
end
end

return out;
end

server.Admin = {
Init = Init;
Expand Down Expand Up @@ -360,7 +390,7 @@ return function(Vargs)
end
end
end

if game.CreatorType == Enum.CreatorType.User then
if p.userId == game.CreatorId then
return true
Expand Down Expand Up @@ -682,12 +712,6 @@ return function(Vargs)
end
end;

GetArgs = function(msg,num,...)
local args = Functions.Split((msg:match("^.-"..Settings.SplitKey..'(.+)') or ''),Settings.SplitKey,num) or {}
for i,v in next,{...} do table.insert(args,v) end
return args
end;

CacheCommands = function()
local tempTable = {}
local tempPrefix = {}
Expand Down Expand Up @@ -746,7 +770,7 @@ return function(Vargs)
end
end
end;

--// Make it so you can't accidentally overwrite certain existing commands... resulting in being unable to add/edit/remove aliases (and other stuff)
CheckAliasBlacklist = function(alias)
local playerPrefix = Settings.PlayerPrefix;
Expand All @@ -758,25 +782,29 @@ return function(Vargs)
[playerPrefix.. "client"] = true;
[playerPrefix.. "userpanel"] = true;
[":adonissettings"] = true;

}
--return Admin.CommandCache[alias:lower()] --// Alternatively, we could make it so you can't overwrite ANY existing commands...
return blacklist[alias];
end;


GetArgs = function(msg,num,...)
local args = Functions.Split((msg:match("^.-"..Settings.SplitKey..'(.+)') or ''),Settings.SplitKey,num) or {}
for i,v in next,{...} do table.insert(args,v) end
return args
end;

AliasFormat = function(aliases, msg)
if aliases then
for alias,cmd in next,aliases do
if not Admin.CheckAliasBlacklist(alias) then
if msg:match("^"..alias) then
msg = msg:gsub("^"..alias, cmd)
elseif msg:match("%s".. alias) then
msg = msg:gsub("%s".. alias, " "..cmd)
if msg:match("^"..alias) or msg:match("%s".. alias) then
msg = FormatAliasArgs(alias, cmd, msg);
end
end
end
end

return msg
end;

Expand Down
62 changes: 30 additions & 32 deletions MainModule/Server/Core/Commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,32 +116,29 @@ return function(Vargs)
end
end
};
joinserver = {

JoinServer = {
Prefix = Settings.Prefix;
Commands = {"joinserver";};
Args = {"jobid"};
Commands = {"toserver", "joinserver"};
Args = {"player", "jobid"};
Hidden = false;
Description = "Join a server using JobId";
Description = "Send player(s) to a server using the server's JobId";
Fun = false;
AdminLevel = "Moderators";
Function = function(plr,args)
assert(args[1].."Argument missing or nil")

local RunService = game:GetService("RunService")
local jobId = args[2];
assert(args[1] and jobId, "Argument missing or nil")

local RunService = game:GetService("RunService")
if RunService:IsStudio() then
Functions.Message("Adonis", "Command doesn't work in studio.",{plr}, false, 5)

error("Command cannot be used in studio.")
else

local jobid = tostring(args[1])

Functions.Message("Adonis", "Teleporting please wait.",{plr}, false, 10)

game:GetService('TeleportService'):TeleportToPlaceInstance(game.PlaceId,jobid,plr)

end
for i, v in pairs(service.GetPlayers(plr,args[1])) do
Functions.Message("Adonis", "Teleporting please wait.", {v}, false, 10)
game:GetService('TeleportService'):TeleportToPlaceInstance(game.PlaceId, jobId, v)
end
end
end
};

TrelloBan = {
Expand Down Expand Up @@ -848,7 +845,7 @@ return function(Vargs)
Parent = "Variables";
Value = data;
})

v:Kick("Banned until "..endTime)
Functions.Hint("Banned "..v.Name.." for "..time,{plr})
end
Expand Down Expand Up @@ -876,6 +873,7 @@ return function(Vargs)
Parent = "Variables";
Value = data;
})

Functions.Hint(tostring(data.Name)..' has been Unbanned',{plr})
end
end
Expand Down Expand Up @@ -2296,7 +2294,7 @@ return function(Vargs)
Remote.MakeGui(plr,"UserPanel",{Tab = "KeyBinds"})
end
};

Aliases = {
Prefix = Settings.PlayerPrefix;
Commands = {"aliases", "addalias", "removealias", "newalias"};
Expand Down Expand Up @@ -7717,14 +7715,14 @@ return function(Vargs)
Description = "Lets you play an audio on the player's client";
AdminLevel = "Moderators";
Function = function(plr,args,data)

assert(args[1] and args[2],"Argument missing or nil")

local id = args[2]
local volume = 1 --tonumber(args[5]) or 1
local pitch = 1 --tonumber(args[4]) or 1
local loop = true

for i,v in pairs(Variables.MusicList) do
if id==v.Name:lower() then
id = v.ID
Expand Down Expand Up @@ -7752,16 +7750,16 @@ return function(Vargs)
if args[3] and args[3] == "true" then loop = false end
volume = tonumber(args[5]) or volume
pitch = tonumber(args[4]) or pitch


for i,v in pairs(service.GetPlayers(plr,args[1])) do
Remote.Send(v,"Function","PlayAudio",id,volume,pitch,loop)

end
Functions.Hint("Playing Audio on Player's Client",{plr})
end
};

UnTargetAudio = {
Prefix = Settings.Prefix;
Commands = {"untaudio";"unlocalsound";"unlocalaudio";"unlsound";"unlaudio";};
Expand Down Expand Up @@ -7822,7 +7820,7 @@ return function(Vargs)
end
end;
};

Pause = {
Prefix = Settings.Prefix;
Commands = {"pause","pausemusic","psound","pausesound";};
Expand All @@ -7838,12 +7836,12 @@ return function(Vargs)
else
Functions.Hint("Music is already paused | Run "..Settings.Prefix.."resume to resume",{plr})
end

end
end
end
};

Resume = {
Prefix = Settings.Prefix;
Commands = {"resume","resumemusic","rsound","resumesound";};
Expand Down Expand Up @@ -8198,7 +8196,7 @@ return function(Vargs)
Fun = false;
AdminLevel = "Moderators";
Function = function(plr,args,data)


local id = args[1]:lower()
local looped = args[2]
Expand Down Expand Up @@ -8247,14 +8245,14 @@ return function(Vargs)
name = 'Now playing '..mp:GetProductInfo(id).Name
end
end)

if name == 'Invalid ID ' then
Functions.Hint("Invalid ID | Use "..Settings.Prefix.."stopmusic to stop the music",{plr})
return
elseif Settings.SongHint then
Functions.Hint(name, service.Players:GetPlayers())
end

for i, v in pairs(service.Workspace:GetChildren()) do
if v:IsA("Sound") and v.Name == "ADONIS_SOUND" then

Expand Down
4 changes: 2 additions & 2 deletions MainModule/Server/Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ return function(Vargs)
end)


Core.CrossServer("TableRemove", data);
Core.CrossServer("LoadData", "SavedTables");
elseif type == "TableAdd" then
local tab = data.Table
local value = data.Value
Expand All @@ -581,7 +581,7 @@ return function(Vargs)
return sets
end)

Core.CrossServer("TableAdd", data);
Core.CrossServer("LoadData", "SavedTables");
end

Logs.AddLog(Logs.Script,{
Expand Down
Loading

0 comments on commit a182dfa

Please sign in to comment.