From 752057fb1b3a71058b5391bde9b0e21d87196539 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 13 Jan 2013 11:10:26 +0000 Subject: Forgotten files for previous merge commit (rev 1139) git-svn-id: http://mc-server.googlecode.com/svn/trunk@1140 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Core/item.lua | 4 +- MCServer/Plugins/Core/main.lua | 42 ++++++++--------- MCServer/Plugins/Core/onblockdig.lua | 10 ---- MCServer/Plugins/Core/onblockplace.lua | 63 ------------------------- MCServer/Plugins/Core/oncraftingnorecipe.lua | 14 +++--- MCServer/Plugins/Core/onplayerbreakingblock.lua | 10 ++++ MCServer/Plugins/Core/onplayerjoin.lua | 4 -- MCServer/Plugins/Core/onplayerjoined.lua | 4 ++ MCServer/Plugins/Core/onplayerplacingblock.lua | 63 +++++++++++++++++++++++++ 9 files changed, 107 insertions(+), 107 deletions(-) delete mode 100644 MCServer/Plugins/Core/onblockdig.lua delete mode 100644 MCServer/Plugins/Core/onblockplace.lua create mode 100644 MCServer/Plugins/Core/onplayerbreakingblock.lua delete mode 100644 MCServer/Plugins/Core/onplayerjoin.lua create mode 100644 MCServer/Plugins/Core/onplayerjoined.lua create mode 100644 MCServer/Plugins/Core/onplayerplacingblock.lua (limited to 'MCServer/Plugins/Core') diff --git a/MCServer/Plugins/Core/item.lua b/MCServer/Plugins/Core/item.lua index ce80ec7d3..00a6aa790 100644 --- a/MCServer/Plugins/Core/item.lua +++ b/MCServer/Plugins/Core/item.lua @@ -1,6 +1,6 @@ function HandleItemCommand( Split, Player ) if( #Split ~= 2 and #Split ~=3 ) then - Player:SendMessage( cChatColor.Green .. "Usage: /item [ItemID/Name:Dmg] " ) + Player:SendMessage( cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] " ) return true end @@ -12,7 +12,7 @@ function HandleItemCommand( Split, Player ) end if( FoundItem == false ) then - Player:SendMessage( cChatColor.Green .. "Invalid Item ID / Name !" ) + Player:SendMessage( cChatColor.Green .. "Invalid Item type / name !" ) return true end diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua index c6a1b7e6a..97263f1d6 100644 --- a/MCServer/Plugins/Core/main.lua +++ b/MCServer/Plugins/Core/main.lua @@ -12,34 +12,34 @@ function Initialize( Plugin ) PLUGIN = Plugin Plugin:SetName( "Core" ) - Plugin:SetVersion( 8 ) + Plugin:SetVersion(9) PluginManager = cRoot:Get():GetPluginManager() - PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOIN) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK) PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN) - PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_PLACE) - PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_DIG) PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLED) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua - Plugin:AddCommand("/help", " - [Page] Show this message", "core.help") - Plugin:AddCommand("/pluginlist", " - Show list of plugins", "core.pluginlist") - Plugin:AddCommand("/tp", " - [Player] - Teleport yourself to a player", "core.teleport") - Plugin:AddCommand("/item", " - [ItemID/Name] - Spawn an item for yourself", "core.item") - Plugin:AddCommand("/list", " - Shows list of connected players", "core.playerlist") - Plugin:AddCommand("/motd", " - Show message of the day", "core.motd") - Plugin:AddCommand("/reload", " - Reload all plugins", "core.reload") - Plugin:AddCommand("/stop", " - Stops the server", "core.stop") - Plugin:AddCommand("/time", " - [Day/Night] - Sets the time of day", "core.time") - Plugin:AddCommand("/spawn", " - Return to the spawn", "core.spawn") - Plugin:AddCommand("/kick", " - [Player] - Kick a player", "core.kick") - Plugin:AddCommand("/ban", " - [Player] - Ban a player", "core.ban") - Plugin:AddCommand("/unban", " - [Player] - Unban a player", "core.unban") - Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top") - Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm") - Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld") - Plugin:AddCommand("/coords", " - Show your current server coordinates", "core.coords") + Plugin:AddCommand("/help", " - [Page] Show this message", "core.help") + Plugin:AddCommand("/pluginlist", " - Show list of plugins", "core.pluginlist") + Plugin:AddCommand("/tp", " - [Player] - Teleport yourself to a player", "core.teleport") + Plugin:AddCommand("/item", " - [ItemType/Name] - Give yourself an item", "core.item") + Plugin:AddCommand("/list", " - Shows list of connected players", "core.playerlist") + Plugin:AddCommand("/motd", " - Show message of the day", "core.motd") + Plugin:AddCommand("/reload", " - Reload all plugins", "core.reload") + Plugin:AddCommand("/stop", " - Stops the server", "core.stop") + Plugin:AddCommand("/time", " - [Day/Night] - Sets the time of day", "core.time") + Plugin:AddCommand("/spawn", " - Return to the spawn", "core.spawn") + Plugin:AddCommand("/kick", " - [Player] - Kick a player", "core.kick") + Plugin:AddCommand("/ban", " - [Player] - Ban a player", "core.ban") + Plugin:AddCommand("/unban", " - [Player] - Unban a player", "core.unban") + Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top") + Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm") + Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld") + Plugin:AddCommand("/coords", " - Show your current server coordinates", "core.coords") Plugin:AddCommand("/viewdistance", " - [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance", "core.viewdistance") Plugin:AddCommand("/regeneratechunk", " - - Regenerates a chunk", "core.regeneratechunk") diff --git a/MCServer/Plugins/Core/onblockdig.lua b/MCServer/Plugins/Core/onblockdig.lua deleted file mode 100644 index 65e48576c..000000000 --- a/MCServer/Plugins/Core/onblockdig.lua +++ /dev/null @@ -1,10 +0,0 @@ -function OnBlockDig(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta) - -- dont check if the direction is in the air - if (BlockFace ~= -1) then - - if (Player:HasPermission("core.build") == false) then - return true - end - end - return false -end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onblockplace.lua b/MCServer/Plugins/Core/onblockplace.lua deleted file mode 100644 index 9032f8207..000000000 --- a/MCServer/Plugins/Core/onblockplace.lua +++ /dev/null @@ -1,63 +0,0 @@ -function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem) - - -- dont check if the direction is in the air - if (BlockFace == -1) then - return false - end - - if( Player:HasPermission("core.build") == false ) then - return true - end - - -- TODO: If the placed block is not a block (torch etc.), allow it without checking for collisions - - local X = BlockX - local Y = BlockY - local Z = BlockZ - X, Y, Z = AddDirection(X, Y, Z, BlockFace) - if (Y >= 256 or Y < 0) then - return true - end - - local CheckCollision = function(Player) - -- drop the decimals, we only care about the full block X,Y,Z - local PlayerX = math.floor(Player:GetPosX(), 0) - local PlayerY = math.floor(Player:GetPosY(), 0) - local PlayerZ = math.floor(Player:GetPosZ(), 0) - - -- player height is 2 blocks, so we check the position and then offset it up one - -- so they can't place a block in anyone's face - - local collision = false - if ((BlockFace == BLOCK_FACE_TOP) and (PlayerY == BlockY - 2) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then - collision = true - end - - if ((BlockFace == BLOCK_FACE_BOTTOM) and (PlayerY == BlockY + 1) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then - collision = true - end - - if ((BlockFace == BLOCK_FACE_NORTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ - 1)) then - if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end - end - - if ((BlockFace == BLOCK_FACE_SOUTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ + 1)) then - if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end - end - - if ((BlockFace == BLOCK_FACE_WEST) and (PlayerX == BlockX - 1) and (PlayerZ == BlockZ)) then - if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end - end - - if ((BlockFace == BLOCK_FACE_EAST) and (PlayerX == BlockX + 1) and (PlayerZ == BlockZ)) then - if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end - end - - return collision - end - - if (Player:GetWorld():ForEachPlayer(CheckCollision) == false) then - return true - end - return false -end \ No newline at end of file diff --git a/MCServer/Plugins/Core/oncraftingnorecipe.lua b/MCServer/Plugins/Core/oncraftingnorecipe.lua index 2006e410f..b6909d672 100644 --- a/MCServer/Plugins/Core/oncraftingnorecipe.lua +++ b/MCServer/Plugins/Core/oncraftingnorecipe.lua @@ -16,7 +16,7 @@ function OnCraftingNoRecipe(Player, Grid, Recipe) for x = 0, Grid:GetWidth() - 1 do for y = 0, Grid:GetHeight() - 1 do local Item = Grid:GetItem(x, y) - if (Item.m_ItemID ~= E_ITEM_EMPTY) then + if (Item.m_ItemType ~= E_ITEM_EMPTY) then table.insert(Items, Item) end end @@ -27,23 +27,23 @@ function OnCraftingNoRecipe(Player, Grid, Recipe) return false end - if (Items[1].m_ItemID ~= Items[2].m_ItemID) then + if (Items[1].m_ItemType ~= Items[2].m_ItemType) then -- Only items of the same type may be fixed return false end if ( - (Items[1].m_ItemHealth == 0) or - (Items[2].m_ItemHealth == 0) + (Items[1].m_ItemDamage == 0) or + (Items[2].m_ItemDamage == 0) ) then -- Only damaged items may be fixed return false end - local _ID = Items[1].m_ItemID - local _least_hp = math.max(Items[1].m_ItemHealth, Items[2].m_ItemHealth) - local _most_hp = math.min(Items[1].m_ItemHealth, Items[2].m_ItemHealth) + local _ID = Items[1].m_ItemType + local _least_hp = math.max(Items[1].m_ItemDamage, Items[2].m_ItemDamage) + local _most_hp = math.min(Items[1].m_ItemDamage, Items[2].m_ItemDamage) local _item_hp = 0 -- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp diff --git a/MCServer/Plugins/Core/onplayerbreakingblock.lua b/MCServer/Plugins/Core/onplayerbreakingblock.lua new file mode 100644 index 000000000..fc7d5897d --- /dev/null +++ b/MCServer/Plugins/Core/onplayerbreakingblock.lua @@ -0,0 +1,10 @@ +function OnPlayerBreakingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta) + -- dont check if the direction is in the air + if (BlockFace ~= -1) then + + if (Player:HasPermission("core.build") == false) then + return true + end + end + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onplayerjoin.lua b/MCServer/Plugins/Core/onplayerjoin.lua deleted file mode 100644 index e8263f608..000000000 --- a/MCServer/Plugins/Core/onplayerjoin.lua +++ /dev/null @@ -1,4 +0,0 @@ -function OnPlayerJoin( Player ) - ShowMOTDTo( Player ) - return false -end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onplayerjoined.lua b/MCServer/Plugins/Core/onplayerjoined.lua new file mode 100644 index 000000000..8aa067a0c --- /dev/null +++ b/MCServer/Plugins/Core/onplayerjoined.lua @@ -0,0 +1,4 @@ +function OnPlayerJoined(Player) + ShowMOTDTo( Player ) + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onplayerplacingblock.lua b/MCServer/Plugins/Core/onplayerplacingblock.lua new file mode 100644 index 000000000..be2fd64d3 --- /dev/null +++ b/MCServer/Plugins/Core/onplayerplacingblock.lua @@ -0,0 +1,63 @@ +function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType) + + -- dont check if the direction is in the air + if (BlockFace == -1) then + return false + end + + if( Player:HasPermission("core.build") == false ) then + return true + end + + -- TODO: If the placed block is not a block (torch etc.), allow it without checking for collisions + + local X = BlockX + local Y = BlockY + local Z = BlockZ + X, Y, Z = AddFaceDirection(X, Y, Z, BlockFace) + if (Y >= 256 or Y < 0) then + return true + end + + local CheckCollision = function(Player) + -- drop the decimals, we only care about the full block X,Y,Z + local PlayerX = math.floor(Player:GetPosX(), 0) + local PlayerY = math.floor(Player:GetPosY(), 0) + local PlayerZ = math.floor(Player:GetPosZ(), 0) + + -- player height is 2 blocks, so we check the position and then offset it up one + -- so they can't place a block in anyone's face + + local collision = false + if ((BlockFace == BLOCK_FACE_TOP) and (PlayerY == BlockY - 2) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then + collision = true + end + + if ((BlockFace == BLOCK_FACE_BOTTOM) and (PlayerY == BlockY + 1) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then + collision = true + end + + if ((BlockFace == BLOCK_FACE_NORTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ - 1)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_SOUTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ + 1)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_WEST) and (PlayerX == BlockX - 1) and (PlayerZ == BlockZ)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_EAST) and (PlayerX == BlockX + 1) and (PlayerZ == BlockZ)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + return collision + end + + if (Player:GetWorld():ForEachPlayer(CheckCollision) == false) then + return true + end + return false +end \ No newline at end of file -- cgit v1.2.3