don't call MinionChestLinkEvent for unlink

This commit is contained in:
rudde 2024-04-30 12:53:44 +03:00
parent d478a3c4eb
commit 05b36a3669

View File

@ -29,6 +29,15 @@ class LinkingListener : Listener {
if (event.clickedBlock!!.type !in CONTAINERS) return
if (!AxMinionsPlugin.integrations.getProtectionIntegration().canBuildAt(event.player, event.clickedBlock!!.location)) return
val minion = linking.remove(event.player) ?: return
event.isCancelled = true
if (minion.getLocation()
.distanceSquared(event.clickedBlock!!.location) > Config.MAX_LINKING_DISTANCE() * Config.MAX_LINKING_DISTANCE()
) {
event.player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.LINK_FAIL()))
return
}
val linkEvent = MinionChestLinkEvent(
linking.getValue(event.player),
event.player,
@ -39,15 +48,6 @@ class LinkingListener : Listener {
return
}
val minion = linking.remove(event.player) ?: return
event.isCancelled = true
if (minion.getLocation()
.distanceSquared(event.clickedBlock!!.location) > Config.MAX_LINKING_DISTANCE() * Config.MAX_LINKING_DISTANCE()
) {
event.player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.LINK_FAIL()))
return
}
event.player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.LINK_SUCCESS()))
minion.setLinkedChest(event.clickedBlock!!.location)
}