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/ChatLog/plugin.lua | 27 +- MCServer/Plugins/ChunkWorx/chunkworx_main.lua | 4 +- 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 +++++ MCServer/Plugins/Debuggers/Debuggers.lua | 16 +- MCServer/Plugins/DiamondMover/DiamondMover.lua | 4 +- MCServer/Plugins/HookNotify/HookNotify.lua | 333 ++++++++++++++++++++++++ MCServer/settings.ini | 5 + VC2008/MCServer.vcproj | 16 +- iniFile/iniFile.h | 112 ++++---- 17 files changed, 544 insertions(+), 187 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 create mode 100644 MCServer/Plugins/HookNotify/HookNotify.lua diff --git a/MCServer/Plugins/ChatLog/plugin.lua b/MCServer/Plugins/ChatLog/plugin.lua index 0288d1aa9..9ef321b48 100644 --- a/MCServer/Plugins/ChatLog/plugin.lua +++ b/MCServer/Plugins/ChatLog/plugin.lua @@ -1,15 +1,30 @@ -function Initialize( Plugin ) - Plugin:SetName( "ChatLog" ) - Plugin:SetVersion( 2 ) + +-- plugin.lua + +-- Implements the main entrypoint for the plugin, as well as all the handling needed + +-- ChatLog plugin logs all chat messages into the server log + + + + + +function Initialize(Plugin) + Plugin:SetName("ChatLog") + Plugin:SetVersion(3) PluginManager = cRoot:Get():GetPluginManager() - PluginManager:AddHook( Plugin, cPluginManager.E_PLUGIN_CHAT ) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) - LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) + LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) return true end -function OnChat( Player, Message ) + + + + +function OnChat(Player, Message) -- Lets get loggin' LOGINFO("[" .. Player:GetName() .. "]: " .. Message); diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua index 95d17aefc..66cf00b97 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua @@ -27,7 +27,7 @@ function Initialize(Plugin) PLUGIN:SetVersion(6) PluginManager = cRoot:Get():GetPluginManager() - PluginManager:AddHook(PLUGIN, cPluginManager.E_PLUGIN_TICK) + PluginManager:AddHook(PLUGIN, cPluginManager.HOOK_TICK) Plugin:AddWebTab("(Re)Generation", HandleRequest_Generation) @@ -71,7 +71,7 @@ function OnDisable() LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...") end -function Tick( DeltaTime ) +function OnTick( DeltaTime ) if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works STARTED!") LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": At world: " .. WORK_WORLD) 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 diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 5550f0335..f2f3f9570 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -13,7 +13,7 @@ function Initialize(Plugin) Plugin:SetVersion(1) PluginManager = cRoot:Get():GetPluginManager() - PluginManager:AddHook(Plugin, cPluginManager.E_PLUGIN_BLOCK_PLACE) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM) PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE) LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) @@ -24,13 +24,15 @@ end -function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem) +function OnPlayerUsingItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ) -- dont check if the direction is in the air - if BlockFace == BLOCK_FACE_NONE then + if (BlockFace == BLOCK_FACE_NONE) then return false end + local HeldItem = Player:GetEquippedItem(); + if (HeldItem.m_ItemType == E_ITEM_STICK) then -- Magic sTick of ticking: set the pointed block for ticking at the next tick Player:SendMessage(cChatColor.LightGray .. "Setting next block tick to {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}") @@ -42,7 +44,9 @@ function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem) -- Magic rod of query: show block types and metas for both neighbors of the pointed face local Type = 0; local Meta = 0; - Type, Meta = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ, Type, Meta); + local Valid = false; + Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(BlockX, BlockY, BlockZ, Type, Meta); + if (Type == E_BLOCK_AIR) then Player:SendMessage(cChatColor.LightGray .. "Block {" .. BlockX .. ", " .. BlockY .. ", " .. BlockZ .. "}: air:" .. Meta); else @@ -53,8 +57,8 @@ function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem) local X = BlockX; local Y = BlockY; local Z = BlockZ; - X, Y, Z = AddDirection(BlockX, BlockY, BlockZ, BlockFace); - Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z, Type, Meta); + X, Y, Z = AddFaceDirection(BlockX, BlockY, BlockZ, BlockFace); + Valid, Type, Meta = Player:GetWorld():GetBlockTypeMeta(X, Y, Z, Type, Meta); if (Type == E_BLOCK_AIR) then Player:SendMessage(cChatColor.LightGray .. "Block {" .. X .. ", " .. Y .. ", " .. Z .. "}: air:" .. Meta); else diff --git a/MCServer/Plugins/DiamondMover/DiamondMover.lua b/MCServer/Plugins/DiamondMover/DiamondMover.lua index 075268fa4..eaced1058 100644 --- a/MCServer/Plugins/DiamondMover/DiamondMover.lua +++ b/MCServer/Plugins/DiamondMover/DiamondMover.lua @@ -25,7 +25,7 @@ function Initialize(Plugin) Plugin:SetVersion(1); PluginManager = cRoot:Get():GetPluginManager(); - PluginManager:AddHook(Plugin, cPluginManager.HOOK_BLOCK_PLACE); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM); return true; end @@ -33,7 +33,7 @@ end -function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem) +function OnPlayerUsedItem(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ) -- Don't check if the direction is in the air if (BlockFace == -1) then diff --git a/MCServer/Plugins/HookNotify/HookNotify.lua b/MCServer/Plugins/HookNotify/HookNotify.lua new file mode 100644 index 000000000..5a5a48c72 --- /dev/null +++ b/MCServer/Plugins/HookNotify/HookNotify.lua @@ -0,0 +1,333 @@ + +-- Global variables +PLUGIN = {} -- Reference to own plugin object + + + + + +function Initialize(Plugin) + PLUGIN = Plugin + + Plugin:SetName("HookNotify") + Plugin:SetVersion(1) + + PluginManager = cRoot:Get():GetPluginManager() + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_COLLECT_PICKUP); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_HANDSHAKE); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLED); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BROKEN_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_EATING); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_LEFT_CLICK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVED); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACED_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_RIGHTCLICK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SHOOTING); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_SPAWNED); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_TOSSING_ITEM); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USED_ITEM); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_BLOCK); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_USING_ITEM); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_POST_CRAFTING); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PRE_CRAFTING); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_TAKE_DAMAGE); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATED_SIGN); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_UPDATING_SIGN); + PluginManager:AddHook(Plugin, cPluginManager.HOOK_WEATHER_CHANGED); + + LOGINFO("HookNotify plugin is installed, beware, the log output may be quite large!"); + LOGINFO("You want this plugin enabled only when developing another plugin, not for regular gameplay."); + + return true +end + + + + + +function LogHook(FnName, ...) + LOG(FnName .. "("); + for i, v in ipairs(arg) do + local vt = tostring(v); + local TypeString = type(v); + if (type(v) == "userdata") then + TypeString = tolua.type(v); + end; + LOG(" " .. tostring(i) .. ": " .. TypeString .. ": " .. tostring(v)); + end + LOG(")"); +end + + + + + +function OnChat(...) + LogHook("OnChat", unpack(arg)); +end + + + + + +function OnChunkGenerated(...) + LogHook("OnChunkGenerated", unpack(arg)); +end + + + + + +function OnChunkGenerating(...) + LogHook("OnChunkGenerating", unpack(arg)); +end + + + + + +function OnPlayerUsingItem(...) + LogHook("OnPlayerUsingItem", unpack(arg)); +end + + + + + +function OnCollectPickup(...) + LogHook("OnCollectPickup", unpack(arg)); +end + + + + +function OnCraftingNoRecipe(...) + LogHook("OnCraftingNoRecipe", unpack(arg)); +end + + + + + +function OnDisconnect(...) + LogHook("OnDisconnect", unpack(arg)); +end + + + + + +function OnHandshake(...) + LogHook("OnHandshake", unpack(arg)); +end + + + + + +function OnKilled(...) + LogHook("OnKilled", unpack(arg)); +end + + + + + +function OnLogin(...) + LogHook("OnLogin", unpack(arg)); +end + + + + + +function OnPlayerBreakingBlock(...) + LogHook("OnPlayerBreakingBlock", unpack(arg)); +end + + + + + +function OnPlayerBrokenBlock(...) + LogHook("OnPlayerBrokenBlock", unpack(arg)); +end + + + + + +function OnPlayerEating(...) + LogHook("OnPlayerEating", unpack(arg)); +end + + + + + +function OnPlayerJoined(...) + LogHook("OnPlayerJoined", unpack(arg)); +end + + + + + +function OnPlayerLeftClick(...) + LogHook("OnPlayerLeftClick", unpack(arg)); +end + + + + + +function OnPlayerMoved(...) + LogHook("OnPlayerMoved", unpack(arg)); +end + + + + + +function OnPlayerPlacedBlock(...) + LogHook("OnPlayerPlacedBlock", unpack(arg)); +end + + + + + +function OnPlayerPlacingBlock(...) + LogHook("OnPlayerPlacingBlock", unpack(arg)); +end + + + + + +function OnPlayerRightClick(...) + LogHook("OnPlayerRightClick", unpack(arg)); +end + + + + + +function OnPlayerShooting(...) + LogHook("OnPlayerShooting", unpack(arg)); +end + + + + + +function OnPlayerSpawned(...) + LogHook("OnPlayerSpawned", unpack(arg)); +end + + + + + +function OnPlayerTossingItem(...) + LogHook("OnPlayerTossingItem", unpack(arg)); +end + + + + + +function OnPlayerUsedBlock(...) + LogHook("OnPlayerUsedBlock", unpack(arg)); +end + + + + + +function OnPlayerUsedItem(...) + LogHook("OnPlayerUsedItem", unpack(arg)); +end + + + + + +function OnPlayerUsingBlock(...) + LogHook("OnPlayerUsingBlock", unpack(arg)); +end + + + + + +function OnPlayerUsingItem(...) + LogHook("OnPlayerUsingItem", unpack(arg)); +end + + + + + +function OnPostCrafting(...) + LogHook("OnPostCrafting", unpack(arg)); +end + + + + + +function OnPreCrafting(...) + LogHook("OnPreCrafting", unpack(arg)); +end + + + + + +function OnUpdatedSign(...) + LogHook("OnUpdatedSign", unpack(arg)); +end + + + + + +function OnUpdatingSign(...) + LogHook("OnUpdatingSign", unpack(arg)); +end + + + + + +function OnWeatherChanged(...) + LogHook("OnWeatherChanged", unpack(arg)); +end + + + + + +------------------------------------------------------------------ +-- Special handling for OnTakeDamage to print the contents of TDI: + +function OnTakeDamage(Receiver, TDI) + -- Receiver is cPawn + -- TDI is TakeDamageInfo + + LOG("OnTakeDamage(): " .. Receiver:GetClass() .. " was dealt RawDamage " .. TDI.RawDamage .. ", FinalDamage " .. TDI.FinalDamage .. " (that is, " .. (TDI.RawDamage - TDI.FinalDamage) .. " HPs covered by armor)"); +end + + + diff --git a/MCServer/settings.ini b/MCServer/settings.ini index 1b4155c14..688859ac5 100644 --- a/MCServer/settings.ini +++ b/MCServer/settings.ini @@ -6,6 +6,7 @@ Port=25565 MaxPlayers=100 Description=MCServer - in C++ +DefaultViewDistance=9 [Worlds] DefaultWorld=world @@ -15,6 +16,10 @@ DefaultWorld=world ; Plugin=DiamondMover Plugin=Core Plugin=ChunkWorx +Plugin=Debuggers +Plugin=HookNotify +Plugin=ChatLog +Plugin=DiamondMover [HelpPlugin] ShowPluginNames=1 diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index c22870614..8e0199cf3 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -699,14 +699,6 @@ RelativePath="..\source\WebAdmin.h" > - - - - @@ -1551,6 +1543,14 @@ RelativePath="..\source\tolua_base.h" > + + + + diff --git a/iniFile/iniFile.h b/iniFile/iniFile.h index 58a5a52b6..1afc404e3 100644 --- a/iniFile/iniFile.h +++ b/iniFile/iniFile.h @@ -30,8 +30,8 @@ -class cIniFile //tolua_export -{ //tolua_export +class cIniFile // tolua_export +{ // tolua_export private: bool caseInsensitive; std::string path; @@ -46,64 +46,64 @@ private: std::string CheckCase( std::string s) const; public: - enum errors{ noID = -1}; //tolua_export - cIniFile( const std::string iniPath = ""); //tolua_export + enum errors{ noID = -1}; // tolua_export + cIniFile( const std::string iniPath = ""); // tolua_export virtual ~cIniFile() {} // Sets whether or not keynames and valuenames should be case sensitive. // The default is case insensitive. - void CaseSensitive() {caseInsensitive = false;} //tolua_export - void CaseInsensitive() {caseInsensitive = true;} //tolua_export + void CaseSensitive() {caseInsensitive = false;} // tolua_export + void CaseInsensitive() {caseInsensitive = true;} // tolua_export // Sets path of ini file to read and write from. - void Path(const std::string & newPath) {path = newPath;} //tolua_export - std::string Path() const {return path;} //tolua_export - void SetPath(const std::string & newPath) {Path( newPath);} //tolua_export + void Path(const std::string & newPath) {path = newPath;} // tolua_export + std::string Path() const {return path;} // tolua_export + void SetPath(const std::string & newPath) {Path( newPath);} // tolua_export // Reads ini file specified using path. // Returns true if successful, false otherwise. - bool ReadFile(); //tolua_export + bool ReadFile(); // tolua_export // Writes data stored in class to ini file. - bool WriteFile(); //tolua_export + bool WriteFile(); // tolua_export // Deletes all stored ini data. - void Erase(); //tolua_export - void Clear() {Erase();} //tolua_export - void Reset() {Erase();} //tolua_export + void Erase(); // tolua_export + void Clear() {Erase();} // tolua_export + void Reset() {Erase();} // tolua_export // Returns index of specified key, or noID if not found. - long FindKey( const std::string & keyname) const; //tolua_export + long FindKey( const std::string & keyname) const; // tolua_export // Returns index of specified value, in the specified key, or noID if not found. - long FindValue( const unsigned keyID, const std::string & valuename) const; //tolua_export + long FindValue( const unsigned keyID, const std::string & valuename) const; // tolua_export // Returns number of keys currently in the ini. - unsigned NumKeys() const {return names.size();} //tolua_export - unsigned GetNumKeys() const {return NumKeys();} //tolua_export + unsigned NumKeys() const {return names.size();} // tolua_export + unsigned GetNumKeys() const {return NumKeys();} // tolua_export // Add a key name. - unsigned AddKeyName( const std::string & keyname); //tolua_export + unsigned AddKeyName( const std::string & keyname); // tolua_export // Returns key names by index. - std::string KeyName( const unsigned keyID) const; //tolua_export - std::string GetKeyName( const unsigned keyID) const {return KeyName(keyID);} //tolua_export + std::string KeyName( const unsigned keyID) const; // tolua_export + std::string GetKeyName( const unsigned keyID) const {return KeyName(keyID);} // tolua_export // Returns number of values stored for specified key. - unsigned NumValues( const std::string & keyname); //tolua_export - unsigned GetNumValues( const std::string & keyname) {return NumValues( keyname);} //tolua_export - unsigned NumValues( const unsigned keyID); //tolua_export - unsigned GetNumValues( const unsigned keyID) {return NumValues( keyID);} //tolua_export + unsigned NumValues( const std::string & keyname); // tolua_export + unsigned GetNumValues( const std::string & keyname) {return NumValues( keyname);} // tolua_export + unsigned NumValues( const unsigned keyID); // tolua_export + unsigned GetNumValues( const unsigned keyID) {return NumValues( keyID);} // tolua_export // Returns value name by index for a given keyname or keyID. - std::string ValueName( const std::string & keyname, const unsigned valueID) const; //tolua_export - std::string GetValueName( const std::string & keyname, const unsigned valueID) const { //tolua_export + std::string ValueName( const std::string & keyname, const unsigned valueID) const; // tolua_export + std::string GetValueName( const std::string & keyname, const unsigned valueID) const { // tolua_export return ValueName( keyname, valueID); - } //tolua_export - std::string ValueName( const unsigned keyID, const unsigned valueID) const; //tolua_export - std::string GetValueName( const unsigned keyID, const unsigned valueID) const { //tolua_export + } // tolua_export + std::string ValueName( const unsigned keyID, const unsigned valueID) const; // tolua_export + std::string GetValueName( const unsigned keyID, const unsigned valueID) const { // tolua_export return ValueName( keyID, valueID); - } //tolua_export + } // tolua_export // Gets value of [keyname] valuename =. // Overloaded to return string, int, and double. @@ -128,37 +128,37 @@ public: // Specify the optional paramter as false (0) if you do not want it to create // the key if it doesn't exist. Returns true if data entered, false otherwise. // Overloaded to accept string, int, and double. - bool SetValue( const unsigned keyID, const unsigned valueID, const std::string & value); //tolua_export - bool SetValue( const std::string & keyname, const std::string & valuename, const std::string & value, const bool create = true); //tolua_export - bool SetValueI( const std::string & keyname, const std::string & valuename, const int value, const bool create = true); //tolua_export - bool SetValueB( const std::string & keyname, const std::string & valuename, const bool value, const bool create = true) { //tolua_export + bool SetValue( const unsigned keyID, const unsigned valueID, const std::string & value); // tolua_export + bool SetValue( const std::string & keyname, const std::string & valuename, const std::string & value, const bool create = true); // tolua_export + bool SetValueI( const std::string & keyname, const std::string & valuename, const int value, const bool create = true); // tolua_export + bool SetValueB( const std::string & keyname, const std::string & valuename, const bool value, const bool create = true) { // tolua_export return SetValueI( keyname, valuename, int(value), create); - } //tolua_export - bool SetValueF( const std::string & keyname, const std::string & valuename, const double value, const bool create = true); //tolua_export + } // tolua_export + bool SetValueF( const std::string & keyname, const std::string & valuename, const double value, const bool create = true); // tolua_export bool SetValueV( const std::string & keyname, const std::string & valuename, char *format, ...); // Deletes specified value. // Returns true if value existed and deleted, false otherwise. - bool DeleteValueByID( const unsigned keyID, const unsigned valueID ); //tolua_export - bool DeleteValue( const std::string & keyname, const std::string & valuename); //tolua_export + bool DeleteValueByID( const unsigned keyID, const unsigned valueID ); // tolua_export + bool DeleteValue( const std::string & keyname, const std::string & valuename); // tolua_export // Deletes specified key and all values contained within. // Returns true if key existed and deleted, false otherwise. - bool DeleteKey(const std::string & keyname); //tolua_export + bool DeleteKey(const std::string & keyname); // tolua_export // Header comment functions. // Header comments are those comments before the first key. // // Number of header comments. - unsigned NumHeaderComments() {return comments.size();} //tolua_export + unsigned NumHeaderComments() {return comments.size();} // tolua_export // Add a header comment. - void HeaderComment( const std::string & comment); //tolua_export + void HeaderComment( const std::string & comment); // tolua_export // Return a header comment. - std::string HeaderComment( const unsigned commentID) const; //tolua_export + std::string HeaderComment( const unsigned commentID) const; // tolua_export // Delete a header comment. - bool DeleteHeaderComment( unsigned commentID); //tolua_export + bool DeleteHeaderComment( unsigned commentID); // tolua_export // Delete all header comments. - void DeleteHeaderComments() {comments.clear();} //tolua_export + void DeleteHeaderComments() {comments.clear();} // tolua_export // Key comment functions. // Key comments are those comments within a key. Any comments @@ -167,20 +167,20 @@ public: // the CIniFile::WriteFile() is called. // // Number of key comments. - unsigned NumKeyComments( const unsigned keyID) const; //tolua_export - unsigned NumKeyComments( const std::string & keyname) const; //tolua_export + unsigned NumKeyComments( const unsigned keyID) const; // tolua_export + unsigned NumKeyComments( const std::string & keyname) const; // tolua_export // Add a key comment. - bool KeyComment( const unsigned keyID, const std::string & comment); //tolua_export - bool KeyComment( const std::string & keyname, const std::string & comment); //tolua_export + bool KeyComment( const unsigned keyID, const std::string & comment); // tolua_export + bool KeyComment( const std::string & keyname, const std::string & comment); // tolua_export // Return a key comment. - std::string KeyComment( const unsigned keyID, const unsigned commentID) const; //tolua_export - std::string KeyComment( const std::string & keyname, const unsigned commentID) const; //tolua_export + std::string KeyComment( const unsigned keyID, const unsigned commentID) const; // tolua_export + std::string KeyComment( const std::string & keyname, const unsigned commentID) const; // tolua_export // Delete a key comment. - bool DeleteKeyComment( const unsigned keyID, const unsigned commentID); //tolua_export - bool DeleteKeyComment( const std::string & keyname, const unsigned commentID); //tolua_export + bool DeleteKeyComment( const unsigned keyID, const unsigned commentID); // tolua_export + bool DeleteKeyComment( const std::string & keyname, const unsigned commentID); // tolua_export // Delete all comments for a key. - bool DeleteKeyComments( const unsigned keyID); //tolua_export - bool DeleteKeyComments( const std::string & keyname); //tolua_export -}; //tolua_export + bool DeleteKeyComments( const unsigned keyID); // tolua_export + bool DeleteKeyComments( const std::string & keyname); // tolua_export +}; // tolua_export #endif -- cgit v1.2.3