diff options
author | nielsbreu@gmail.com <nielsbreu@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-07-05 21:56:32 +0200 |
---|---|---|
committer | nielsbreu@gmail.com <nielsbreu@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-07-05 21:56:32 +0200 |
commit | ae22e2545d4c300c2ef535621cf0aa013bf748c7 (patch) | |
tree | 332c3d28d9356e44ba86da68128ff4c59723dd18 /MCServer/Plugins | |
parent | Initial 1.6.1 protocol support. (diff) | |
download | cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar.gz cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar.bz2 cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar.lz cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar.xz cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.tar.zst cuberite-ae22e2545d4c300c2ef535621cf0aa013bf748c7.zip |
Diffstat (limited to 'MCServer/Plugins')
-rw-r--r-- | MCServer/Plugins/Core/main.lua | 2 | ||||
-rw-r--r-- | MCServer/Plugins/Core/motd.lua | 84 |
2 files changed, 83 insertions, 3 deletions
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua index acdcd1606..7558a5e6f 100644 --- a/MCServer/Plugins/Core/main.lua +++ b/MCServer/Plugins/Core/main.lua @@ -8,6 +8,7 @@ PLUGIN = {} -- Reference to own plugin object BannedPlayersIni = {}
WhiteListIni = {}
BackCoords = {}
+Messages = {}
LimitWorldsCuboid = {}
@@ -122,6 +123,7 @@ function Initialize(Plugin) Plugin:AddWebTab("Permissions", HandleRequest_Permissions);
Plugin:AddWebTab("Manage Plugins", HandleRequest_ManagePlugins);
+ LoadMotd()
LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
return true
end
\ No newline at end of file diff --git a/MCServer/Plugins/Core/motd.lua b/MCServer/Plugins/Core/motd.lua index 69f3ee245..cff35e3c4 100644 --- a/MCServer/Plugins/Core/motd.lua +++ b/MCServer/Plugins/Core/motd.lua @@ -3,8 +3,86 @@ function HandleMOTDCommand( Split, Player ) return true
end
+function LoadMotd()
+ local File = io.open("motd.txt", "r")
+ if not File then
+ CreateFile = io.open("motd.txt", "w")
+ CreateFile:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands")
+ CreateFile:close()
+ else
+ File:close()
+ end
+ local Lines = 0
+ for _ in io.lines'motd.txt' do
+ Lines = Lines + 1
+ end
+ for line in io.lines("motd.txt") do
+ Split = StringSplit( line, " " )
+ local TempMessage = ""
+ for i=1, #Split do
+ if string.find( Split[i], "@" ) ~= nil then
+ local TempWord = ""
+ for I=1, string.len(Split[i]) do
+ if string.sub( Split[i], I, I ) == "@" then
+ local Color, Char = ReturnColor( string.sub( Split[i], I + 1, I + 1 ), 0 )
+ TempWord = TempWord .. Color
+ StopNextChar = true
+ else
+ if StopNextChar ~= true then
+ TempWord = TempWord .. string.sub( Split[i], I, I )
+ end
+ StopNextChar = false
+ end
+ end
+ TempMessage = TempMessage .. TempWord .. " "
+ else
+ TempMessage = TempMessage .. Split[i] .. " "
+ end
+ end
+ Messages[#Messages + 1] = TempMessage
+ end
+end
+
function ShowMOTDTo( Player )
- Player:SendMessage( cChatColor.Gold .. "Welcome to the MCServer test server!" );
- Player:SendMessage( cChatColor.Gold .. "http://www.mcserver.org/" );
- Player:SendMessage( cChatColor.Gold .. "Type /help for all commands" );
+ for I=1, #Messages do
+ Player:SendMessage(Messages[I])
+ end
+end
+
+function ReturnColor( Split, char )
+ if string.sub( Split, char + 1, char + 1 ) == "0" then
+ return cChatColor.Black, 0
+ elseif string.sub( Split, char + 1, char + 1 ) == "1" then
+ return cChatColor.Navy, 1
+ elseif string.sub( Split, char + 1, char + 1 ) == "2" then
+ return cChatColor.Green, 2
+ elseif string.sub( Split, char + 1, char + 1 ) == "3" then
+ return cChatColor.Blue, 3
+ elseif string.sub( Split, char + 1, char + 1 ) == "4" then
+ return cChatColor.Red, 4
+ elseif string.sub( Split, char + 1, char + 1 ) == "5" then
+ return cChatColor.Purple, 5
+ elseif string.sub( Split, char + 1, char + 1 ) == "6" then
+ return cChatColor.Gold, 6
+ elseif string.sub( Split, char + 1, char + 1 ) == "7" then
+ return cChatColor.LightGray, 7
+ elseif string.sub( Split, char + 1, char + 1 ) == "8" then
+ return cChatColor.Gray, 8
+ elseif string.sub( Split, char + 1, char + 1 ) == "9" then
+ return cChatColor.DarkPurple, 9
+ elseif string.sub( Split, char + 1, char + 1 ) == "a" then
+ return cChatColor.LightGreen, "a"
+ elseif string.sub( Split, char + 1, char + 1 ) == "b" then
+ return cChatColor.LightBlue, "b"
+ elseif string.sub( Split, char + 1, char + 1 ) == "c" then
+ return cChatColor.Rose, "c"
+ elseif string.sub( Split, char + 1, char + 1 ) == "d" then
+ return cChatColor.LightPurple, "d"
+ elseif string.sub( Split, char + 1, char + 1 ) == "e" then
+ return cChatColor.Yellow, "e"
+ elseif string.sub( Split, char + 1, char + 1 ) == "f" then
+ return cChatColor.White, "f"
+ else
+ return ""
+ end
end
\ No newline at end of file |