mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-12-01 13:03:43 +01:00
don't call MinionChestLinkEvent for unlink
This commit is contained in:
parent
d478a3c4eb
commit
05b36a3669
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user