diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:54:25 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:54:25 +0200 |
commit | 7d28f8bbff2dedcf63466618372ecf3d8d05bbc3 (patch) | |
tree | 8e361cc8dac17fbe13a48a027111e9e187930fe0 | |
parent | Added correct core plugin (diff) | |
download | cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.gz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.bz2 cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.lz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.xz cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.tar.zst cuberite-7d28f8bbff2dedcf63466618372ecf3d8d05bbc3.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/Core/main.lua | 62 | ||||
-rw-r--r-- | MCServer/Plugins/Core/teleport.lua | 42 |
2 files changed, 78 insertions, 26 deletions
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua index b4d03ce9d..eeceb034b 100644 --- a/MCServer/Plugins/Core/main.lua +++ b/MCServer/Plugins/Core/main.lua @@ -1,5 +1,5 @@ --- Global variables -PLUGIN = {} -- Reference to own plugin object +--COMMENCE VARIABLES +PLUGIN = {} BannedPlayersIni = {} WhiteListIni = {} BackCoords = {} @@ -8,13 +8,16 @@ LimitWorldsCuboid = {} SPAWNPROTECT = true PROTECTRADIUS = 20 LOGTOFILE = false +--END VARIABLES +--COMMENCE AWESOMENESS! function Initialize(Plugin) PLUGIN = Plugin Plugin:SetName("Core") Plugin:SetVersion(13) + --ADD HOOKS PluginManager = cRoot:Get():GetPluginManager() PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED) PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK) @@ -26,37 +29,41 @@ function Initialize(Plugin) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING) PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING) - PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds"); - PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups"); - PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather"); - PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position"); - PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds"); - PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands"); - PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group"); - PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins"); - PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " ~ Teleport yourself to a player"); + --PLEASE ALPHA SORT http://elmosaukko.com/sort-alphabetically/ THIS LIST + --BIND COMMANDS + PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position"); + PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player"); PluginManager:BindCommand("/give", "core.give", HandleGiveCommand, " ~ Give yourself an item"); + PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode"); + PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands"); + PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player"); PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); - PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); - PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups"); + PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates"); PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day"); + PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins"); + PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world"); + PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group"); + PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified"); PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins"); + PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds"); + PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn"); PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server"); PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " ~ Sets the time of day"); - PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn"); - PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player"); - PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player"); - PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player"); + PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather"); PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block"); - PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode"); - PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world"); - PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates"); - PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified"); + PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " ~ Teleport yourself to a player"); + PluginManager:BindCommand("/tpa", "core.teleport", HandleTPACommand, " ~ Ask to teleport yourself to a player"); + PluginManager:BindCommand("/tpaccept", "core.teleport", HandleTPAcceptCommand, " ~ Accept a teleportation request"); + PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player"); PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance") + PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds"); InitConsoleCommands(); - -- Load the settings + --LOAD SETTINGS IniFile = cIniFile("settings.ini") if ( IniFile:ReadFile() == true ) then HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false") @@ -78,7 +85,7 @@ function Initialize(Plugin) end ) end - -- Load whitelist, and add default values and stuff + --LOAD WHITELIST WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" ) if ( WhiteListIni:ReadFile() == true ) then if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then @@ -98,7 +105,7 @@ function Initialize(Plugin) end end - -- Load banned players, and add default values and stuff + --LOAD BANNED (BAD LUCK, BRO) BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" ) if ( BannedPlayersIni:ReadFile() == true ) then if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then @@ -113,6 +120,7 @@ function Initialize(Plugin) end end + --ADD WEB INTERFACE TABULATES (CURRENTLY DEPRECATED DUE TO LIST FORMAT BREAKING CSS) Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer); Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings); Plugin:AddWebTab("Chat", HandleRequest_Chat); @@ -126,7 +134,9 @@ function Initialize(Plugin) return true end +--AWESOMENESS STILL GOING! +--BEGIN SPAWNPROTECT LOGFILE CODE (COURTSEY OF BEARBIN) function WriteLog(breakPlace, X, Y, Z, player, id, meta) PLUGIN = Plugin @@ -143,7 +153,6 @@ function WriteLog(breakPlace, X, Y, Z, player, id, meta) table.insert(logText, ItemToString(cItem(id, 1, meta))) - table.insert(logText, " at ") table.insert(logText, tostring(X)) table.insert(logText, ", ") @@ -170,4 +179,5 @@ end function OnDisable() LOG( "Disabled " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) -end
\ No newline at end of file +end +--END AWESOMENESS :'(
\ No newline at end of file diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua index 4d3d98fee..89352408a 100644 --- a/MCServer/Plugins/Core/teleport.lua +++ b/MCServer/Plugins/Core/teleport.lua @@ -15,6 +15,48 @@ function HandleTPCommand(a_Split, a_Player) end end +function HandleTPACommand( Split, Player ) + if Split[2] == nil then + Player:SendMessage( cChatColor.Green .. "Usage: /tpa [Player]" ) + return true + end + local loopPlayer = function( OtherPlayer ) + if OtherPlayer:GetName() == Split[2] then + OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName() .. " send a teleport request" ) + Player:SendMessage( cChatColor.Green .. "You send a teleport request to " .. OtherPlayer:GetName() ) + Destination[OtherPlayer:GetName()] = Player:GetName() + end + end + local loopWorlds = function( World ) + World:ForEachPlayer( loopPlayer ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + return true +end + +function HandleTPAcceptCommand( Split, Player ) + if Destination[Player:GetName()] == nil then + Player:SendMessage( cChatColor.Green .. "Nobody has send you a teleport request" ) + return true + end + local loopPlayer = function( OtherPlayer ) + if Destination[Player:GetName()] == OtherPlayer:GetName() then + if OtherPlayer:GetWorld():GetName() ~= Player:GetWorld():GetName() then + OtherPlayer:MoveToWorld( Player:GetWorld():GetName() ) + end + OtherPlayer:TeleportToEntity( Player ) + Player:SendMessage( cChatColor.Green .. OtherPlayer:GetName() .. " teleported to you" ) + OtherPlayer:SendMessage( cChatColor.Green .. "You teleported to " .. Player:GetName() ) + Destination[Player:GetName()] = nil + end + end + local loopWorlds = function( World ) + World:ForEachPlayer( loopPlayer ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + 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) |