1
0
Fork 0

Forgotten files for previous merge commit (rev 1139)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1140 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-01-13 11:10:26 +00:00
parent 43e6840719
commit 752057fb1b
15 changed files with 474 additions and 117 deletions

View File

@ -1,14 +1,29 @@
-- 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( 2 )
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())
return true
end
function OnChat(Player, Message)
-- Lets get loggin'
LOGINFO("[" .. Player:GetName() .. "]: " .. Message);

View File

@ -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)

View File

@ -1,6 +1,6 @@
function HandleItemCommand( Split, Player )
if( #Split ~= 2 and #Split ~=3 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /item [ItemID/Name:Dmg] <Amount>" )
Player:SendMessage( cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] <Amount>" )
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

View File

@ -12,13 +12,13 @@ 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
@ -26,7 +26,7 @@ function Initialize( Plugin )
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] <Amount> - Spawn an item for yourself", "core.item")
Plugin:AddCommand("/item", " - [ItemType/Name] <Amount> - 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")

View File

@ -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

View File

@ -1,4 +1,4 @@
function OnBlockDig(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta)
function OnPlayerBreakingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta)
-- dont check if the direction is in the air
if (BlockFace ~= -1) then

View File

@ -1,4 +0,0 @@
function OnPlayerJoin( Player )
ShowMOTDTo( Player )
return false
end

View File

@ -0,0 +1,4 @@
function OnPlayerJoined(Player)
ShowMOTDTo( Player )
return false
end

View File

@ -1,4 +1,4 @@
function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem)
function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType)
-- dont check if the direction is in the air
if (BlockFace == -1) then
@ -14,7 +14,7 @@ function OnBlockPlace(Player, BlockX, BlockY, BlockZ, BlockFace, HeldItem)
local X = BlockX
local Y = BlockY
local Z = BlockZ
X, Y, Z = AddDirection(X, Y, Z, BlockFace)
X, Y, Z = AddFaceDirection(X, Y, Z, BlockFace)
if (Y >= 256 or Y < 0) then
return true
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -699,14 +699,6 @@
RelativePath="..\source\WebAdmin.h"
>
</File>
<File
RelativePath="..\source\WebPlugin.cpp"
>
</File>
<File
RelativePath="..\source\WebPlugin.h"
>
</File>
<File
RelativePath="..\source\World.cpp"
>
@ -1551,6 +1543,14 @@
RelativePath="..\source\tolua_base.h"
>
</File>
<File
RelativePath="..\source\WebPlugin.cpp"
>
</File>
<File
RelativePath="..\source\WebPlugin.h"
>
</File>
<Filter
Name="Squirrel"
>