summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-08-03 09:37:43 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-08-03 09:37:43 +0200
commitf14b0ec7fd15e5b7e1819327c07e6198160d422c (patch)
treeffd926c89b67b5a9825701df47fc68101f5458cf
parentMerge pull request #37 from tigerw/master (diff)
downloadcuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar.gz
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar.bz2
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar.lz
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar.xz
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.tar.zst
cuberite-f14b0ec7fd15e5b7e1819327c07e6198160d422c.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/Core/ban-unban.lua45
-rw-r--r--MCServer/Plugins/Core/console.lua69
-rw-r--r--MCServer/Plugins/Core/onjoinleave.lua19
-rw-r--r--MCServer/Plugins/Core/onlogin.lua2
4 files changed, 70 insertions, 65 deletions
diff --git a/MCServer/Plugins/Core/ban-unban.lua b/MCServer/Plugins/Core/ban-unban.lua
index 1ad9b7e75..480e5633e 100644
--- a/MCServer/Plugins/Core/ban-unban.lua
+++ b/MCServer/Plugins/Core/ban-unban.lua
@@ -4,37 +4,22 @@ function HandleBanCommand( Split, Player )
return true
end
- local Reason = "You have been banned"
+ local Reason = cChatColor.Red .. "You have been banned." .. cChatColor.White .. " Did you do something illegal?"
if( #Split > 2 ) then
Reason = table.concat(Split, " ", 3)
end
-
- if( BanPlayer(Split[2], Reason) == false ) then
- Player:SendMessage(cChatColor.Rose .. "[INFO] " .. cChatColor.White .. "Could not find player " .. Split[2] )
- return true
- end
-
- return true
-end
-
-function BanPlayer(PlayerName, Reason)
- -- Ban the player in the banned.ini:
- BannedPlayersIni:SetValueB("Banned", PlayerName, true)
- BannedPlayersIni:WriteFile()
- -- Kick the player:
- if (Reason == nil) then
- Reason = "You have been banned"
- end
- local Success = KickPlayer(PlayerName, Reason)
- if (not(Success)) then
- return false;
+ if KickPlayer(Split[2], Reason) == false then
+ BannedPlayersIni:DeleteValue("Banned", Split[2])
+ BannedPlayersIni:SetValueB("Banned", Split[2], true)
+ BannedPlayersIni:WriteFile()
+ Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "Could not find player, but banned anyway" )
+ else
+ BannedPlayersIni:DeleteValue("Banned", Split[2])
+ BannedPlayersIni:SetValueB("Banned", Split[2], true)
+ BannedPlayersIni:WriteFile()
+ Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "Successfully kicked and banned player" )
end
-
- LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") ");
- local Server = cRoot:Get():GetServer();
- Server:SendMessage("Banned " .. PlayerName);
-
return true
end
@@ -45,16 +30,16 @@ function HandleUnbanCommand( Split, Player )
end
if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then
- Player:SendMessage(cChatColor.Rose .. "[INFO] " .. cChatColor.White .. " is not banned!" )
+ Player:SendMessage(cChatColor.Rose .. "[INFO] " .. cChatColor.White .. Split[2] .. " is not banned!" )
return true
end
- BannedPlayersIni:SetValueB("Banned", Split[2], false, false)
+ BannedPlayersIni:DeleteValue("Banned", Split[2])
+ BannedPlayersIni:SetValueB("Banned", Split[2], false)
BannedPlayersIni:WriteFile()
- local Server = cRoot:Get():GetServer()
LOGINFO( Player:GetName() .. " is unbanning " .. Split[2] )
- Server:SendMessage( "Unbanning " .. Split[2] )
+ Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "Unbanning " .. Split[2] )
return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/console.lua b/MCServer/Plugins/Core/console.lua
index 7c1e6abde..59a60ae62 100644
--- a/MCServer/Plugins/Core/console.lua
+++ b/MCServer/Plugins/Core/console.lua
@@ -4,39 +4,47 @@ function InitConsoleCommands()
local PluginMgr = cPluginManager:Get();
-- Please keep the list alpha-sorted
- PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, "Bans a player by name");
- PluginMgr:BindConsoleCommand("unban", HandleConsoleUnban, "Unbans a player by name");
- PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, "Lists all players banned by name");
- PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP");
- PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands");
- PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format");
- PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups");
- PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded");
- PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players");
- PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients");
- PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group");
- PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins");
- PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks");
- PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players");
- PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks");
+ PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, " ~ Bans a player by name");
+ PluginMgr:BindConsoleCommand("unban", HandleConsoleUnban, " ~ Unbans a player by name");
+ PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, " - Lists all players banned by name");
+ PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, " - Lists all players banned by IP");
+ PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, " - Lists all commands");
+ PluginMgr:BindConsoleCommand("list", HandleConsoleList, " - Lists all players in a machine-readable format");
+ PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, " - Shows a list of all the groups");
+ PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, " - Shows number of chunks currently loaded");
+ PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, " - Lists all connected players");
+ PluginMgr:BindConsoleCommand("getversion", HandleConsoleVersion, " - Gets server version reported to 1.4+ clients");
+ PluginMgr:BindConsoleCommand("setversion", HandleConsoleVersion, " ~ Sets server version reported to 1.4+ clients");
+ PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " ~ Add a player to a group");
+ PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, " - Reloads all plugins");
+ PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, " - Saves all chunks");
+ PluginMgr:BindConsoleCommand("say", HandleConsoleSay, " - Sends a chat message to all players");
+ PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, " - Unloads all unused chunks");
end
function HandleConsoleBan(Split)
if (#Split < 2) then
return true, "Usage: ban [Player] <Reason>";
- end
-
- local Reason = "You have been banned"
- if (#Split > 2) then
- Reason = table.concat(Split, " ", 3);
- end
+ end
+ local Reason = cChatColor.Red .. "You have been banned." .. cChatColor.White .. " Did you do something illegal?"
+ if( #Split > 2 ) then
+ Reason = table.concat(Split, " ", 3)
+ end
- if (not(BanPlayer(Split[2], Reason))) then
- return true, "Could not find player " .. Split[2];
+ if KickPlayer(Split[2], Reason) == false then
+ BannedPlayersIni:DeleteValue("Banned", Split[2])
+ BannedPlayersIni:SetValueB("Banned", Split[2], true)
+ BannedPlayersIni:WriteFile()
+ LOGINFO("Could not find player, but banned anyway" )
+ else
+ BannedPlayersIni:DeleteValue("Banned", Split[2])
+ BannedPlayersIni:SetValueB("Banned", Split[2], true)
+ BannedPlayersIni:WriteFile()
+ LOGINFO("Successfully kicked and banned player" )
end
- return true, "Player " .. Split[2] .. " has been banned.";
+ return true
end
function HandleConsoleUnban(Split)
@@ -87,9 +95,10 @@ function HandleConsoleHelp(Split)
table.sort(Commands, CompareCommands);
local Out = "";
+ Out = "'-' denotes no prefix, '~' denotes that a value is required.\n"
for i, Command in ipairs(Commands) do
Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table
- Out = Out .. " - " .. Command[2] .. "\n";
+ Out = Out .. Command[2] .. "\n";
end
return true, Out;
end
@@ -171,7 +180,7 @@ function HandleConsolePlayers(Split)
return true, Out;
end
-function HandleConsolePrimaryServerVersion(Split)
+function HandleConsoleVersion(Split)
if (#Split == 1) then
-- Display current version:
local Version = cRoot:Get():GetPrimaryServerVersion();
@@ -218,7 +227,7 @@ function HandleConsoleRank(Split)
World:ForEachPlayer(
function (Player)
if (Player:GetName() == Split[2]) then
- Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]);
+ Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. "You were moved to group " .. Split[3]);
Player:LoadPermissionsFromDisk();
end
end
@@ -231,12 +240,14 @@ end
function HandleConsoleReload(Split)
Server = cRoot:Get():GetServer();
- Server:SendMessage(cChatColor.Green .. "Reloading all plugins.");
+ Server:SendMessage(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Reloading all plugins!");
cPluginManager:Get():ReloadPlugins();
return true;
end
function HandleConsoleSaveAll(Split)
+ Server = cRoot:Get():GetServer();
+ Server:SendMessage(cChatColor.Rose .. "[WARNING] " .. cChatColor.White .. "Saving all chunks!");
cRoot:Get():SaveAllChunks();
return true;
end
@@ -248,7 +259,7 @@ function HandleConsoleSay(Split)
Message = Message .. " " .. Text;
end
Message = Message:sub(2); -- Cut off the first space
- cRoot:Get():GetServer():BroadcastChat(cChatColor.Purple .. "[SERVER] " .. Message);
+ cRoot:Get():GetServer():BroadcastChat(cChatColor.Gold .. "[SERVER] " .. cChatColor.Yellow .. Message);
return true;
end
diff --git a/MCServer/Plugins/Core/onjoinleave.lua b/MCServer/Plugins/Core/onjoinleave.lua
index 7acef47de..372f6af47 100644
--- a/MCServer/Plugins/Core/onjoinleave.lua
+++ b/MCServer/Plugins/Core/onjoinleave.lua
@@ -1,8 +1,19 @@
function OnPlayerJoined(Player)
- ShowMOTDTo( Player )
- local Server = cRoot:Get():GetServer()
- Server:SendMessage(cChatColor.Yellow .. "[JOIN] " .. cChatColor.White .. Player:GetName() .. " has joined the game" )
- return false
+ --if( BannedPlayersIni:GetValueB("Banned", Player:GetName(), false) == true ) then
+ -- LOGINFO( Player:GetName() .. " tried to join, but is banned!" )
+ -- KickPlayer(Player:GetName(), cChatColor.Red .. "You are banned!" )
+ -- return true
+ --elseif( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then
+ -- if( WhiteListIni:GetValueB("WhiteList", Player:GetName(), false ) == false ) then
+ -- LOGINFO( Player:GetName() .. " tried to join, but is not whitelisted!" )
+ -- KickPlayer(Player:GetName(), cChatColor.Red .. "You are not whitelisted!" )
+ -- end
+ --else
+ ShowMOTDTo( Player )
+ local Server = cRoot:Get():GetServer()
+ Server:SendMessage(cChatColor.Yellow .. "[JOIN] " .. cChatColor.White .. Player:GetName() .. " has joined the game" )
+ return false
+ --end
end
function OnDisconnect(Player, Reason)
diff --git a/MCServer/Plugins/Core/onlogin.lua b/MCServer/Plugins/Core/onlogin.lua
index cc79bb0ae..6826305b2 100644
--- a/MCServer/Plugins/Core/onlogin.lua
+++ b/MCServer/Plugins/Core/onlogin.lua
@@ -1,8 +1,6 @@
function OnLogin(Client, ProtocolVersion, Username)
if( Username ~= "" ) then
if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then
- local Server = cRoot:Get():GetServer()
- Server:SendMessage( Username .. " tried to join, but is banned!" )
LOGINFO( Username .. " tried to join, but is banned!")
return true -- Player is banned, return true to deny access
end