summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-05-27 19:22:09 +0200
committerGitHub <noreply@github.com>2017-05-27 19:22:09 +0200
commit226272fc63297b4477ae43f217a83d7f08701b45 (patch)
tree03483733ed0faa350951064d27c4eb5febe0bfec
parentAdd rank prefix and suffix to player name in chat (#3730) (diff)
downloadcuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar.gz
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar.bz2
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar.lz
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar.xz
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.tar.zst
cuberite-226272fc63297b4477ae43f217a83d7f08701b45.zip
-rw-r--r--Server/Plugins/Debuggers/Debuggers.lua50
-rw-r--r--Server/Plugins/Debuggers/Info.lua6
2 files changed, 56 insertions, 0 deletions
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua
index fb18a0c19..6c47a8a17 100644
--- a/Server/Plugins/Debuggers/Debuggers.lua
+++ b/Server/Plugins/Debuggers/Debuggers.lua
@@ -1576,6 +1576,56 @@ end
+function HandleComeCmd(a_Split, a_Player)
+ -- Find the first solid block under the player (in case they are flying):
+ local playerWorld = a_Player:GetWorld()
+ local playerPos = a_Player:GetPosition()
+ local toPos = Vector3i(playerPos)
+ if (toPos.y < 1) then
+ a_Player:SendMessageFailure("Cannot navigate to you, you're too low in the world")
+ return true
+ end
+ while not(cBlockInfo:IsSolid(playerWorld:GetBlock(toPos.x, toPos.y, toPos.z))) do
+ if (toPos.y <= 0) then
+ a_Player:SendMessageFailure("Cannot navigate to you, there's no solid block below you")
+ return true
+ end
+ toPos.y = toPos.y - 1
+ end
+
+ -- Find the mob to navigate:
+ local mob
+ local playerLook = a_Player:GetLookVector():NormalizeCopy()
+ local maxDot = 0
+ playerWorld:ForEachEntity(
+ function (a_CBEntity)
+ local dir = (a_CBEntity:GetPosition() - playerPos)
+ dir:Normalize()
+ local dot = dir:Dot(playerLook)
+ if (dot > maxDot) then
+ maxDot = dot
+ mob = a_CBEntity
+ end
+ end
+ )
+ if not(mob) then
+ a_Player:SendMessageFailure("Cannot navigate to you, there's no mob this way")
+ return true
+ end
+
+ mob:MoveToPosition(Vector3d(toPos))
+ a_Player:SendMessageSuccess((
+ string.format("Navigating the %s to position {%d, %d, %d}",
+ cMonster:MobTypeToString(mob:GetMobType()), toPos.x, toPos.y, toPos.z
+ )
+ ))
+ return true
+end
+
+
+
+
+
function HandleCompo(a_Split, a_Player)
-- Send one composite message to self:
local msg = cCompositeChat()
diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua
index dea656837..e3b0beee1 100644
--- a/Server/Plugins/Debuggers/Info.lua
+++ b/Server/Plugins/Debuggers/Info.lua
@@ -34,6 +34,12 @@ g_PluginInfo =
Handler = HandleClientVersionCmd,
HelpString = "Shows your client's protocol version",
},
+ ["/come"] =
+ {
+ Permission = "debuggers.come",
+ Handler = HandleComeCmd,
+ HelpString = "Instruct the mob you're looking at to navigate to your position",
+ },
["/compo"] =
{
Permission = "debuggers",