diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 6e410767c..8a49f4d01 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -711,6 +711,7 @@ public class NPCCommands { msg += " as a baby"; npc.getOrAddTrait(Age.class).setAge(-24000); } + if (args.hasFlag('s')) { npc.data().set(NPC.Metadata.SILENT, true); } @@ -2099,50 +2100,53 @@ public class NPCCommands { @Command( aliases = { "npc" }, - usage = "playerfilter --hide [uuid] --unhide [uuid] --only [uuid] --hidegroup [group] --unhidegroup [group] --onlygroup [group] -c(lear)", + usage = "playerfilter -a(llowlist) -e(mpty) -d(enylist) --add [uuid] --remove [uuid] --addgroup [group] --removegroup [group] -c(lear)", desc = "Sets the NPC filter", modifiers = { "playerfilter" }, min = 1, max = 1, - flags = "c", + flags = "adce", permission = "citizens.npc.playerfilter") - public void playerfilter(CommandContext args, CommandSender sender, NPC npc, @Flag("hide") UUID hide, - @Flag("unhide") UUID unhide, @Flag("only") UUID only, @Flag("hidegroup") String hidegroup, - @Flag("unhidegroup") String unhidegroup, @Flag("onlygroup") String onlygroup) { + public void playerfilter(CommandContext args, CommandSender sender, NPC npc, @Flag("add") UUID add, + @Flag("remove") UUID remove, @Flag("removegroup") String removegroup, @Flag("addgroup") String addgroup) { PlayerFilter trait = npc.getOrAddTrait(PlayerFilter.class); - if (hide != null) { - trait.hide(hide); - Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_HIDDEN, hide, npc.getName()); + if (add != null) { + trait.addPlayer(add); + Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_ADDED, add, npc.getName()); } - if (unhide != null) { - trait.unhide(unhide); - Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_UNHIDDEN, unhide, npc.getName()); + if (remove != null) { + trait.removePlayer(remove); + Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_REMOVED, remove, npc.getName()); } - if (only != null) { - trait.only(only); - Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_ONLY_ADDED, only, npc.getName()); + if (addgroup != null) { + trait.addGroup(addgroup); + Messaging.sendTr(sender, Messages.PLAYERFILTER_GROUP_ADDED, addgroup, npc.getName()); } - if (hidegroup != null) { - trait.hideGroup(hidegroup); - Messaging.sendTr(sender, Messages.PLAYERFILTER_GROUP_HIDDEN, hidegroup, npc.getName()); + if (removegroup != null) { + trait.removeGroup(removegroup); + Messaging.sendTr(sender, Messages.PLAYERFILTER_GROUP_REMOVED, removegroup, npc.getName()); } - if (unhidegroup != null) { - trait.unhideGroup(unhidegroup); - Messaging.sendTr(sender, Messages.PLAYERFILTER_GROUP_UNHIDDEN, unhidegroup, npc.getName()); + if (args.hasFlag('e')) { + trait.setPlayers(Collections.emptySet()); + Messaging.sendTr(sender, Messages.PLAYERFILTER_EMPTY_SET, npc.getName()); } - if (onlygroup != null) { - trait.onlyGroup(onlygroup); - Messaging.sendTr(sender, Messages.PLAYERFILTER_GROUP_ONLY_ADDED, onlygroup, npc.getName()); + if (args.hasFlag('a')) { + trait.setAllowlist(); + Messaging.sendTr(sender, Messages.PLAYERFILTER_ALLOWLIST_SET, npc.getName()); + } + if (args.hasFlag('d')) { + trait.setDenylist(); + Messaging.sendTr(sender, Messages.PLAYERFILTER_DENYLIST_SET, npc.getName()); } if (args.hasFlag('c')) { trait.clear(); - Messaging.sendTr(sender, Messages.PLAYERFILTER_PLAYER_CLEARED, npc.getName()); + Messaging.sendTr(sender, Messages.PLAYERFILTER_CLEARED, npc.getName()); } } @Command( aliases = { "npc" }, - usage = "playerlist (-a,r)", + usage = "playerlist (-a(dd),r(emove))", desc = "Sets whether the NPC is put in the playerlist", modifiers = { "playerlist" }, min = 1, diff --git a/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java b/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java index e43f4939a..d3f342be5 100644 --- a/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/ShopTrait.java @@ -207,6 +207,7 @@ public class ShopTrait extends Trait { evt.setCancelled(true); return; } + if (display == null) { if (copying != null && evt.getCursorNonNull().getType() != Material.AIR && evt.getCursorNonNull().equals(copying.getDisplayItem(null))) { diff --git a/main/src/main/java/net/citizensnpcs/trait/shop/ItemAction.java b/main/src/main/java/net/citizensnpcs/trait/shop/ItemAction.java index 8450728e6..33e7173c7 100644 --- a/main/src/main/java/net/citizensnpcs/trait/shop/ItemAction.java +++ b/main/src/main/java/net/citizensnpcs/trait/shop/ItemAction.java @@ -233,8 +233,8 @@ public class ItemAction extends NPCShopAction { slot.setItemStack(base.items.get(i).clone()); } slot.setClickHandler(event -> { - event.setCancelled(true); event.setCurrentItem(event.getCursorNonNull()); + event.setCancelled(true); }); } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java index 7287c0a76..2aa33c8a1 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java @@ -35,7 +35,7 @@ public class Waypoint implements Locatable { } public Waypoint(Location at) { - location = at; + location = at.clone(); } public void addTrigger(WaypointTrigger trigger) { diff --git a/main/src/main/java/net/citizensnpcs/util/Messages.java b/main/src/main/java/net/citizensnpcs/util/Messages.java index de7530476..f8b49bd90 100644 --- a/main/src/main/java/net/citizensnpcs/util/Messages.java +++ b/main/src/main/java/net/citizensnpcs/util/Messages.java @@ -327,13 +327,14 @@ public class Messages { public static final String PIGLIN_DANCING_SET = "citizens.commands.npc.piglin.dancing-set"; public static final String PIGLIN_DANCING_UNSET = "citizens.commands.npc.piglin.dancing-unset"; public static final String PLAYER_NOT_FOUND_FOR_SPAWN = "citizens.commands.npc.create.no-player-for-spawn"; - public static final String PLAYERFILTER_GROUP_HIDDEN = "citizens.commands.npc.playerfilter.hidden-group"; - public static final String PLAYERFILTER_GROUP_ONLY_ADDED = "citizens.commands.npc.playerfilter.only-added-group"; - public static final String PLAYERFILTER_GROUP_UNHIDDEN = "citizens.commands.npc.playerfilter.unhidden-group"; - public static final String PLAYERFILTER_PLAYER_CLEARED = "citizens.commands.npc.playerfilter.cleared"; - public static final String PLAYERFILTER_PLAYER_HIDDEN = "citizens.commands.npc.playerfilter.hidden"; - public static final String PLAYERFILTER_PLAYER_ONLY_ADDED = "citizens.commands.npc.playerfilter.only-added"; - public static final String PLAYERFILTER_PLAYER_UNHIDDEN = "citizens.commands.npc.playerfilter.unhidden"; + public static final String PLAYERFILTER_ALLOWLIST_SET = "citizens.commands.npc.playerfilter.allowlist-set"; + public static final String PLAYERFILTER_CLEARED = "citizens.commands.npc.playerfilter.cleared"; + public static final String PLAYERFILTER_DENYLIST_SET = "citizens.commands.npc.playerfilter.denylist-set"; + public static final String PLAYERFILTER_EMPTY_SET = "citizens.commands.npc.playerfilter.emptied"; + public static final String PLAYERFILTER_GROUP_ADDED = "citizens.commands.npc.playerfilter.group-added"; + public static final String PLAYERFILTER_GROUP_REMOVED = "citizens.commands.npc.playerfilter.group-removed"; + public static final String PLAYERFILTER_PLAYER_ADDED = "citizens.commands.npc.playerfilter.added"; + public static final String PLAYERFILTER_PLAYER_REMOVED = "citizens.commands.npc.playerfilter.removed"; public static final String POLAR_BEAR_REARING = "citizens.commands.npc.polarbear.rearing-set"; public static final String POLAR_BEAR_STOPPED_REARING = "citizens.commands.npc.polarbear.rearing-unset"; public static final String POSE_ADDED = "citizens.commands.npc.pose.added"; diff --git a/main/src/main/resources/messages_en.properties b/main/src/main/resources/messages_en.properties index 67d323f1e..926bec78f 100644 --- a/main/src/main/resources/messages_en.properties +++ b/main/src/main/resources/messages_en.properties @@ -229,12 +229,13 @@ citizens.commands.npc.painting.art-set=[[{0}]]''s art set to [[{1}]]. citizens.commands.npc.playerlist.added=Added [[{0}]] to the player list. citizens.commands.npc.playerlist.removed=Removed [[{0}]] from the player list. citizens.commands.npc.playerfilter.cleared=[[{0}]]''s filter cleared. -citizens.commands.npc.playerfilter.only-added=[[{0}]] added to the list of players that will be allowed to see [[{1}]]. -citizens.commands.npc.playerfilter.hidden=[[{0}]] added to the list of players hidden from [[{1}]]. -citizens.commands.npc.playerfilter.unhidden=[[{0}]] will now be allowed to see [[{1}]]. -citizens.commands.npc.playerfilter.only-added-group=[[{0}]] added to the list of groups that will be allowed to see [[{1}]]. -citizens.commands.npc.playerfilter.hidden-group=[[{0}]] added to the list of groups hidden from [[{1}]]. -citizens.commands.npc.playerfilter.unhidden-group=[[{0}]] will now be allowed to see [[{1}]]. +citizens.commands.npc.playerfilter.emptied=[[{0}]]''s filter was emptied. +citizens.commands.npc.playerfilter.added=[[{0}]] added to [[{1}]]''s filter players. +citizens.commands.npc.playerfilter.removed=[[{0}]] removed from [[{1}]]''s filter players. +citizens.commands.npc.playerfilter.group-added=[[{0}]] added to [[{1}]]''s filter groups. +citizens.commands.npc.playerfilter.group-removed=[[{0}]] removed from [[{1}]]''s filter players. +citizens.commands.npc.playerfilter.allowlist-set=[[{0}]] filter mode set to allowlist. +citizens.commands.npc.playerfilter.denylist-set=[[{0}]] filter mode set to denylist. citizens.commands.npc.polarbear.rearing-set=[[{0}]] is now rearing. citizens.commands.npc.polarbear.rearing-unset=[[{0}]] is no longer rearing. citizens.commands.npc.pickupitems.set=[[{0}]] will now pickup items.