summaryrefslogtreecommitdiffstats
path: root/Server
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-11-26 20:45:01 +0100
committerMattes D <github@xoft.cz>2016-11-26 20:45:01 +0100
commit12071bc51a46b245d7b46bfe697dda1d54ee2f56 (patch)
tree7800402041e8ae8ecfb10fd2fb3efc6cc8921c61 /Server
parentDebuggers: Added commands to investigate item's custom name. (diff)
downloadcuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar.gz
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar.bz2
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar.lz
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar.xz
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.tar.zst
cuberite-12071bc51a46b245d7b46bfe697dda1d54ee2f56.zip
Diffstat (limited to 'Server')
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua4
-rw-r--r--Server/Plugins/Debuggers/Debuggers.lua47
-rw-r--r--Server/Plugins/Debuggers/Info.lua12
3 files changed, 61 insertions, 2 deletions
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index 79fcc67c1..4bc3fc096 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -2081,7 +2081,7 @@ return
},
},
Notes = "Returns the block's hardness. The bigger the harder the block.",
- },
+ },
GetBlockHeight =
{
IsStatic = true,
@@ -7930,7 +7930,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
Type = "cItem",
},
},
- Notes = "Returns the currently selected item from the hotbar. Note that the returned item is read-only",
+ Notes = "Returns the currently selected item from the hotbar. Note that the returned item is read-only. Also note that the returned item is bound to the actual inventory slot - if a player moves another item into the slot, this object will update to the new item. Use a {{cItem}} constructor to make a copy if you need to store the contents of the slot.",
},
GetEquippedLeggings =
{
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua
index 914da8036..4dfc55030 100644
--- a/Server/Plugins/Debuggers/Debuggers.lua
+++ b/Server/Plugins/Debuggers/Debuggers.lua
@@ -1031,6 +1031,28 @@ end
+function HandleGetPropCmd(a_Split, a_Player)
+ local item = a_Player:GetInventory():GetEquippedItem()
+ if not(item.m_DebuggersCustomProp) then
+ a_Player:SendMessage("The custom property is not set.")
+ return true
+ end
+ local dispValue = string.gsub(item.m_DebuggersCustomProp, ".",
+ function(a_Char)
+ if (a_Char < " ") then
+ return string.byte(a_Char)
+ end
+ return a_Char
+ end
+ )
+ a_Player:SendMessage(string.format("The custom property value is %d bytes: %s", string.len(item.m_DebuggersCustomProp), dispValue))
+ return true
+end
+
+
+
+
+
function HandleHungerCmd(a_Split, a_Player)
a_Player:SendMessage("FoodLevel: " .. a_Player:GetFoodLevel());
a_Player:SendMessage("FoodSaturationLevel: " .. a_Player:GetFoodSaturationLevel());
@@ -1109,6 +1131,31 @@ end
+function HandleSetPropCmd(a_Split, a_Player, a_EntireCmd)
+ if not(a_Split[2]) then
+ a_Player:SendMessageFatal("Missing an argument: the property value to set");
+ return true
+ end
+ local valueToSet = a_EntireCmd:match("/setprop%s(.*)")
+ if not(valueToSet) then
+ a_Player:SendMessageFatal("Failed to extract the property value to set")
+ return true
+ end
+ valueToSet = valueToSet:gsub("\\([0-9][0-9][0-9])", string.char)
+
+ local inv = a_Player:GetInventory()
+ local slotNum = inv:GetEquippedSlotNum()
+ local item = inv:GetEquippedItem()
+ item.m_DebuggersCustomProp = valueToSet
+ inv:SetHotbarSlot(slotNum, item)
+ a_Player:SendMessage("Custom property set to " .. valueToSet)
+ return true
+end
+
+
+
+
+
function HandleSetLoreCmd(a_Split, a_Player, a_EntireCmd)
if not(a_Split[2]) then
a_Player:SendMessageFatal("Missing an argument: the lore to set");
diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua
index dcdcdd17f..c21865218 100644
--- a/Server/Plugins/Debuggers/Info.lua
+++ b/Server/Plugins/Debuggers/Info.lua
@@ -112,6 +112,12 @@ g_PluginInfo =
Handler = HandleGetLoreCmd,
HelpString = "Displays the exact Lore of currently held item (including non-printables)",
},
+ ["/getprop"] =
+ {
+ Permission = "debuggers",
+ Handler = HandleGetPropCmd,
+ HelpString = "Displays the custom cItem property of the currently held item",
+ },
["/hunger"] =
{
Permission = "debuggers",
@@ -190,6 +196,12 @@ g_PluginInfo =
Handler = HandleSetLoreCmd,
HelpString = "Sets the lore for the item currently in hand",
},
+ ["/setprop"] =
+ {
+ Permission = "debuggers",
+ Handler = HandleSetPropCmd,
+ HelpString = "Sets the custom property for the item currently in hand",
+ },
["/spidey"] =
{
Permission = "debuggers",