Skip to content

Commit 74e1d97

Browse files
authored
Update warp.lua
1 parent 95ec1d5 commit 74e1d97

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Utility/warp.lua

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,18 @@ end, {
156156
end
157157
})
158158

159-
script.onEnable(function()
160-
-- Event to cancel the teleport if the player moves before the wait time is up
161-
script.hook("org.bukkit.event.player.PlayerMoveEvent", function(event)
162-
local player = event:getPlayer()
163-
-- Ignore camera movement
164-
if event:getFrom():getBlockX() == event:getTo():getBlockX() and
165-
event:getFrom():getBlockY() == event:getTo():getBlockY() and
166-
event:getFrom():getBlockZ() == event:getTo():getBlockZ() then
167-
return
168-
end
169-
local uniqueId = player:getUniqueId()
170-
if teleportTasks[uniqueId] then
171-
teleportTasks[uniqueId]:cancel()
172-
teleportTasks[uniqueId] = nil
173-
player:sendRichMessage("<red>Teleport cancelled due to movement.")
174-
end
175-
end)
176-
end)
159+
script.hook("org.bukkit.event.player.PlayerMoveEvent", function(event)
160+
local player = event:getPlayer()
161+
-- Ignore camera movement
162+
if event:getFrom():getBlockX() == event:getTo():getBlockX() and
163+
event:getFrom():getBlockY() == event:getTo():getBlockY() and
164+
event:getFrom():getBlockZ() == event:getTo():getBlockZ() then
165+
return
166+
end
167+
local uniqueId = player:getUniqueId()
168+
if teleportTasks[uniqueId] then
169+
teleportTasks[uniqueId]:cancel()
170+
teleportTasks[uniqueId] = nil
171+
player:sendRichMessage("<red>Teleport cancelled due to movement.")
172+
end
173+
end)

0 commit comments

Comments
 (0)