summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/Core/console.lua24
-rw-r--r--MCServer/Plugins/Core/do.lua29
-rw-r--r--MCServer/Plugins/Core/functions.lua161
-rw-r--r--MCServer/Plugins/Core/kick.lua27
-rw-r--r--MCServer/Plugins/Core/main.lua7
-rw-r--r--MCServer/Plugins/Core/messages.lua27
-rw-r--r--MCServer/Plugins/Core/motd.lua50
-rw-r--r--MCServer/Plugins/Core/ondeath.lua11
-rw-r--r--MCServer/Plugins/Core/teleport.lua26
9 files changed, 197 insertions, 165 deletions
diff --git a/MCServer/Plugins/Core/console.lua b/MCServer/Plugins/Core/console.lua
index 44fdc83ff..669d7c9cb 100644
--- a/MCServer/Plugins/Core/console.lua
+++ b/MCServer/Plugins/Core/console.lua
@@ -336,27 +336,3 @@ function HandleConsoleUnload(Split)
Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount();
return true, Out;
end
-
-
--- Helper functions:
-
---- Returns the list of players banned by name, separated by ", "
-function BanListByName()
- local NumValues = BannedPlayersIni:NumValues("Banned");
- local Banned = {};
- local KeyID = BannedPlayersIni:FindKey("Banned");
- for i = 1, NumValues do
- local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1);
- if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then
- -- Player listed AND banned
- table.insert(Banned, PlayerName);
- end
- end
- return table.concat(Banned, ", ");
-end
-
---- Returns the list of players banned by IP, separated by ", "
-function BanListByIPs()
- -- TODO: No IP ban implemented yet
- return "";
-end
diff --git a/MCServer/Plugins/Core/do.lua b/MCServer/Plugins/Core/do.lua
new file mode 100644
index 000000000..6ac7e96cd
--- /dev/null
+++ b/MCServer/Plugins/Core/do.lua
@@ -0,0 +1,29 @@
+function HandleDoCommand( Split, Player )
+
+ if #Split < 3 then
+ SendMessage( "Usage: /do <player> <command> [arguments]" )
+ return true
+ end
+
+ -- Get the command and arguments.
+ local newSplit = table.concat( Split, " ", 3 )
+
+ local pluginManager = cRoot:Get():GetPluginManager()
+ pluginManager:ExecuteCommand( Split[2], newSplit )
+
+end
+
+function HandleSudoCommand ( Split, Player )
+
+ if #Split < 3 then
+ SendMessage( "Usage: /sudo <player> <command> [arguments]" )
+ return true
+ end
+
+ -- Get the command and arguments.
+ local newSplit = table.concat( Split, " ", 3 )
+
+ local pluginManager = cRoot:Get():GetPluginManager()
+ pluginManager:ForceExecuteCommand( Split[2], newSplit )
+
+end
diff --git a/MCServer/Plugins/Core/functions.lua b/MCServer/Plugins/Core/functions.lua
index 5fc0173b9..75a078a53 100644
--- a/MCServer/Plugins/Core/functions.lua
+++ b/MCServer/Plugins/Core/functions.lua
@@ -1,3 +1,162 @@
function SetBackCoordinates( Player )
BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() )
-end \ No newline at end of file
+end
+
+function SendMessage(a_Player, a_Message)
+ if (g_UsePrefixes) then
+ a_Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. a_Message)
+ else
+ a_Player:SendMessage(cChatColor.Yellow .. a_Message)
+ end
+end
+
+function SendMessageSuccess(a_Player, a_Message)
+ if (g_UsePrefixes) then
+ a_Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. a_Message)
+ else
+ a_Player:SendMessage(cChatColor.Green .. a_Message)
+ end
+end
+
+function SendMessageFailure(a_Player, a_Message)
+ if (g_UsePrefixes) then
+ a_Player:SendMessage(cChatColor.Red .. "[INFO] " .. cChatColor.White .. a_Message)
+ else
+ a_Player:SendMessage(cChatColor.Red .. a_Message)
+ end
+end
+
+--- Returns the list of players banned by name, separated by ", "
+function BanListByName()
+ local NumValues = BannedPlayersIni:NumValues("Banned");
+ local Banned = {};
+ local KeyID = BannedPlayersIni:FindKey("Banned");
+ for i = 1, NumValues do
+ local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1);
+ if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then
+ -- Player listed AND banned
+ table.insert(Banned, PlayerName);
+ end
+ end
+ return table.concat(Banned, ", ");
+end
+
+--- Returns the list of players banned by IP, separated by ", "
+function BanListByIPs()
+ -- TODO: No IP ban implemented yet
+ return "";
+end
+
+--- Kicks a player by name, with the specified reason; returns bool whether found and player's real name
+function KickPlayer( PlayerName, Reason )
+
+ local RealName = ""
+ if (Reason == nil) then
+ Reason = "You have been kicked"
+ end
+
+ local FoundPlayerCallback = function( a_Player )
+ RealName = a_Player:GetName()
+
+ local Server = cRoot:Get():GetServer()
+ LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
+ Server:SendMessage("Kicking " .. RealName)
+
+ a_Player:GetClientHandle():Kick(Reason)
+ end
+
+ if not cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback ) then
+ -- Could not find player
+ return false
+ end
+
+ return true, RealName -- Player has been kicked
+
+end
+
+
+function ReturnColorFromChar( Split, char )
+
+ -- Check if the char represents a color. Else return nil.
+ if char == "0" then
+ return cChatColor.Black
+ elseif char == "1" then
+ return cChatColor.Navy
+ elseif char == "2" then
+ return cChatColor.Green
+ elseif char == "3" then
+ return cChatColor.Blue
+ elseif char == "4" then
+ return cChatColor.Red
+ elseif char == "5" then
+ return cChatColor.Purple
+ elseif char == "6" then
+ return cChatColor.Gold
+ elseif char == "7" then
+ return cChatColor.LightGray
+ elseif char == "8" then
+ return cChatColor.Gray
+ elseif char == "9" then
+ return cChatColor.DarkPurple
+ elseif char == "a" then
+ return cChatColor.LightGreen
+ elseif char == "b" then
+ return cChatColor.LightBlue
+ elseif char == "c" then
+ return cChatColor.Rose
+ elseif char == "d" then
+ return cChatColor.LightPurple
+ elseif char == "e" then
+ return cChatColor.Yellow
+ elseif char == "f" then
+ return cChatColor.White
+ elseif char == "k" then
+ return cChatColor.Random
+ elseif char == "l" then
+ return cChatColor.Bold
+ elseif char == "m" then
+ return cChatColor.Strikethrough
+ elseif char == "n" then
+ return cChatColor.Underlined
+ elseif char == "o" then
+ return cChatColor.Italic
+ elseif char == "r" then
+ return cChatColor.Plain
+ end
+
+end
+
+function CheckHardcore(Victim)
+ if HardCore == "true" then
+ if Victim:IsPlayer() == true then
+ local KilledPlayer = tolua.cast(Victim, "cPlayer")
+ BanPlayer(KilledPlayer:GetName(), "You died, haha. Good game, bro.")
+ end
+ end
+end
+
+-- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player
+function TeleportToPlayer( a_SrcPlayer, a_DstPlayerName, a_TellDst )
+
+ local teleport = function(OtherPlayer)
+
+ if OtherPlayer == a_SrcPlayer then
+ -- Asked to teleport to self?
+ SendMessageFailure( a_SrcPlayer, "Y' can't teleport to yerself!" )
+ else
+ SetBackCoordinates( a_SrcPlayer )
+ a_SrcPlayer:TeleportToEntity( OtherPlayer )
+ SendMessageSuccess( a_SrcPlayer, "You teleported to " .. OtherPlayer:GetName() .. "!" )
+ if (a_TellDst) then
+ SendMessage( OtherPlayer, Player:GetName().." teleported to you!" )
+ end
+ end
+
+ end
+
+ local World = a_SrcPlayer:GetWorld()
+ if not World:DoWithPlayer(a_DstPlayerName, teleport) then
+ SendMessageFailure( a_SrcPlayer, "Can't find player " .. a_DstPlayerName)
+ end
+
+end
diff --git a/MCServer/Plugins/Core/kick.lua b/MCServer/Plugins/Core/kick.lua
index bcea1bd8b..1bc2ab128 100644
--- a/MCServer/Plugins/Core/kick.lua
+++ b/MCServer/Plugins/Core/kick.lua
@@ -17,30 +17,3 @@ function HandleKickCommand( Split, Player )
return true
end
-
---- Kicks a player by name, with the specified reason; returns bool whether found and player's real name
-function KickPlayer( PlayerName, Reason )
-
- local RealName = ""
- if (Reason == nil) then
- Reason = "You have been kicked"
- end
-
- local FoundPlayerCallback = function( a_Player )
- RealName = a_Player:GetName()
-
- local Server = cRoot:Get():GetServer()
- LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
- Server:SendMessage("Kicking " .. RealName)
-
- a_Player:GetClientHandle():Kick(Reason)
- end
-
- if not cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback ) then
- -- Could not find player
- return false
- end
-
- return true, RealName -- Player has been kicked
-
-end
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua
index da4d1e84e..28df69cc3 100644
--- a/MCServer/Plugins/Core/main.lua
+++ b/MCServer/Plugins/Core/main.lua
@@ -7,6 +7,11 @@ Messages = {}
Destination = {}
--END VARIABLES
+-- Configuration
+-- Use prefixes or not.
+-- If set to true, messages are prefixed, e. g. "[FATAL]". If false, messages are colored.
+g_UsePrefixes = true
+
--COMMENCE AWESOMENESS!
function Initialize( Plugin )
PLUGIN = Plugin
@@ -62,6 +67,8 @@ function Initialize( Plugin )
PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
PluginManager:BindCommand("/weather", "core.weather", HandleWeatherCommand, " ~ Change world weather")
PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds")
+ PluginManager:BindCommand("/sudo", "core.sudo", HandleSudoCommand, " - Runs a command as a player, ignoring permissions")
+ PluginManager:BindCommand("/do", "core.do", HandleDoCommand, " - Runs a command as a player.")
InitConsoleCommands()
diff --git a/MCServer/Plugins/Core/messages.lua b/MCServer/Plugins/Core/messages.lua
deleted file mode 100644
index 91a4a7337..000000000
--- a/MCServer/Plugins/Core/messages.lua
+++ /dev/null
@@ -1,27 +0,0 @@
--- Use prefixes or not.
--- If set to true, messages are prefixed, e. g. "[FATAL]". If false, messages are colored.
-g_UsePrefixes = true
-
-function SendMessage(a_Player, a_Message)
- if (g_UsePrefixes) then
- a_Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. a_Message)
- else
- a_Player:SendMessage(cChatColor.Yellow .. a_Message)
- end
-end
-
-function SendMessageSuccess(a_Player, a_Message)
- if (g_UsePrefixes) then
- a_Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. a_Message)
- else
- a_Player:SendMessage(cChatColor.Green .. a_Message)
- end
-end
-
-function SendMessageFailure(a_Player, a_Message)
- if (g_UsePrefixes) then
- a_Player:SendMessage(cChatColor.Red .. "[INFO] " .. cChatColor.White .. a_Message)
- else
- a_Player:SendMessage(cChatColor.Red .. a_Message)
- end
-end
diff --git a/MCServer/Plugins/Core/motd.lua b/MCServer/Plugins/Core/motd.lua
index edeec78b7..3909c18e3 100644
--- a/MCServer/Plugins/Core/motd.lua
+++ b/MCServer/Plugins/Core/motd.lua
@@ -42,53 +42,3 @@ function ShowMOTDTo( Player )
end
end
-function ReturnColorFromChar( Split, char )
-
- -- Check if the char represents a color. Else return nil.
- if char == "0" then
- return cChatColor.Black
- elseif char == "1" then
- return cChatColor.Navy
- elseif char == "2" then
- return cChatColor.Green
- elseif char == "3" then
- return cChatColor.Blue
- elseif char == "4" then
- return cChatColor.Red
- elseif char == "5" then
- return cChatColor.Purple
- elseif char == "6" then
- return cChatColor.Gold
- elseif char == "7" then
- return cChatColor.LightGray
- elseif char == "8" then
- return cChatColor.Gray
- elseif char == "9" then
- return cChatColor.DarkPurple
- elseif char == "a" then
- return cChatColor.LightGreen
- elseif char == "b" then
- return cChatColor.LightBlue
- elseif char == "c" then
- return cChatColor.Rose
- elseif char == "d" then
- return cChatColor.LightPurple
- elseif char == "e" then
- return cChatColor.Yellow
- elseif char == "f" then
- return cChatColor.White
- elseif char == "k" then
- return cChatColor.Random
- elseif char == "l" then
- return cChatColor.Bold
- elseif char == "m" then
- return cChatColor.Strikethrough
- elseif char == "n" then
- return cChatColor.Underlined
- elseif char == "o" then
- return cChatColor.Italic
- elseif char == "r" then
- return cChatColor.Plain
- end
-
-end
diff --git a/MCServer/Plugins/Core/ondeath.lua b/MCServer/Plugins/Core/ondeath.lua
index a5f8f6745..4cb62f6a8 100644
--- a/MCServer/Plugins/Core/ondeath.lua
+++ b/MCServer/Plugins/Core/ondeath.lua
@@ -44,7 +44,7 @@ function OnKilling(Victim, Killer)
elseif Killer:IsA("cMagmacube") then
Server:SendMessage( cChatColor.Red .. "[FATALITY] " .. cChatColor.White .. Victim:GetName() .. " was incinerated by a magmacube")
elseif Killer:IsA("cWolf") then
- Server:SendMessage( cChatColor.Red .. "[FATALITY] " .. cChatColor.White .. Victim:GetName() .. " was savaged by a wolf")
+ Server:SendMessage( cChatColor.Red .. "[FATALITY] " .. cChatColor.White .. Victim:GetName() .. " was savaged by a wolf")
end
CheckHardcore(Victim)
return false
@@ -54,12 +54,3 @@ function OnKilling(Victim, Killer)
CheckHardcore(Victim)
end
end
-
-function CheckHardcore(Victim)
- if HardCore == "true" then
- if Victim:IsPlayer() == true then
- local KilledPlayer = tolua.cast(Victim, "cPlayer")
- BanPlayer(KilledPlayer:GetName(), "You died, haha. Good game, bro.")
- end
- end
-end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua
index 70aee131c..126801648 100644
--- a/MCServer/Plugins/Core/teleport.lua
+++ b/MCServer/Plugins/Core/teleport.lua
@@ -72,29 +72,3 @@ function HandleTPAcceptCommand( Split, Player )
return true
end
-
--- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player
-function TeleportToPlayer( a_SrcPlayer, a_DstPlayerName, a_TellDst )
-
- local teleport = function(OtherPlayer)
-
- if OtherPlayer == a_SrcPlayer then
- -- Asked to teleport to self?
- SendMessageFailure( a_SrcPlayer, "Y' can't teleport to yerself!" )
- else
- SetBackCoordinates( a_SrcPlayer )
- a_SrcPlayer:TeleportToEntity( OtherPlayer )
- SendMessageSuccess( a_SrcPlayer, "You teleported to " .. OtherPlayer:GetName() .. "!" )
- if (a_TellDst) then
- SendMessage( OtherPlayer, Player:GetName().." teleported to you!" )
- end
- end
-
- end
-
- local World = a_SrcPlayer:GetWorld()
- if not World:DoWithPlayer(a_DstPlayerName, teleport) then
- SendMessageFailure( a_SrcPlayer, "Can't find player " .. a_DstPlayerName)
- end
-
-end