Use new method

This commit is contained in:
fullwall 2023-03-01 23:05:25 +08:00
parent ef9220b5fd
commit c22916bb70
5 changed files with 9 additions and 0 deletions

View File

@ -452,9 +452,14 @@ public class EventListen implements Listener {
}
if (npc.hasTrait(CommandTrait.class)) {
npc.getTraitNullable(CommandTrait.class).dispatch(player, CommandTrait.Hand.RIGHT);
rightClickEvent.setDelayedCancellation(true);
}
if (npc.hasTrait(ShopTrait.class)) {
npc.getTraitNullable(ShopTrait.class).onRightClick(player);
rightClickEvent.setDelayedCancellation(true);
}
if (rightClickEvent.isDelayedCancellation()) {
event.setCancelled(true);
}
}

View File

@ -106,6 +106,7 @@ public class NPCSelector implements Listener, net.citizensnpcs.api.npc.NPCSelect
player.removeMetadata("selected", plugin);
select(player, npc);
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), npc);
event.setDelayedCancellation(true);
}
}
}

View File

@ -188,6 +188,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
if (!enabled || !npc.isSpawned() || !event.getNPC().equals(npc))
return;
controller.rightClickEntity(event);
event.setDelayedCancellation(true);
}
@Override

View File

@ -28,6 +28,7 @@ public class PausePathfindingTrait extends Trait {
if (!rightclick || event.getNPC() != npc)
return;
pause();
event.setDelayedCancellation(true);
}
private void pause() {

View File

@ -156,6 +156,7 @@ public class Text extends Trait implements Runnable, Listener {
String localPattern = itemInHandPattern.equals("default") ? Setting.TALK_ITEM.asString() : itemInHandPattern;
if (Util.matchesItemInHand(event.getClicker(), localPattern) && !shouldTalkClose()) {
talk(event.getClicker());
event.setDelayedCancellation(true);
}
}