Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple prefix support and adds ; as a prefix. #1841

Merged
merged 14 commits into from
Jan 27, 2025
2 changes: 1 addition & 1 deletion Loader/Config/Settings.luau
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ settings.SaveAdmins = true -- If true anyone you :admin or :headadmin in-game
settings.LoadAdminsFromDS = true -- If false, any admins saved in your DataStores will not load
settings.WhitelistEnabled = false -- If true enables the whitelist/server lock; Only lets admins & whitelisted users join

settings.Prefix = ":" -- The : in :kill me
settings.Prefix = {";", ":"} -- A list of prefixes for commands, the ; in ;kill me
settings.PlayerPrefix = "!" -- The ! in !donate; Mainly used for commands that any player can run; Do not make it the same as settings.Prefix
settings.SpecialPrefix = "" -- Used for things like "all", "me" and "others" (If changed to ! you would do :kill !me)
settings.SplitKey = " " -- The space in :kill me (eg if you change it to / :kill me would be :kill/me)
Expand Down
39 changes: 30 additions & 9 deletions MainModule/Server/Core/Admin.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,16 @@ return function(Vargs, GetEnv)
for ind, data in Commands do
if type(data) == "table" then
for i,cmd in data.Commands do
if data.Prefix == "" then Admin.BlankPrefix = true end
tempPrefix[data.Prefix] = true
tempTable[string.lower(data.Prefix..cmd)] = ind
if type(data.Prefix) ~= "table" and data.Prefix == "" then Admin.BlankPrefix = true end
if type(data.Prefix) == "table" then
for _,p in data.Prefix do
tempPrefix[p] = true
tempTable[string.lower(p..cmd)] = ind
end
else
tempPrefix[data.Prefix] = true
tempTable[string.lower(data.Prefix..cmd)] = ind
end
end
end
end
Expand Down Expand Up @@ -1232,13 +1239,27 @@ return function(Vargs, GetEnv)
end

for _, v in data.Commands do
if not blacklistedCommands["/"..data.Prefix..v] then
if not command1 then
command1 = "/"..data.Prefix..v
else
command2 = "/"..data.Prefix..v
if type(data.Prefix) == "table" then
for _, p in data.Prefix do
if not blacklistedCommands["/"..p..v] then
if not command1 then
command1 = "/"..p..v
else
command2 = "/"..p..v
end
end
end
else
if not blacklistedCommands["/"..data.Prefix..v] then
if not command1 then
command1 = "/"..data.Prefix..v
else
command2 = "/"..data.Prefix..v
end
end

end

end

if command1 then
Expand Down Expand Up @@ -1336,7 +1357,7 @@ return function(Vargs, GetEnv)

FormatCommand = function(command, cmdn)
return table.concat({
(command.Prefix or ""),
(if type(command.Prefix) == "table" then command.Prefix[1] else command.Prefix or ""),
tostring(command.Commands[cmdn or 1]),
#command.Args > 0 and Settings.SplitKey or "",
#command.Args > 0 and Admin.FormatCommandArguments(command) or ""
Expand Down
10 changes: 8 additions & 2 deletions MainModule/Server/Core/Commands.luau
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ return function(Vargs, GetEnv)
t = server.Typechecker;

local ValidateCommandDefinition = t.interface({
Prefix = t.string,
Prefix = t.union(t.string, t.array(t.string)),
Commands = t.array(t.string),
Description = t.string,
AdminLevel = t.union(t.string, t.number, t.nan, t.array(t.union(t.string, t.number, t.nan))),
Expand Down Expand Up @@ -99,7 +99,13 @@ return function(Vargs, GetEnv)
Admin.PrefixCache[cmd.Prefix] = true

for _, v in cmd.Commands do
Admin.CommandCache[string.lower(cmd.Prefix..v)] = ind
if type(cmd.Prefix) == "table" then
for _,p in cmd.Prefix do
Admin.CommandCache[string.lower(p..v)] = ind
end
else
Admin.CommandCache[string.lower(cmd.Prefix..v)] = ind
end
end

cmd.Args = cmd.Args or cmd.Arguments or {}
Expand Down
20 changes: 10 additions & 10 deletions MainModule/Server/Dependencies/DefaultSettings.luau
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,13 @@ settings.HideScript = true -- When the game starts the Adonis_Loader model
settings.DataStore = "Adonis_1" -- DataStore the script will use for saving data; Changing this will lose any saved data
settings.DataStoreKey = "CHANGE_THIS" -- CHANGE THIS TO ANYTHING RANDOM! Key used to encrypt all datastore entries; Changing this will lose any saved data
settings.DataStoreEnabled = true -- Disable if you don't want to load settings and admins from the datastore; PlayerData will still save
settings.LocalDatastore = false -- If this is turned on, a mock DataStore will forcibly be used instead and shall never save across servers
settings.LocalDatastore = false -- If this is turned on, a mock DataStore will forcibly be used instead and shall never save across servers

settings.Storage = game:GetService("ServerStorage") -- Where things like tools are stored
settings.RecursiveTools = false -- Whether tools that are included in sub-containers within settings.Storage will be available via the :give command (useful if your tools are organized into multiple folders)
settings.Storage = game:GetService("ServerStorage") -- Where things like tools are stored
settings.RecursiveTools = false -- Whether tools that are included in sub-containers within settings.Storage will be available via the :give command (useful if your tools are organized into multiple folders)

settings.Theme = "Default" -- UI theme;
settings.MobileTheme = "Mobilius" -- Theme to use on mobile devices; Some UI elements are disabled
settings.DefaultTheme = "Default" -- Theme to be used as a replacement for "Default". The new replacement theme can still use "Default" as its Base_Theme however any other theme that references "Default" as its redirects to this theme.

--[[
**HOW TO ADD ADMINISTRATORS:**
Expand All @@ -158,7 +157,7 @@ settings.DefaultTheme = "Default" -- Theme to be used as a replacement for "Defa
settings.Ranks = {
["Moderators"] = {
Level = 100;
Users = {"Username"; "Username:UserId"; UserId; "Group:GroupId:GroupRank"; "Group:GroupId"; "Item:ItemID"; "GamePass:GamePassID";}
Users = {"Username"; "Username:UserId"; UserId; "Group:GroupId:GroupRank"; "Group:GroupId"; "Item:ItemID"; "GamePass:GamePassID"; "Subscription:SubscriptionId";}
}
}

Expand Down Expand Up @@ -211,7 +210,6 @@ settings.Aliases = {
[":examplealias <player> <fireColor>"] = ":ff <player> | :fling <player> | :fire <player> <fireColor>" --// Order arguments appear in alias string determines their required order in the command message when ran later
};

--// Use the below table to define pre-set cameras
settings.Cameras = {
--[[
"Camera Name" would be the name of your camera
Expand Down Expand Up @@ -240,7 +238,7 @@ settings.SaveAdmins = true -- If true anyone you :admin or :headadmin in-game
settings.LoadAdminsFromDS = true -- If false, any admins saved in your DataStores will not load
settings.WhitelistEnabled = false -- If true enables the whitelist/server lock; Only lets admins & whitelisted users join

settings.Prefix = ":" -- The : in :kill me
settings.Prefix = {";", ":"} -- A list of prefixes for commands, the ; in ;kill me
settings.PlayerPrefix = "!" -- The ! in !donate; Mainly used for commands that any player can run; Do not make it the same as settings.Prefix
settings.SpecialPrefix = "" -- Used for things like "all", "me" and "others" (If changed to ! you would do :kill !me)
settings.SplitKey = " " -- The space in :kill me (eg if you change it to / :kill me would be :kill/me)
Expand Down Expand Up @@ -295,7 +293,7 @@ settings.ChatCommands = true -- If false you will not be able to run commands
settings.CreatorPowers = true -- Gives me creator-level admin; This is strictly used for debugging; I can't debug without full access to the script
settings.CodeExecution = true -- Enables the use of code execution in Adonis; Scripting related (such as :s) and a few other commands require this
settings.SilentCommandDenials = false -- If true, there will be no differences between the error messages shown when a user enters an invalid command and when they have insufficient permissions for the command
settings.OverrideChatCallbacks = true -- If the TextChatService ShouldDeliverCallbacks of all channels are overridden by Adonis on load. Required for slowmode. Mutes use a CanSend method to mute when this is set to false.
settings.OverrideChatCallbacks = true -- If the TextChatService ShouldDeliverCallbacks of all channels are overridden by Adonis on load. Required for slowmode. Mutes use a CanSend method to mute when this is set to false.

settings.BanMessage = "Banned" -- Message shown to banned users upon kick
settings.LockMessage = "Not Whitelisted" -- Message shown to people when they are kicked while the game is :slocked
Expand All @@ -306,6 +304,7 @@ settings.SaveCommandLogs = true -- If command logs are saved to the d
settings.Notification = true -- Whether or not to show the "You're an admin" and "Updated" notifications
settings.SongHint = true -- Display a hint with the current song name and ID when a song is played via :music
settings.TopBarShift = false -- By default hints and notifications will appear from the top edge of the window. Set this to true if you don't want hints/notifications to appear in that region.
settings.DefaultTheme = "Default" -- Theme to be used as a replacement for "Default". The new replacement theme can still use "Default" as its Base_Theme however any other theme that references "Default" as its redirects to this theme.
settings.HiddenThemes = {} -- Hide themes from the theme selector tab inside the userpanel. Each theme name must be the specific name such as "Mobilius"
settings.Messages = {} -- A list of notifications shown on join. Messages can either be strings or tables. Messages are shown to HeadAdmins+ by default but tables can define a different minimum level via .Level
settings.AutoClean = false -- Will auto clean workspace of things like hats and tools
Expand Down Expand Up @@ -408,7 +407,6 @@ descs.RecursiveTools = [[ Whether tools that are included in sub-containers with

descs.Theme = [[ UI theme; ]]
descs.MobileTheme = [[ Theme to use on mobile devices; Mobile themes are optimized for smaller screens; Some GUIs are disabled ]]
descs.DefaultTheme = [[ Theme to be used as a replacement for "Default". The new replacement theme can still use "Default" as its Base_Theme however any other theme that references "Default" as its redirects to this theme. ]]

descs.Ranks = [[ All admin permission level ranks; ]];
descs.Moderators = [[ Mods; Format: {"Username"; "Username:UserId"; UserId; "Group:GroupId:GroupRank"; "Group:GroupId"; "Item:ItemID";} ]]
Expand Down Expand Up @@ -481,6 +479,7 @@ descs.Notification = [[ Whether or not to show the "You're an admin" and "Update
descs.CodeExecution = [[ Enables the use of code execution in Adonis; Scripting related and a few other commands require this ]]
descs.SongHint = [[ Display a hint with the current song name and ID when a song is played via :music ]]
descs.TopBarShift = [[ By default hints and notifs will appear from the top edge of the window. Set this to true if you don't want hints/notifications to appear in that region. ]]
descs.DefaultTheme = [[ Theme to be used as a replacement for "Default". The new replacement theme can still use "Default" as its Base_Theme however any other theme that references "Default" as its redirects to this theme. ]]
descs.ReJail = [[ If true then when a player rejoins they'll go back into jail. Or if the moderator leaves everybody gets unjailed ]]

descs.Messages = [[ A list of notifications shown on join. Messages can either be strings or tables. Messages are shown to HeadAdmins+ by default but tables can define a different minimum level via .Level ]]
Expand Down Expand Up @@ -530,7 +529,6 @@ order = {
" ";
"Theme";
"MobileTheme";
"DefaultTheme";
" ";
"Ranks";
" ";
Expand Down Expand Up @@ -598,13 +596,15 @@ order = {
"Notification";
"SongHint";
"TopBarShift";
"DefaultTheme";
"ReJail";
"";
"AutoClean";
"AutoCleanDelay";
"AutoBackup";
" ";
"PlayerList";
" ";
"Console";
"Console_AdminsOnly";
" ";
Expand Down
Loading