From b35368ad0a793fe5037a1094d7e4e082c77d598f Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 11 Aug 2013 08:33:24 -0700 Subject: Initial commit --- LICENSE | 20 ++++++++++++++++++++ README.md | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..102ed2a36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Alexander Harkness + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..476ecdcb6 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +transapi +======== + +A Translation API for MCServer -- cgit v1.2.3 From 0d97cd77fdee94f5bd5e2b89f645a84e62dc8da9 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 12 Aug 2013 21:15:53 +0100 Subject: Did some stuff. --- main.lua | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 main.lua diff --git a/main.lua b/main.lua new file mode 100644 index 000000000..e8d7d7990 --- /dev/null +++ b/main.lua @@ -0,0 +1,54 @@ +-- This plugin copyright Alexander Harkness 2013, licensed under the MIT license. + +-- Configuration +g_ServerLang = "english" +g_ConsoleLang = "english" + +-- Global Variables +g_Plugin = nil +g_PluginManager = nil +g_PluginDir = nil +g_UserData + +-- START WITH DA AWESOME! +function Initialize( Plugin ) + + -- Set up the globals. + g_Plugin = Plugin + g_PluginManager = cRoot:Get():GetPluginManager() + g_PluginDir = Plugin:GetDirectory() + + -- Set up the plugin details. + Plugin:SetName( "TransAPI" ) + Plugin:SetVersion( 1 ) + + -- This is the place for commands! + PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language.") + + -- Load the userdata file. + + + LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) + + return true + +end + +function GetLanguage( user ) + + -- Returns a language to use. + +end + +function GetConsoleLanguage() + -- Return the language to use for console messages. + return g_ConsoleLang +end + +function HandleLanguageCommand ( Split, Player ) + return true +end + +function OnDisable() + LOG( "Disabled TransAPI!" ) +end -- cgit v1.2.3 From ff7e4b5bb9e1c5c567043ad8479a054c0c085f5e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 09:39:42 +0100 Subject: Finished up the main plugin. --- main.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/main.lua b/main.lua index e8d7d7990..da1fdda7d 100644 --- a/main.lua +++ b/main.lua @@ -1,14 +1,14 @@ -- This plugin copyright Alexander Harkness 2013, licensed under the MIT license. -- Configuration -g_ServerLang = "english" -g_ConsoleLang = "english" +g_ServerLang = "english" +g_ConsoleLang = "english" -- Global Variables -g_Plugin = nil +g_Plugin = nil g_PluginManager = nil -g_PluginDir = nil -g_UserData +g_PluginDir = nil +g_UserData = nil -- START WITH DA AWESOME! function Initialize( Plugin ) @@ -23,10 +23,13 @@ function Initialize( Plugin ) Plugin:SetVersion( 1 ) -- This is the place for commands! - PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language.") + g_PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language.") -- Load the userdata file. - + g_UserData = cIniFile( g_PluginDir .. "/userdata.ini" ) + if g_UserData ~= true then + LOGERROR( "TransAPI INI file could not be opened!" ) + end LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) @@ -34,9 +37,19 @@ function Initialize( Plugin ) end -function GetLanguage( user ) +function GetLanguage( Player ) -- Returns a language to use. + if g_UserData:ReadFile() == true then + local userLang = g_UserData:GetValueSet( Player:GetName(), "language", "false" ) + g_UserData:WriteFile() + end + + if userLang == "false" then + return g_ServerLang + else + return userLang + end end @@ -46,7 +59,31 @@ function GetConsoleLanguage() end function HandleLanguageCommand ( Split, Player ) + + -- If the user is not setting the language, tell them the currently selected one. + if #Split ~= 2 then + + local userLang = g_UserData:GetValueSet( Player:GetName(), "language", "false" ) + if userLang == "false" then + return g_ServerLang + else + return userLang + end + + end + + -- Set the language. + local success = g_UserData:SetValue( Player:GetName(), "language" Split[2] ) + g_UserData:WriteFile() + + if not success then + Player:SendMessage( "Language could not be set!" ) + else + Player:SendMessage( "Language set!" ) + end + return true + end function OnDisable() -- cgit v1.2.3 From 40094c2620248c0f79df12e5860bf6eb26614f75 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 09:46:15 +0100 Subject: Changed system to use ISO 639-1. --- main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index da1fdda7d..2b6f77da6 100644 --- a/main.lua +++ b/main.lua @@ -1,8 +1,8 @@ -- This plugin copyright Alexander Harkness 2013, licensed under the MIT license. -- Configuration -g_ServerLang = "english" -g_ConsoleLang = "english" +g_ServerLang = "en" +g_ConsoleLang = "en" -- Global Variables g_Plugin = nil @@ -23,7 +23,7 @@ function Initialize( Plugin ) Plugin:SetVersion( 1 ) -- This is the place for commands! - g_PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language.") + g_PluginManager:BindCommand("/language", "transapi.setlang", HandleLanguageCommand, " - Set your preferred language (use ISO 639-1)") -- Load the userdata file. g_UserData = cIniFile( g_PluginDir .. "/userdata.ini" ) -- cgit v1.2.3 From ce761fa2b874d40c49a4aa44f3a2b751c725ae6e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 09:47:43 +0100 Subject: Made the README --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 476ecdcb6..855c4bd4b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,20 @@ -transapi +TransAPI ======== -A Translation API for MCServer +A plugin translation API for MCServer. + +TransAPI is designed to be used with the provided client library, however there is also a stable API available for use. + +API +--- + + GetLanguage ( cPlayer ) + Returns the user's preferred language (or server default if not set). (ISO 639-1 language code) + + GetConsoleLanguage ( ) + Returns the preferred language for console text. (ISO 639-1 language code) + +Commands +-------- + + * /language [lang] - Takes a language code (ISO 639-1) and sets the user's preferred language to that. (tranapi.setlang) -- cgit v1.2.3 From 52e1de4332a026e58fda843aae98c1f51e57199e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 09:50:15 +0100 Subject: Added link to future lib. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 855c4bd4b..b037a6732 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ TransAPI A plugin translation API for MCServer. -TransAPI is designed to be used with the provided client library, however there is also a stable API available for use. +TransAPI is designed to be used with the [client library](https://github.com/bearbin/transapi-client), however there is also a stable API available for use. API --- -- cgit v1.2.3 From c52e0e81ea1584e37359ff9e77b00c3e35045ced Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 17:55:46 +0100 Subject: Squashed commit of the following: commit 322b33d95a8486b22c3c259ce241976516a88a4b Merge: b3d6dc7 954b682 Author: Alexander Harkness Date: Tue Aug 13 09:54:51 2013 -0700 Merge pull request #24 from mc-server/sudo Added sudo and do. commit 954b682450503815a2a81e1ab51a190aeeb0bd8d Author: Alexander Harkness Date: Tue Aug 13 17:00:56 2013 +0100 Added sudo and do. commit b3d6dc73347c3ec9e49502a2250aff4ab664e870 Merge: 735f1da b39b144 Author: Alexander Harkness Date: Sun Aug 11 23:00:24 2013 -0700 Merge pull request #22 from mc-server/functions-squashing Squash helper functions around the source into just one file. commit 735f1dac5e0d5a9d98dd2e0b5833e01d925487a0 Author: Alexander Harkness Date: Sun Aug 11 19:42:42 2013 +0100 Re-added the downfall command. commit b39b144c6afc246647d46ed0ac1b66f9b46e2cd3 Author: Alexander Harkness Date: Sun Aug 11 19:01:05 2013 +0100 Dragged out TeleportToPlayer and dumped it in the new functions.lua. commit 5ea91abb6b9a85d91ba82d125b6897a2e743937e Author: Alexander Harkness Date: Sun Aug 11 19:00:01 2013 +0100 Dragged out the CheckHardcore function. commit dc00e218cdf55252e5e8d5984e4e63bf11457d5e Author: Alexander Harkness Date: Sun Aug 11 18:58:42 2013 +0100 Dragged yet more functions out. commit 1e95ca25d71770382074d5e379cbfea7288f6e0d Author: Alexander Harkness Date: Sun Aug 11 18:57:36 2013 +0100 Dragged some functions out of kick. commit 9168dee74d0b3c9f3c7a6fdb756798095ae444a4 Author: Alexander Harkness Date: Sun Aug 11 18:56:37 2013 +0100 Dragged the helper functions out of console.lua. commit 0f48daf02c0b823ae7fe0863d2a1292e53f0fa22 Author: Alexander Harkness Date: Sun Aug 11 18:54:40 2013 +0100 Dumped messages in the functions file, removed it's own special one. commit 9dc3f0d18af4a411f8a40b525e49e7598159f450 Author: Alexander Harkness Date: Sun Aug 11 15:46:05 2013 +0100 Alpha-sorted the command bindings. commit e22d2fcf3dd840b1a051f3b5b529040213c151c6 Merge: 3ff68e9 9e285ea Author: Alexander Harkness Date: Sun Aug 11 15:35:46 2013 +0100 Merge branch 'vanilla-commands' Conflicts: main.lua weather.lua commit 3ff68e9690ff365fd57343dd8d0609bdc6b6bb54 Author: Alexander Harkness Date: Sun Aug 11 15:22:33 2013 +0100 Cleaned up some files and also killed some demons that had survived the messaging update. commit 9e285ea6ceb3f2e279052fd10227a6dfeb48c062 Author: Tiger Wang Date: Sun Aug 11 15:09:28 2013 +0100 Fixed tabs and conforms to standards commit e092a35988074b7ebd58068c0b24a235a98596df Merge: f4038d2 c1c563b Author: Alexander Harkness Date: Sun Aug 11 15:06:35 2013 +0100 Merge branch 'message-standards' Conflicts: console.lua item.lua main.lua commit d68c84b8b74a54cc15965036d27ad0b1dde2d603 Author: Tiger Wang Date: Sun Aug 11 14:56:08 2013 +0100 Added /msg alias commit c1c563bda69d51cf5454c7584a25fa3968f0e3ad Author: Alexander Harkness Date: Sun Aug 11 14:55:56 2013 +0100 Cleaned up console a little and switched to new message system. Also fixed missing eof newline. commit dc6c5fafc32034321f6827b0c21e99212e2d559b Author: Alexander Harkness Date: Sun Aug 11 14:54:47 2013 +0100 Cleaned up web-perms and switched to new message system. Also added missing eof newline. commit f739fc83ace22cf1ee966ad5514bd3c708d08c20 Author: Tiger Wang Date: Sun Aug 11 14:54:10 2013 +0100 Remove command commit dc5ce476e871b425f79e510522e35db5608161d4 Author: Tiger Wang Date: Sun Aug 11 14:52:40 2013 +0100 Now conforms to chat standards commit 41e15803541f4a20ee5baf92106e2ba1cb40cbd7 Author: Alexander Harkness Date: Sun Aug 11 14:51:21 2013 +0100 Cleaned up weather and switched to new message system. Also added missing eof newline. commit d19caacaad67addaa30d1b6f48ec47c265b4832e Author: Alexander Harkness Date: Sun Aug 11 14:50:07 2013 +0100 Cleaned up viewdistance and switched to new messaging system. Also added missing eof newline. commit d6f6603773ae7beb87cb951988e7738ba9c1e538 Author: Alexander Harkness Date: Sun Aug 11 14:48:34 2013 +0100 Cleaned up top and changed to new messaging system. Also fixed missing eof newline. commit f50fb793a1332c1cc87b3c6e0dfa283f9dfc9e61 Author: Alexander Harkness Date: Sun Aug 11 14:47:28 2013 +0100 Cleaned up the time file and switched to new messaging system. commit aff076175ded4823da817547349537f3c33d4a43 Author: Tiger Wang Date: Sun Aug 11 14:43:38 2013 +0100 Now comforms to help standards commit 4c416d1d1944fa00d4bf07f2580b29b530545bb3 Author: tonibm19 Date: Sun Aug 11 14:09:29 2013 +0200 Added /tell [playername] [message] commit 56db86812bfa7c4482b563af71846616a1716434 Author: tonibm19 Date: Sun Aug 11 14:06:47 2013 +0200 Added /tell [playername] [message] commit 1b5f32e3b577474b0878dfe9211cafbdb00790bb Author: Alexander Harkness Date: Sun Aug 11 12:58:53 2013 +0100 Cleaned up teleport and switched to new message system. Also added missing eof newline. commit fb96b73831679735a9677d7f520d19d8276a15d6 Author: tonibm19 Date: Sun Aug 11 13:33:49 2013 +0200 Added /weather [Clear/Rain/Thunder] commit 1e4676965a3ce6dc79912e0c8686b7de5026eb42 Author: tonibm19 Date: Sun Aug 11 13:32:04 2013 +0200 Added /weather [Clear/Rain/Thunder] commit f4038d2f9d748df54af054661a18630219ebd25c Author: STRWarrior Date: Sun Aug 11 13:08:24 2013 +0200 changed /downfall to /toggledownfall becouse thats the way it is in vanilla. commit acdcefe61919e9ecbace1ee2f56dc24c94ffa4dc Author: tonibm19 Date: Sun Aug 11 13:02:35 2013 +0200 Fixed /tpa and /tpaccept commit 9f526a63f07497fa7542515aa17afce9adc34abb Author: tonibm19 Date: Sun Aug 11 12:59:22 2013 +0200 Updated README (new commands added) commit 717239095c638d86859f1b1b449e6bea0d093f02 Author: Alexander Harkness Date: Sun Aug 11 11:37:11 2013 +0100 Cleaned up spawn.lua and changed to new message system. Also fixed missing eof newline. commit 2a6a693efcffa1145270bc79ce403e5038a88308 Author: Alexander Harkness Date: Sun Aug 11 11:35:58 2013 +0100 Cleaned up the save-reload-stop file. Also fixed missing eof newline. commit d32223e4361509a598ee528261b113d92f402e7e Author: Alexander Harkness Date: Sun Aug 11 11:35:08 2013 +0100 Cleaned up the regen file and changed to the new message system. Also fixed missing eof newline. commit 7635e0cd1be051d60bbb6127f04b5b9b8decf51f Author: Alexander Harkness Date: Sun Aug 11 11:30:47 2013 +0100 Cleaned up rank-groups.lua and changed to new message system. Also fixed missing eof newline. commit 204e38aa33541794745a671092a3b5b37388f6d2 Merge: 42e95a6 a319162 Author: Alexander Harkness Date: Sun Aug 11 00:54:49 2013 -0700 Merge pull request #19 from mc-server/vanilla-commands Added /kill and /clear commit a31916277fcef2925fc96ce6833dac1ab7c62905 Author: tonibm19 Date: Sat Aug 10 23:11:21 2013 +0200 You die if you dont specify a player commit 0aca0d8431cc69f841a3e3f3a0ada81c1d8b1fbb Author: Alexander Harkness Date: Sat Aug 10 21:05:03 2013 +0100 Cleaned up the portal and worlds file and added new message system. Also fixed missing eof newline. commit 9f4a1fe0ef18a3ee48ea5629969854e5a60616a0 Author: Alexander Harkness Date: Sat Aug 10 21:01:23 2013 +0100 Cleaned up plugins file and added new message system. also fixed missing eof newline. commit 9f04dfef81e8705597aac8fbc8912e3c3b9be6e8 Author: tonibm19 Date: Sat Aug 10 21:23:41 2013 +0200 fixed /clear commit 13e9007844f15050ad4ecea79246d31426975898 Author: Alexander Harkness Date: Sat Aug 10 20:17:06 2013 +0100 Cleaned up the motd file. commit 6c8de9b3594221fbb092d9989166826754641eda Author: tonibm19 Date: Sat Aug 10 21:13:42 2013 +0200 Added /clear command commit 97fe00aac1bf7d497e08a9622bb32786d64b4c0b Author: tonibm19 Date: Sat Aug 10 21:11:31 2013 +0200 Added /clear command commit 8dec3c04acb9814db1c89cba2094494fd321e40a Author: Alexander Harkness Date: Sat Aug 10 20:11:26 2013 +0100 Cleaned up the me file and changed to new message system. commit 72c401fe65589adce446e7de59b3c47ac2147fc9 Author: Alexander Harkness Date: Sat Aug 10 20:09:26 2013 +0100 Cleaned up the main file, and changed to the new message system. commit c48604becd8da56590c9374a641a665d1d6dedab Author: tonibm19 Date: Sat Aug 10 21:05:24 2013 +0200 Added /kill commit 41b90ad60fc944aa307447491e511879e64f108a Author: tonibm19 Date: Sat Aug 10 21:03:47 2013 +0200 added /kill commit b2ffcfb1ea36758b013e1ea85c2515485ed30543 Author: Alexander Harkness Date: Sat Aug 10 19:57:50 2013 +0100 Added new messaging system to locate.lua. Also added the eof newline. commit 318e4dc85eb10d7d97279a19f2d21f3ec75c4598 Author: Alexander Harkness Date: Sat Aug 10 19:53:51 2013 +0100 Cleaned up the kick command and added new message system. Also fixed missing eof newline. commit 3d864b47a826911181604f83ea72ca0416ff25ce Author: Alexander Harkness Date: Sat Aug 10 19:49:56 2013 +0100 Cleaned the /i a bit more. commit 7c26e76048885e2cbc7bc5b57d6ba38b7475e2a5 Author: Alexander Harkness Date: Sat Aug 10 19:48:19 2013 +0100 Changed to the new message system for /i. Also fixed eof newline. commit 1bc7f1844942a4a675c125b06c81b418b009c037 Author: Alexander Harkness Date: Sat Aug 10 18:37:35 2013 +0100 Cleaned up help massively and implemented the new messages. Also added new eof newline. commit 150c88ccfe2d6e5210f95c31e56f824832a0c98c Author: Alexander Harkness Date: Sat Aug 10 18:36:14 2013 +0100 Added spaces after the tag for the messages so the results look good. commit a144b535cd51805ef8badfc6645aa654370913ed Author: Alexander Harkness Date: Sat Aug 10 18:30:21 2013 +0100 Added new messages to gm.lua. Also added spaces in functions and added a eof newline. commit 2237f62c1c6e40d7b2a2986916b2a6e1879f6bfd Author: Alexander Harkness Date: Sat Aug 10 18:23:29 2013 +0100 Removed a semicolon that was creeping around in the messages file. commit fbe68a2c28f0b7d54d8527b54a737218bc9a6da4 Author: Alexander Harkness Date: Sat Aug 10 18:22:48 2013 +0100 Fixed derpy spelling and added new messages to the give command. Also cleaned up the functions in the give command file. commit 66b33c0436d084a2fed1248d63f074c768545ad0 Author: Alexander Harkness Date: Sat Aug 10 18:04:55 2013 +0100 Added new messages to the ban and unban command. Also cleaned up the function calls and added the eof newline. commit c90dda25990de8ab6d529e83c9620d9bc8c9b9f1 Author: Alexander Harkness Date: Sat Aug 10 17:56:43 2013 +0100 Added new messages to /back command. Also fixed newline at end of file. commit 42e95a6d32da7227a84a5202a2e72fcf4007aaf2 Author: Tiger Wang Date: Sat Aug 10 17:04:36 2013 +0100 Fix concatenation issue commit 7432c25306b8125fca13100048b693bebad92d3d Author: Tiger Wang Date: Sat Aug 10 16:44:47 2013 +0100 Fix of bracket commit 4e0b3f905e2f937951eebd322b204f8da3e745cd Author: Alexander Harkness Date: Sat Aug 10 16:38:53 2013 +0100 Fixed bugs in the console command file that were stopping it from working. There was an extra `end` and an extra `)` commit ea1215da739e65585b448103e0bf1bebec00dfac Author: Tiger Wang Date: Sat Aug 10 16:06:30 2013 +0100 Fixed duplicate leave messages commit b6ecb378ca6f213b4676ca17efcb5baa64f2f132 Merge: b273df1 1a6f70f Author: Alexander Harkness Date: Sat Aug 10 06:05:32 2013 -0700 Merge pull request #13 from mc-server/give-console Added a console command for giving players items. commit b273df17c759eba82342466cf6e2291d84b77ab3 Author: Alexander Harkness Date: Sat Aug 10 08:27:14 2013 +0100 Hopefully fixed the /i command not working. I had not defined the newSplit variable before using it. commit 8a74037cc092d048364299f18e07c02c85ae3737 Author: Alexander Harkness Date: Thu Aug 8 10:18:48 2013 +0100 Fixed the contributors not being on their own lines. commit 57d842cbc61464a613c248d043a3fe7254d931a2 Author: Alexander Harkness Date: Thu Aug 8 10:17:03 2013 +0100 Added temporary messages.lua, seeing if people like it. commit 0f61781047fbe3a4986dde3079be4fc1fb9ff14d Author: Alexander Harkness Date: Wed Aug 7 18:26:12 2013 +0100 Fix the README - fixes #15 commit cc438b3229cdb730d308479c59491b5e66130118 Author: Alexander Harkness Date: Wed Aug 7 18:01:48 2013 +0100 Alpha-sort the console commands. commit aa22f647c27d50b3ccf7e763927bd24329da3a56 Author: Alexander Harkness Date: Wed Aug 7 18:00:44 2013 +0100 Alpha-sort the commands when they are bound. commit 5d9367fcdeeb8a5e1485aac539147edb7a0cd0ab Merge: a485101 01ccfaa Author: Alexander Harkness Date: Wed Aug 7 09:41:38 2013 -0700 Merge pull request #14 from mc-server/ireplace Told the player receiving items what they are getting, and fixed the console log. commit 01ccfaa340afa8a4b909a923702da48b8b5f0d4a Author: Alexander Harkness Date: Wed Aug 7 17:39:36 2013 +0100 Told the player reveiving items what they are getting, and fixed the console log. commit 1a6f70f25ffa4c12a0d738c97435ae2c30cdb6a9 Author: Alexander Harkness Date: Wed Aug 7 17:35:48 2013 +0100 Added a console command for giving players items. commit a4851010b2ff29bb55feb6331ea6ddec28532a0f Merge: 0ffbd4a ba923e4 Author: Alexander Harkness Date: Wed Aug 7 09:01:47 2013 -0700 Merge pull request #12 from mc-server/ireplace Re-implement the /i command and make /give conform to the vanilla standards commit ba923e4764b6a3064be6aacea86e059828b2d0e6 Author: Alexander Harkness Date: Wed Aug 7 16:59:53 2013 +0100 Added /item and made /i an alias of it. commit 25652d2d5390d46a9cfe8bc80ab702b831bb49ed Author: Alexander Harkness Date: Wed Aug 7 16:46:14 2013 +0100 Kept the stuff alpha-sorted. commit 7fc56322420c0f99c1d0f0e6ba5df6169ef57fcc Author: Alexander Harkness Date: Wed Aug 7 16:45:09 2013 +0100 Removed some extra semicolons. commit 06b1adbcde3d4d610f9d3646ac3dd912b4071ea7 Author: Alexander Harkness Date: Wed Aug 7 16:44:06 2013 +0100 Cleaned up the code a little and fixed the messed up stuff that tried to make sure a player was good. commit 0ffbd4adb80edf51cf7eb5117b0287c7ed286add Author: tonibm19 Date: Wed Aug 7 13:52:02 2013 +0200 Fixed typo commit b9503b977bdfeed8795fcacd8c6d15bc2e6a723a Author: Alexander Harkness Date: Tue Aug 6 18:23:51 2013 +0100 Re-implement the /i command and make /give conform to the vanilla standards. This commit is experimental and may fail. Please test it! commit f4ac029a0f1903fc9e49365117a81293303c8811 Author: Tiger Wang Date: Fri Aug 2 23:23:15 2013 +0100 Miscellaneous Changes Reduced ban/unban code size a little. Clarified console commands. Added commented code to onjoin when bugs are fixed. Removed embarrassing server wide messages. commit da84f4977522ab48ead4af7a71efd43cdd4e3d0a Merge: cc77056 a631484 Author: bearbin Date: Thu Aug 1 10:58:05 2013 -0700 Merge pull request #10 from mc-server/tabmix Fix the inconsistency of spaces and tabs. commit a6314849c2b474b6e17a245c91a2ac74c7acf7bf Author: Alexander Harkness Date: Thu Aug 1 16:47:15 2013 +0100 Changed everything to use the correct system of tabs. commit cc7705645b6b387c618c9448fa6b0d5c789370c6 Author: Tiger Wang Date: Wed Jul 31 16:56:41 2013 +0100 Rewrote Info Messages + Implemented #7 [SEE DESC] Standardisation of info messages: [INFO] [WARNING] [JOIN] [LEAVE] [FATALITY] with colours Green, Gold, Red, Rose, and Yellow. Individual worlds have individual LimitWorld setting, with individual WebAdmin setting as well. commit 16cae4cdc0ec067e7e71fa5c5a3ba8c248ce063b Author: Tiger Wang Date: Mon Jul 29 14:47:45 2013 +0100 Fix of nil value in SpawnProtect commit 7c33f75e7da7fc104112c17fcb53bc9f06fe09fc Author: Tiger Wang Date: Mon Jul 29 13:19:11 2013 +0100 Fixed potential SpawnProtect nil value issue Now detects if PROTECTRADIUS is zero, and if so, cancels checks. commit 0c4a9d427620ab04ca01b5f31ed9b90530353d96 Author: Tiger Wang Date: Mon Jul 29 13:07:50 2013 +0100 Enhanced SpawnProtect greatly (thanks xoft) Wow. Who knew ~30 lines of code could become one? commit 17f5ef4fed0b6f32900cc7473563848466139655 Author: Tiger Wang Date: Mon Jul 29 11:11:22 2013 +0100 Removed Development LOGINFOs commit 02034bf2d67f2ae62092b0688d81338f7b0788df Author: Tiger Wang Date: Mon Jul 29 10:40:57 2013 +0100 Implemented Issue #5 Enhancement [SEE DESC] Made spawn protection configurable in each world's world file. World has to be listed in settings.ini! commit ccc73db8c51e45372069ec0a42f437cfb25253b1 Merge: 6bf4b40 21c7c68 Author: Alexander Harkness Date: Sun Jul 28 14:00:15 2013 +0100 Merge branch 'master' of github.com:tigerw/MCSCore into tigerw-master Conflicts: main.lua commit 21c7c68d20782a7dfd0d8f9ce0996397549dd425 Author: Tiger Wang Date: Sun Jul 28 12:55:50 2013 +0100 Default WorldLimiter = Off commit 141298481f3adef30b68d0c4200204aa264cb3e2 Author: Tiger Wang Date: Sun Jul 28 12:47:24 2013 +0100 Fixed Potential WorldLimit & OnDisable Bugs Changed WorldLimiter if detection from nil value to config boolean. Changed OnDisable to use hardcoded name as Plugin:GetName was apparently a nil value. ?? commit 6bf4b40a0e27677afa6df9cb3521266e6b99c4f7 Merge: 1ca4217 bfd6c5f Author: bearbin Date: Sat Jul 27 11:44:18 2013 -0700 Merge pull request #3 from tonibm19/master Added /me command commit bfd6c5f2a47cda4ac98a7225736e2669eaf61849 Author: tonibm19 Date: Sat Jul 27 20:35:22 2013 +0200 Added /me command commit d25abaf44a6f5828b90297ff80003d2cd2a90be5 Author: tonibm19 Date: Sat Jul 27 20:30:31 2013 +0200 Added /me command commit 9047f7778aa1cdd42d22c4dcf925db792b4d684e Author: tonibm19 Date: Sat Jul 27 20:29:24 2013 +0200 added /me command commit 1ca42172391d41ba71c65a3f15d3a96d15a80496 Merge: 52a6f4e 7a40336 Author: Tiger Wang Date: Sat Jul 27 09:01:45 2013 -0700 Merge pull request #2 from tigerw/master Fixed /give descriptor & removed webadmin commit 7a40336437525c447adae3d9800e75b39c0300c4 Author: Tiger Wang Date: Sat Jul 27 17:00:38 2013 +0100 Fixed /give descriptor & removed webadmin commit 52a6f4e35bdea2ae9f33977928b6693f5800e515 Merge: f5d56ff 2af1da8 Author: Tiger Wang Date: Sat Jul 27 08:51:45 2013 -0700 Merge pull request #1 from tigerw/master Added TPA (tonibm9's fork) commit 2af1da8a3cd8e94674b22805662b83de87ac4a95 Author: Tiger Wang Date: Sat Jul 27 16:38:10 2013 +0100 Added TPA (tonibm9's fork) With code from STR_Warrior. commit f5d56ffeb02fef4735e846661fa71d15622d25b9 Author: Tiger Wang Date: Sat Jul 27 15:51:18 2013 +0100 Integrated SpawnProtect & Bugfixes [SEE DESC.] Integrated bearbin's SpawnProtect. Fixed config file bugs. Improved SpawnProtect to use settings.ini. Variable cleanup (SHOW_PLUGIN_NAMES). File and filename cleanup. commit 56dc51c00af4514253c04e38b5ccc9fbed2f0022 Author: Tiger Wang Date: Fri Jul 26 23:14:40 2013 +0100 Update README.md Added info. commit acd7e2849dcd7f3ee7bdc6b0f9b777ee1d9cbb3c Author: Tiger Wang Date: Fri Jul 26 19:37:59 2013 +0100 Implemented Block Property checking for Collisions Used g_BlockIsSolid, instead of checking data values. commit 246d423ff9660a2b00a1c51e6276ec74eb3419de Author: Tiger Wang Date: Fri Jul 26 15:49:55 2013 +0100 Updated Files Buildpermandcollision: updated collision code to check for torches and redstone torches. Help: attempt at always showing page number Web_serversettings: attempt at introducing a check for Maximum Players (must be above zero). commit 868f99ab49edeee78f4fc1c212c6bf614b860378 Author: Tiger Wang Date: Thu Jul 25 19:46:08 2013 +0100 Update README.md Extended 'GUI Redesign' section. commit e0df40bd082bdeb5c6823b485bc5001103a77502 Author: Tiger Wang Date: Thu Jul 25 19:43:00 2013 +0100 Update README.md Added features and fixes and instructions for use. commit 332d8221f753f1a38d6c21bfc30af5890f48e3bb Author: Tiger Wang Date: Thu Jul 25 19:35:27 2013 +0100 Uploaded All Files All Core files, both modified and unmodified. commit 3dd191f6bed71c863ee264856fbc3660e52cf88b Author: Tiger Wang Date: Thu Jul 25 04:59:50 2013 -0700 Initial commit --- MCServer/Plugins/Core/console.lua | 24 ------ MCServer/Plugins/Core/do.lua | 29 +++++++ MCServer/Plugins/Core/functions.lua | 161 +++++++++++++++++++++++++++++++++++- MCServer/Plugins/Core/kick.lua | 27 ------ MCServer/Plugins/Core/main.lua | 7 ++ MCServer/Plugins/Core/messages.lua | 27 ------ MCServer/Plugins/Core/motd.lua | 50 ----------- MCServer/Plugins/Core/ondeath.lua | 11 +-- MCServer/Plugins/Core/teleport.lua | 26 ------ 9 files changed, 197 insertions(+), 165 deletions(-) create mode 100644 MCServer/Plugins/Core/do.lua delete mode 100644 MCServer/Plugins/Core/messages.lua 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 [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 [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 -- cgit v1.2.3 From 3e5b74fa026d931220af5568bfe4080b46ae8c73 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 18:35:31 +0100 Subject: Added TransAPI as a default plugin. --- MCServer/settings.example.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/MCServer/settings.example.ini b/MCServer/settings.example.ini index e2505368d..3daeb00f1 100644 --- a/MCServer/settings.example.ini +++ b/MCServer/settings.example.ini @@ -18,6 +18,7 @@ DefaultWorld=world Plugin=Core Plugin=ChunkWorx Plugin=ChatLog +Plugin=TransAPI [Monsters] AnimalsOn=0 -- cgit v1.2.3 From 765bbe739e996e8c310467f5b9ca05dd8d3b54de Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 13 Aug 2013 20:02:38 +0100 Subject: Added the transapi permission because yay! --- MCServer/groups.example.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MCServer/groups.example.ini b/MCServer/groups.example.ini index 87b28b70d..f1a8df7d7 100644 --- a/MCServer/groups.example.ini +++ b/MCServer/groups.example.ini @@ -13,5 +13,5 @@ Color=2 Inherits=Default [Default] -Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn -Color=7 \ No newline at end of file +Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn,transapi.setlang +Color=7 -- cgit v1.2.3 From 87fdeae583d3aac70ffd69f92aafd52b2b001e0e Mon Sep 17 00:00:00 2001 From: tonibm19 Date: Tue, 13 Aug 2013 21:40:31 +0200 Subject: Fixed new crafting recipes. I forgot to change items.ini in my latest merged PR, sorry for that --- MCServer/items.ini | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MCServer/items.ini b/MCServer/items.ini index c9bd6df53..c4e2466d8 100644 --- a/MCServer/items.ini +++ b/MCServer/items.ini @@ -281,7 +281,8 @@ pillarquartzblock=155:2 quartzstairs=156 activatorrail=157 dropper=158 - +haybale=170 +carpet=171 ironshovel=256 ironspade=256 ironpickaxe=257 @@ -294,6 +295,7 @@ redapple=260 bow=261 arrow=262 coal=263 +coalblock=173 charcoal=263:1 diamond=264 ironingot=265 @@ -528,6 +530,7 @@ netherbrickitem=405 netherquartz=406 tntminecart=407 hopperminecart=408 +lead=420 goldrecord=2256 greenrecord=2257 @@ -541,3 +544,6 @@ stradrecord=2264 wardrecord=2265 11record=2266 + + + -- cgit v1.2.3 From fcb558a427463afdae883ab14dcfd0a949cc5184 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 13 Aug 2013 22:47:42 +0200 Subject: Added ConsoleColors test for testing out linux console color codes. --- Tests/ConsoleColors/ConsoleColors.cpp | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Tests/ConsoleColors/ConsoleColors.cpp diff --git a/Tests/ConsoleColors/ConsoleColors.cpp b/Tests/ConsoleColors/ConsoleColors.cpp new file mode 100644 index 000000000..7efc698b2 --- /dev/null +++ b/Tests/ConsoleColors/ConsoleColors.cpp @@ -0,0 +1,62 @@ + +// ConsoleColors.cpp + +// Tests the various console color combinations + +#include +#include + + + + + +/// Evaluates to the number of elements in an array (compile-time!) +#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X))) + + + + + +int main(void) +{ + static const char * Attribs[] = + { + "0", // All attribs off + "1", // bold + "2", // faint + "7", // inverse + "1;7", // bold inverse + "2;7", // faint inverse + } ; + for (int i = 0; i < ARRAYCOUNT(Attribs); i++) + { + const char * Attrib = Attribs[i]; + for (int fg = 30; fg <= 37; fg++) + { + for (int bg = 40; bg <= 47; bg++) + { + printf("\x1b[%s;%d;%dm %s;%d;%d ", Attrib, fg, bg, Attrib, fg, bg); + } // for bg + puts("\x1b[0m"); // Reset terminal back to normal colors for the newline + } // for fg + } // for i - Attribs[] + + for (int i = 1; i < ARRAYCOUNT(Attribs); i++) + { + const char * Attrib = Attribs[i]; + for (int fg = 30; fg <= 37; fg++) + { + for (int bg = 40; bg <= 47; bg++) + { + printf("\x1b[%d;%d;%sm %d;%d;%s ", fg, bg, Attrib, fg, bg, Attrib); + } // for bg + puts("\x1b[0m"); // Reset terminal back to normal colors for the newline + } // for fg + } // for i - Attribs[] + + return 0; +} + + + + -- cgit v1.2.3 From c0629a9a6e84b705398ae0ea04de85ef3838a773 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 14 Aug 2013 10:33:26 +0200 Subject: Fixed player swimstate crash. The check for swimming / submersion checks the Y coord first. Fixes #63. --- source/Player.cpp | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/source/Player.cpp b/source/Player.cpp index d9dbf8406..18c4744bb 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -1322,7 +1322,7 @@ cPlayer::StringList cPlayer::GetResolvedPermissions() -void cPlayer::UseEquippedItem() +void cPlayer::UseEquippedItem(void) { if (GetGameMode() == gmCreative) // No damage in creative { @@ -1332,29 +1332,39 @@ void cPlayer::UseEquippedItem() GetInventory().DamageEquippedItem(); } + + + + void cPlayer::SetSwimState(cChunk & a_Chunk) { - + int RelY = (int)floor(m_LastPosY + 0.1); + if ((RelY < 0) || (RelY >= cChunkDef::Height)) + { + m_IsSwimming = false; + m_IsSubmerged = false; + return; + } + BLOCKTYPE BlockIn; int RelX = (int)floor(m_LastPosX) - a_Chunk.GetPosX() * cChunkDef::Width; - int RelY = (int)floor(m_LastPosY + 0.1); int RelZ = (int)floor(m_LastPosZ) - a_Chunk.GetPosZ() * cChunkDef::Width; - // first we check if the player is swimming - + // Check if the player is swimming: // Use Unbounded, because we're being called *after* processing super::Tick(), which could have changed our chunk VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockIn)); - m_IsSwimming = IsBlockWater(BlockIn); - // now we check if the player is submerged - - VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY+1, RelZ, BlockIn)); - + // Check if the player is submerged: + VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY + 1, RelZ, BlockIn)); m_IsSubmerged = IsBlockWater(BlockIn); } -void cPlayer::HandleAir() + + + + +void cPlayer::HandleAir(void) { // Ref.: http://www.minecraftwiki.net/wiki/Chunk_format // see if the player is /submerged/ water (block above is water) @@ -1363,22 +1373,28 @@ void cPlayer::HandleAir() if (IsSubmerged()) { // either reduce air level or damage player - if(m_AirLevel < 1) + if (m_AirLevel < 1) { - if(m_AirTickTimer < 1) + if (m_AirTickTimer < 1) { // damage player TakeDamage(dtDrowning, NULL, 1, 1, 0); // reset timer m_AirTickTimer = DROWNING_TICKS; - }else{ + } + else + { m_AirTickTimer -= 1; } - }else{ + } + else + { // reduce air supply m_AirLevel -= 1; } - }else{ + } + else + { // set the air back to maximum m_AirLevel = MAX_AIR_LEVEL; m_AirTickTimer = DROWNING_TICKS; @@ -1386,6 +1402,9 @@ void cPlayer::HandleAir() } + + + void cPlayer::HandleFood(void) { // Ref.: http://www.minecraftwiki.net/wiki/Hunger -- cgit v1.2.3 From 386d8190e9acf161185b60c16fed36134c18d215 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 14 Aug 2013 09:48:16 +0100 Subject: Added basic contributing file, fixes #86. --- CONTRIBUTING | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CONTRIBUTING diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 000000000..b4c87b67d --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,11 @@ +Code Stuff +---------- + + * No magic numbers, use named constants like E_ITEM... + +Copyright +--------- + +Your work should be licensed under the apache license, and you should add yourself to the CONTRIBUTORS file. + +If your work is not licensed under the apache license, then it must be compatible and marked as such.s -- cgit v1.2.3 From ade261255cb209da4ea5c4620c2a4a8cda45d2b8 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 14 Aug 2013 10:26:30 +0100 Subject: Added tabs/spaces stuff. --- CONTRIBUTING | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING b/CONTRIBUTING index b4c87b67d..734f40ddc 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -1,7 +1,8 @@ Code Stuff ---------- - * No magic numbers, use named constants like E_ITEM... + * No magic numbers, use named constants like E_ITEM... + * Please use tabs for indentation and spaces for alignment. Copyright --------- -- cgit v1.2.3 From 959f875bba958917fd47c06175d084c195b6e377 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 14 Aug 2013 10:29:43 +0100 Subject: Moved the file as it was markdown. --- CONTRIBUTING | 12 ------------ CONTRIBUTING.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 CONTRIBUTING create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING b/CONTRIBUTING deleted file mode 100644 index 734f40ddc..000000000 --- a/CONTRIBUTING +++ /dev/null @@ -1,12 +0,0 @@ -Code Stuff ----------- - - * No magic numbers, use named constants like E_ITEM... - * Please use tabs for indentation and spaces for alignment. - -Copyright ---------- - -Your work should be licensed under the apache license, and you should add yourself to the CONTRIBUTORS file. - -If your work is not licensed under the apache license, then it must be compatible and marked as such.s diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..734f40ddc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +Code Stuff +---------- + + * No magic numbers, use named constants like E_ITEM... + * Please use tabs for indentation and spaces for alignment. + +Copyright +--------- + +Your work should be licensed under the apache license, and you should add yourself to the CONTRIBUTORS file. + +If your work is not licensed under the apache license, then it must be compatible and marked as such.s -- cgit v1.2.3 From d211cc91c4d05b26126ab01b1f50950a9171c036 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 14 Aug 2013 10:30:54 +0100 Subject: Removed 's' at the end of CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 734f40ddc..fe7ad5313 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,4 +9,4 @@ Copyright Your work should be licensed under the apache license, and you should add yourself to the CONTRIBUTORS file. -If your work is not licensed under the apache license, then it must be compatible and marked as such.s +If your work is not licensed under the apache license, then it must be compatible and marked as such. -- cgit v1.2.3 From 64345fe2884cd10b511385283b453332d95a2b80 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 14 Aug 2013 12:16:05 +0200 Subject: Added some old contributors. --- CONTRIBUTORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ebb5f37ed..23d5045fa 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -7,5 +7,8 @@ STR_Warrior mgueydan tigerw bearbin +Lapayo +rs2k +Duralex If you feel you have contributed enough to be included in this list, just put in a PR including yourself. -- cgit v1.2.3 From b1a892bd9a5e9c2807580b55cb322aa026f80149 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 14 Aug 2013 12:45:39 +0200 Subject: Partially fixed tonibm19's mess. --- source/Piston.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/source/Piston.cpp b/source/Piston.cpp index 161f2b38c..91b1aaa93 100644 --- a/source/Piston.cpp +++ b/source/Piston.cpp @@ -12,18 +12,16 @@ #include "Server.h" #include "Blocks/BlockHandler.h" -#ifdef _WIN32 -#include -#else -#include -#endif -//Athar from http://www.cplusplus.com/forum/unices/60161/ helped with the sleep code. extern bool g_BlockPistonBreakable[]; + + + + #define AddDir( x, y, z, dir, amount ) \ switch (dir) \ { \ @@ -128,11 +126,11 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) AddDir(extx, exty, extz, pistonMeta & 7, 1) - #ifdef _WIN32 - Sleep(100); - #else - usleep(static_cast(100)*1000); - #endif + // TODO: This code needs replacing + // Sleeping here will play the piston animation on the client; however, it will block the entire server + // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad + // This needs to be handled using delayed scheduled tasks instead + cSleep::MilliSleep(100); m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta & 7); } @@ -178,22 +176,23 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) // These cannot be moved by the sticky piston, bail out return; } - #ifdef _WIN32 - Sleep(100); - #else - usleep(static_cast(100)*1000); - #endif + + // TODO: This code needs replacing + // Sleeping here will play the piston animation on the client; however, it will block the entire server + // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad + // This needs to be handled using delayed scheduled tasks instead + cSleep::MilliSleep(100); m_World->SetBlock(pistx, pisty, pistz, tempblock, tempmeta); m_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0); } else { - #ifdef _WIN32 - Sleep(100); - #else - usleep(static_cast(100)*1000); - #endif + // TODO: This code needs replacing + // Sleeping here will play the piston animation on the client; however, it will block the entire server + // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad + // This needs to be handled using delayed scheduled tasks instead + cSleep::MilliSleep(100); m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0); } -- cgit v1.2.3