From b9a08d609a267b57f76ecb41ae3a18d4bdaa81fc Mon Sep 17 00:00:00 2001 From: fullwall Date: Fri, 14 Feb 2020 22:48:40 +0800 Subject: [PATCH] Reformat project --- .../citizensnpcs/commands/NPCCommands.java | 686 +++++++++++---- .../citizensnpcs/npc/CitizensNPCRegistry.java | 2 +- .../npc/profile/ProfileFetchResult.java | 6 +- .../net/citizensnpcs/trait/CommandTrait.java | 7 +- .../citizensnpcs/trait/OcelotModifiers.java | 66 +- .../java/net/citizensnpcs/trait/Powered.java | 4 +- .../trait/text/TextStartPrompt.java | 122 +-- .../trait/versioned/CatTrait.java | 108 +-- .../waypoint/LinearWaypointProvider.java | 816 +++++++++--------- .../trait/waypoint/Waypoints.java | 213 ++--- .../main/java/net/citizensnpcs/util/Util.java | 16 +- .../v1_10_R1/entity/CreeperController.java | 3 +- .../v1_8_R3/util/PlayerPathfinderNormal.java | 3 +- 13 files changed, 1198 insertions(+), 854 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index dfa280bb7..cc041839d 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -112,9 +112,16 @@ public class NPCCommands { selector = plugin.getNPCSelector(); } - @Command(aliases = { - "npc" }, usage = "age [age] (-l)", desc = "Set the age of a NPC", help = Messages.COMMAND_AGE_HELP, flags = "l", modifiers = { - "age" }, min = 1, max = 2, permission = "citizens.npc.age") + @Command( + aliases = { "npc" }, + usage = "age [age] (-l)", + desc = "Set the age of a NPC", + help = Messages.COMMAND_AGE_HELP, + flags = "l", + modifiers = { "age" }, + min = 1, + max = 2, + permission = "citizens.npc.age") public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie))) throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName()); @@ -149,9 +156,15 @@ public class NPCCommands { trait.setAge(age); } - @Command(aliases = { - "npc" }, usage = "anchor (--save [name]|--assume [name]|--remove [name]) (-a)(-c)", desc = "Changes/Saves/Lists NPC's location anchor(s)", flags = "ac", modifiers = { - "anchor" }, min = 1, max = 3, permission = "citizens.npc.anchor") + @Command( + aliases = { "npc" }, + usage = "anchor (--save [name]|--assume [name]|--remove [name]) (-a)(-c)", + desc = "Changes/Saves/Lists NPC's location anchor(s)", + flags = "ac", + modifiers = { "anchor" }, + min = 1, + max = 3, + permission = "citizens.npc.anchor") public void anchor(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Anchors trait = npc.getTrait(Anchors.class); if (args.hasValueFlag("save")) { @@ -219,9 +232,13 @@ public class NPCCommands { npc.teleport(args.getSenderLocation(), TeleportCause.COMMAND); } - @Command(aliases = { - "npc" }, usage = "armorstand --visible [visible] --small [small] --gravity [gravity] --arms [arms] --baseplate [baseplate]", desc = "Edit armorstand properties", modifiers = { - "armorstand" }, min = 1, max = 1) + @Command( + aliases = { "npc" }, + usage = "armorstand --visible [visible] --small [small] --gravity [gravity] --arms [arms] --baseplate [baseplate]", + desc = "Edit armorstand properties", + modifiers = { "armorstand" }, + min = 1, + max = 1) @Requirements(selected = true, ownership = true, types = EntityType.ARMOR_STAND) public void armorstand(CommandContext args, CommandSender sender, NPC npc) throws CommandException { ArmorStandTrait trait = npc.getTrait(ArmorStandTrait.class); @@ -242,20 +259,31 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "collidable", desc = "Toggles an NPC's collidability", modifiers = { - "collidable" }, min = 1, max = 1, permission = "citizens.npc.collidable") + @Command( + aliases = { "npc" }, + usage = "collidable", + desc = "Toggles an NPC's collidability", + modifiers = { "collidable" }, + min = 1, + max = 1, + permission = "citizens.npc.collidable") @Requirements(ownership = true, selected = true, types = { EntityType.PLAYER }) public void collidable(CommandContext args, CommandSender sender, NPC npc) throws CommandException { npc.data().setPersistent(NPC.COLLIDABLE_METADATA, !npc.data().get(NPC.COLLIDABLE_METADATA, true)); Messaging.sendTr(sender, - npc.data().get(NPC.COLLIDABLE_METADATA) ? Messages.COLLIDABLE_SET : Messages.COLLIDABLE_UNSET, + npc.data(). get(NPC.COLLIDABLE_METADATA) ? Messages.COLLIDABLE_SET : Messages.COLLIDABLE_UNSET, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "command|cmd (add [command] | remove [id]) (-l[eft]/-r[ight]) (-p[layer] -o[p])", desc = "Controls commands which will be run when clicking on an NPC", modifiers = { - "command", "cmd" }, min = 1, flags = "lrpo", permission = "citizens.npc.command") + @Command( + aliases = { "npc" }, + usage = "command|cmd (add [command] | remove [id]) (-l[eft]/-r[ight]) (-p[layer] -o[p])", + desc = "Controls commands which will be run when clicking on an NPC", + modifiers = { "command", "cmd" }, + min = 1, + flags = "lrpo", + permission = "citizens.npc.command") public void command(CommandContext args, CommandSender sender, NPC npc) throws CommandException { CommandTrait commands = npc.getTrait(CommandTrait.class); if (args.argsLength() == 1) { @@ -281,9 +309,14 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "controllable|control (-m(ount),-y,-n,-o)", desc = "Toggles whether the NPC can be ridden and controlled", modifiers = { - "controllable", "control" }, min = 1, max = 1, flags = "myno") + @Command( + aliases = { "npc" }, + usage = "controllable|control (-m(ount),-y,-n,-o)", + desc = "Toggles whether the NPC can be ridden and controlled", + modifiers = { "controllable", "control" }, + min = 1, + max = 1, + flags = "myno") public void controllable(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if ((npc.isSpawned() && !sender.hasPermission( "citizens.npc.controllable." + npc.getEntity().getType().name().toLowerCase().replace("_", ""))) @@ -307,8 +340,14 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "copy (--name newname)", desc = "Copies an NPC", modifiers = { - "copy" }, min = 1, max = 1, permission = "citizens.npc.copy") + @Command( + aliases = { "npc" }, + usage = "copy (--name newname)", + desc = "Copies an NPC", + modifiers = { "copy" }, + min = 1, + max = 1, + permission = "citizens.npc.copy") public void copy(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String name = args.getFlag("name", npc.getFullName()); NPC copy = npc.clone(); @@ -339,9 +378,14 @@ public class NPCCommands { selector.select(sender, copy); } - @Command(aliases = { - "npc" }, usage = "create [name] ((-b,u) --at (x:y:z:world) --type (type) --trait ('trait1, trait2...') --b (behaviours))", desc = "Create a new NPC", flags = "bu", modifiers = { - "create" }, min = 2, permission = "citizens.npc.create") + @Command( + aliases = { "npc" }, + usage = "create [name] ((-b,u) --at (x:y:z:world) --type (type) --trait ('trait1, trait2...') --b (behaviours))", + desc = "Create a new NPC", + flags = "bu", + modifiers = { "create" }, + min = 2, + permission = "citizens.npc.create") @Requirements public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String name = Colorizer.parseColors(args.getJoinedStrings(1).trim()); @@ -457,8 +501,14 @@ public class NPCCommands { Messaging.send(sender, msg + '.'); } - @Command(aliases = { "npc" }, usage = "despawn (id)", desc = "Despawn a NPC", modifiers = { - "despawn" }, min = 1, max = 2, permission = "citizens.npc.despawn") + @Command( + aliases = { "npc" }, + usage = "despawn (id)", + desc = "Despawn a NPC", + modifiers = { "despawn" }, + min = 1, + max = 2, + permission = "citizens.npc.despawn") @Requirements public void despawn(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException { NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() { @@ -483,11 +533,19 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "flyable (true|false)", desc = "Toggles or sets an NPC's flyable status", modifiers = { - "flyable" }, min = 1, max = 2, permission = "citizens.npc.flyable") - @Requirements(selected = true, ownership = true, excludedTypes = { EntityType.BAT, EntityType.BLAZE, - EntityType.ENDER_DRAGON, EntityType.GHAST, EntityType.WITHER }) + @Command( + aliases = { "npc" }, + usage = "flyable (true|false)", + desc = "Toggles or sets an NPC's flyable status", + modifiers = { "flyable" }, + min = 1, + max = 2, + permission = "citizens.npc.flyable") + @Requirements( + selected = true, + ownership = true, + excludedTypes = { EntityType.BAT, EntityType.BLAZE, EntityType.ENDER_DRAGON, EntityType.GHAST, + EntityType.WITHER }) public void flyable(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean flyable = args.argsLength() == 2 ? args.getString(1).equals("true") : !npc.isFlyable(); npc.setFlyable(flyable); @@ -495,9 +553,15 @@ public class NPCCommands { Messaging.sendTr(sender, flyable ? Messages.FLYABLE_SET : Messages.FLYABLE_UNSET, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "follow (player name) (-p[rotect])", desc = "Toggles NPC following you", flags = "p", modifiers = { - "follow" }, min = 1, max = 2, permission = "citizens.npc.follow") + @Command( + aliases = { "npc" }, + usage = "follow (player name) (-p[rotect])", + desc = "Toggles NPC following you", + flags = "p", + modifiers = { "follow" }, + min = 1, + max = 2, + permission = "citizens.npc.follow") public void follow(CommandContext args, Player sender, NPC npc) throws CommandException { boolean protect = args.hasFlag('p'); String name = sender.getName(); @@ -513,8 +577,14 @@ public class NPCCommands { player.getName()); } - @Command(aliases = { "npc" }, usage = "gamemode [gamemode]", desc = "Changes the gamemode", modifiers = { - "gamemode" }, min = 1, max = 2, permission = "citizens.npc.gamemode") + @Command( + aliases = { "npc" }, + usage = "gamemode [gamemode]", + desc = "Changes the gamemode", + modifiers = { "gamemode" }, + min = 1, + max = 2, + permission = "citizens.npc.gamemode") @Requirements(selected = true, ownership = true, types = { EntityType.PLAYER }) public void gamemode(CommandContext args, CommandSender sender, NPC npc) { Player player = (Player) npc.getEntity(); @@ -541,9 +611,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.GAMEMODE_SET, mode.name().toLowerCase()); } - @Command(aliases = { - "npc" }, usage = "glowing --color [minecraft chat color]", desc = "Toggles an NPC's glowing status", modifiers = { - "glowing" }, min = 1, max = 1, permission = "citizens.npc.glowing") + @Command( + aliases = { "npc" }, + usage = "glowing --color [minecraft chat color]", + desc = "Toggles an NPC's glowing status", + modifiers = { "glowing" }, + min = 1, + max = 1, + permission = "citizens.npc.glowing") @Requirements(selected = true, ownership = true) public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if (args.hasValueFlag("color")) { @@ -560,18 +635,30 @@ public class NPCCommands { Messaging.sendTr(sender, glowing ? Messages.GLOWING_SET : Messages.GLOWING_UNSET, npc.getName()); } - @Command(aliases = { "npc" }, usage = "gravity", desc = "Toggles gravity", modifiers = { - "gravity" }, min = 1, max = 1, permission = "citizens.npc.gravity") + @Command( + aliases = { "npc" }, + usage = "gravity", + desc = "Toggles gravity", + modifiers = { "gravity" }, + min = 1, + max = 1, + permission = "citizens.npc.gravity") public void gravity(CommandContext args, CommandSender sender, NPC npc) { boolean enabled = npc.getTrait(Gravity.class).toggle(); String key = !enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED; Messaging.sendTr(sender, key, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "horse|llama|donkey|mule (--color color) (--type type) (--style style) (-cb)", desc = "Sets horse and horse-like entity modifiers", help = "Use the -c flag to make the NPC have a chest, or the -b flag to stop them from having a chest.", modifiers = { - "horse", "llama", "donkey", - "mule" }, min = 1, max = 1, flags = "cb", permission = "citizens.npc.horse") + @Command( + aliases = { "npc" }, + usage = "horse|llama|donkey|mule (--color color) (--type type) (--style style) (-cb)", + desc = "Sets horse and horse-like entity modifiers", + help = "Use the -c flag to make the NPC have a chest, or the -b flag to stop them from having a chest.", + modifiers = { "horse", "llama", "donkey", "mule" }, + min = 1, + max = 1, + flags = "cb", + permission = "citizens.npc.horse") @Requirements(selected = true, ownership = true) public void horse(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Set allowedTypes = Util.optionalEntitySet("HORSE", "LLAMA", "DONKEY", "MULE", "TRADER_LLAMA"); @@ -616,22 +703,43 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "id", desc = "Sends the selected NPC's ID to the sender", modifiers = { - "id" }, min = 1, max = 1, permission = "citizens.npc.id") + @Command( + aliases = { "npc" }, + usage = "id", + desc = "Sends the selected NPC's ID to the sender", + modifiers = { "id" }, + min = 1, + max = 1, + permission = "citizens.npc.id") public void id(CommandContext args, CommandSender sender, NPC npc) { Messaging.send(sender, npc.getId()); } - @Command(aliases = { "npc" }, usage = "inventory", desc = "Show's an NPC's inventory", modifiers = { - "inventory" }, min = 1, max = 1, permission = "citizens.npc.inventory") + @Command( + aliases = { "npc" }, + usage = "inventory", + desc = "Show's an NPC's inventory", + modifiers = { "inventory" }, + min = 1, + max = 1, + permission = "citizens.npc.inventory") public void inventory(CommandContext args, CommandSender sender, NPC npc) { npc.getTrait(Inventory.class).openInventory((Player) sender); } - @Command(aliases = { "npc" }, usage = "item [item] (data)", desc = "Sets the NPC's item", modifiers = { - "item", }, min = 2, max = 3, flags = "", permission = "citizens.npc.item") - @Requirements(selected = true, ownership = true, types = { EntityType.DROPPED_ITEM, EntityType.ITEM_FRAME, - EntityType.FALLING_BLOCK }) + @Command( + aliases = { "npc" }, + usage = "item [item] (data)", + desc = "Sets the NPC's item", + modifiers = { "item", }, + min = 2, + max = 3, + flags = "", + permission = "citizens.npc.item") + @Requirements( + selected = true, + ownership = true, + types = { EntityType.DROPPED_ITEM, EntityType.ITEM_FRAME, EntityType.FALLING_BLOCK }) public void item(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Material mat = Material.matchMaterial(args.getString(1)); if (mat == null) @@ -640,14 +748,14 @@ public class NPCCommands { npc.data().setPersistent(NPC.ITEM_ID_METADATA, mat.name()); npc.data().setPersistent(NPC.ITEM_DATA_METADATA, data); switch (npc.getEntity().getType()) { - case DROPPED_ITEM: - ((org.bukkit.entity.Item) npc.getEntity()).getItemStack().setType(mat); - break; - case ITEM_FRAME: - ((ItemFrame) npc.getEntity()).getItem().setType(mat); - break; - default: - break; + case DROPPED_ITEM: + ((org.bukkit.entity.Item) npc.getEntity()).getItemStack().setType(mat); + break; + case ITEM_FRAME: + ((ItemFrame) npc.getEntity()).getItem().setType(mat); + break; + default: + break; } if (npc.isSpawned()) { npc.despawn(DespawnReason.PENDING_RESPAWN); @@ -656,8 +764,15 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.ITEM_SET, Util.prettyEnum(mat)); } - @Command(aliases = { "npc" }, usage = "leashable", desc = "Toggles leashability", modifiers = { - "leashable" }, min = 1, max = 1, flags = "t", permission = "citizens.npc.leashable") + @Command( + aliases = { "npc" }, + usage = "leashable", + desc = "Toggles leashability", + modifiers = { "leashable" }, + min = 1, + max = 1, + flags = "t", + permission = "citizens.npc.leashable") public void leashable(CommandContext args, CommandSender sender, NPC npc) { boolean vulnerable = !npc.data().get(NPC.LEASH_PROTECTED_METADATA, true); if (args.hasFlag('t')) { @@ -669,9 +784,15 @@ public class NPCCommands { Messaging.sendTr(sender, key, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "list (page) ((-a) --owner (owner) --type (type) --char (char) --registry (name))", desc = "List NPCs", flags = "a", modifiers = { - "list" }, min = 1, max = 2, permission = "citizens.npc.list") + @Command( + aliases = { "npc" }, + usage = "list (page) ((-a) --owner (owner) --type (type) --char (char) --registry (name))", + desc = "List NPCs", + flags = "a", + modifiers = { "list" }, + min = 1, + max = 2, + permission = "citizens.npc.list") @Requirements public void list(CommandContext args, CommandSender sender, NPC npc) throws CommandException { NPCRegistry source = args.hasValueFlag("registry") ? CitizensAPI.getNamedNPCRegistry(args.getFlag("registry")) @@ -727,9 +848,14 @@ public class NPCCommands { throw new CommandException(Messages.COMMAND_PAGE_MISSING); } - @Command(aliases = { - "npc" }, usage = "lookclose --(random|r)look [true|false] --(random|r)pitchrange [min,max] --(random|r)yawrange [min,max]", desc = "Toggle whether a NPC will look when a player is near", modifiers = { - "lookclose", "look", "rotate" }, min = 1, max = 1, permission = "citizens.npc.lookclose") + @Command( + aliases = { "npc" }, + usage = "lookclose --(random|r)look [true|false] --(random|r)pitchrange [min,max] --(random|r)yawrange [min,max]", + desc = "Toggle whether a NPC will look when a player is near", + modifiers = { "lookclose", "look", "rotate" }, + min = 1, + max = 1, + permission = "citizens.npc.lookclose") public void lookClose(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean toggle = true; if (args.hasAnyValueFlag("randomlook", "rlook")) { @@ -782,9 +908,15 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "metadata set|get|remove [key] (value) (-t(emporary))", desc = "Manages NPC metadata", modifiers = { - "metadata" }, flags = "t", min = 2, max = 4, permission = "citizens.npc.metadata") + @Command( + aliases = { "npc" }, + usage = "metadata set|get|remove [key] (value) (-t(emporary))", + desc = "Manages NPC metadata", + modifiers = { "metadata" }, + flags = "t", + min = 2, + max = 4, + permission = "citizens.npc.metadata") @Requirements(selected = true, ownership = true) public void metadata(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String command = args.getString(1).toLowerCase(); @@ -811,12 +943,21 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "minecart (--item item_name(:data)) (--offset offset)", desc = "Sets minecart item", modifiers = { - "minecart" }, min = 1, max = 1, flags = "", permission = "citizens.npc.minecart") - @Requirements(selected = true, ownership = true, types = { EntityType.MINECART, EntityType.MINECART_CHEST, - EntityType.MINECART_COMMAND, EntityType.MINECART_FURNACE, EntityType.MINECART_HOPPER, - EntityType.MINECART_MOB_SPAWNER, EntityType.MINECART_TNT }) + @Command( + aliases = { "npc" }, + usage = "minecart (--item item_name(:data)) (--offset offset)", + desc = "Sets minecart item", + modifiers = { "minecart" }, + min = 1, + max = 1, + flags = "", + permission = "citizens.npc.minecart") + @Requirements( + selected = true, + ownership = true, + types = { EntityType.MINECART, EntityType.MINECART_CHEST, EntityType.MINECART_COMMAND, + EntityType.MINECART_FURNACE, EntityType.MINECART_HOPPER, EntityType.MINECART_MOB_SPAWNER, + EntityType.MINECART_TNT }) public void minecart(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if (args.hasValueFlag("item")) { String raw = args.getFlag("item"); @@ -840,9 +981,15 @@ public class NPCCommands { npc.data().get(NPC.MINECART_ITEM_DATA_METADATA, 0), npc.data().get(NPC.MINECART_OFFSET_METADATA, 0)); } - @Command(aliases = { - "npc" }, usage = "mount (--onnpc ) (-c (ancel))", desc = "Mounts a controllable NPC", modifiers = { - "mount" }, min = 1, max = 1, flags = "c", permission = "citizens.npc.mount") + @Command( + aliases = { "npc" }, + usage = "mount (--onnpc ) (-c (ancel))", + desc = "Mounts a controllable NPC", + modifiers = { "mount" }, + min = 1, + max = 1, + flags = "c", + permission = "citizens.npc.mount") public void mount(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if (args.hasValueFlag("onnpc")) { NPC mount; @@ -879,8 +1026,13 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "moveto x:y:z:world | x y z world", desc = "Teleports a NPC to a given location", modifiers = "moveto", min = 1, permission = "citizens.npc.moveto") + @Command( + aliases = { "npc" }, + usage = "moveto x:y:z:world | x y z world", + desc = "Teleports a NPC to a given location", + modifiers = "moveto", + min = 1, + permission = "citizens.npc.moveto") public void moveto(CommandContext args, CommandSender sender, NPC npc) throws CommandException { // Spawn the NPC if it isn't spawned to prevent NPEs if (!npc.isSpawned()) { @@ -927,11 +1079,18 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.MOVETO_TELEPORTED, npc.getName(), to); } - @Command(aliases = { "npc" }, modifiers = { - "name" }, usage = "name", desc = "Toggle nameplate visibility", min = 1, max = 1, flags = "h", permission = "citizens.npc.name") + @Command( + aliases = { "npc" }, + modifiers = { "name" }, + usage = "name", + desc = "Toggle nameplate visibility", + min = 1, + max = 1, + flags = "h", + permission = "citizens.npc.name") @Requirements(selected = true, ownership = true, livingEntity = true) public void name(CommandContext args, CommandSender sender, NPC npc) { - String old = npc.data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); + String old = npc.data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); if (args.hasFlag('h')) { old = "hover"; } else { @@ -961,9 +1120,16 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "ocelot (--type type) (-s(itting), -n(ot sitting))", desc = "Set the ocelot type of an NPC and whether it is sitting", modifiers = { - "ocelot" }, min = 1, max = 1, requiresFlags = true, flags = "sn", permission = "citizens.npc.ocelot") + @Command( + aliases = { "npc" }, + usage = "ocelot (--type type) (-s(itting), -n(ot sitting))", + desc = "Set the ocelot type of an NPC and whether it is sitting", + modifiers = { "ocelot" }, + min = 1, + max = 1, + requiresFlags = true, + flags = "sn", + permission = "citizens.npc.ocelot") @Requirements(selected = true, ownership = true, types = { EntityType.OCELOT }) public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws CommandException { OcelotModifiers trait = npc.getTrait(OcelotModifiers.class); @@ -982,8 +1148,14 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "owner [name]", desc = "Set the owner of an NPC", modifiers = { - "owner" }, min = 1, max = 2, permission = "citizens.npc.owner") + @Command( + aliases = { "npc" }, + usage = "owner [name]", + desc = "Set the owner of an NPC", + modifiers = { "owner" }, + min = 1, + max = 2, + permission = "citizens.npc.owner") public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Owner ownerTrait = npc.getTrait(Owner.class); if (args.argsLength() == 1) { @@ -998,9 +1170,14 @@ public class NPCCommands { Messaging.sendTr(sender, serverOwner ? Messages.OWNER_SET_SERVER : Messages.OWNER_SET, npc.getName(), name); } - @Command(aliases = { - "npc" }, usage = "passive (--set [true|false])", desc = "Sets whether an NPC damages other entities or not", modifiers = { - "passive" }, min = 1, max = 1, permission = "citizens.npc.passive") + @Command( + aliases = { "npc" }, + usage = "passive (--set [true|false])", + desc = "Sets whether an NPC damages other entities or not", + modifiers = { "passive" }, + min = 1, + max = 1, + permission = "citizens.npc.passive") public void passive(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean passive = args.hasValueFlag("set") ? Boolean.parseBoolean(args.getFlag("set")) : npc.data().get(NPC.DAMAGE_OTHERS_METADATA, true); @@ -1008,9 +1185,14 @@ public class NPCCommands { Messaging.sendTr(sender, passive ? Messages.PASSIVE_SET : Messages.PASSIVE_UNSET, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "pathopt --avoid-water|aw [true|false] --stationary-ticks [ticks] --attack-range [range] --distance-margin [margin] --path-distance-margin [margin]", desc = "Sets an NPC's pathfinding options", modifiers = { - "pathopt", "po", "patho" }, min = 1, max = 1, permission = "citizens.npc.pathfindingoptions") + @Command( + aliases = { "npc" }, + usage = "pathopt --avoid-water|aw [true|false] --stationary-ticks [ticks] --attack-range [range] --distance-margin [margin] --path-distance-margin [margin]", + desc = "Sets an NPC's pathfinding options", + modifiers = { "pathopt", "po", "patho" }, + min = 1, + max = 1, + permission = "citizens.npc.pathfindingoptions") public void pathfindingOptions(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean found = false; if (args.hasValueFlag("avoid-water") || args.hasValueFlag("aw")) { @@ -1058,17 +1240,29 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "pathrange [range]", desc = "Sets an NPC's pathfinding range", modifiers = { - "pathrange", "pathfindingrange", "prange" }, min = 2, max = 2, permission = "citizens.npc.pathfindingrange") + @Command( + aliases = { "npc" }, + usage = "pathrange [range]", + desc = "Sets an NPC's pathfinding range", + modifiers = { "pathrange", "pathfindingrange", "prange" }, + min = 2, + max = 2, + permission = "citizens.npc.pathfindingrange") public void pathfindingRange(CommandContext args, CommandSender sender, NPC npc) { double range = Math.max(1, args.getDouble(1)); npc.getNavigator().getDefaultParameters().range((float) range); Messaging.sendTr(sender, Messages.PATHFINDING_RANGE_SET, range); } - @Command(aliases = { - "npc" }, usage = "playerlist (-a,r)", desc = "Sets whether the NPC is put in the playerlist", modifiers = { - "playerlist" }, min = 1, max = 1, flags = "ar", permission = "citizens.npc.playerlist") + @Command( + aliases = { "npc" }, + usage = "playerlist (-a,r)", + desc = "Sets whether the NPC is put in the playerlist", + modifiers = { "playerlist" }, + min = 1, + max = 1, + flags = "ar", + permission = "citizens.npc.playerlist") @Requirements(selected = true, ownership = true, types = EntityType.PLAYER) public void playerlist(CommandContext args, CommandSender sender, NPC npc) { boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()); @@ -1087,9 +1281,15 @@ public class NPCCommands { npc.getName()); } - @Command(aliases = { - "npc" }, usage = "pose (--save [name]|--assume [name]|--remove [name]) (-a)", desc = "Changes/Saves/Lists NPC's head pose(s)", flags = "a", modifiers = { - "pose" }, min = 1, max = 2, permission = "citizens.npc.pose") + @Command( + aliases = { "npc" }, + usage = "pose (--save [name]|--assume [name]|--remove [name]) (-a)", + desc = "Changes/Saves/Lists NPC's head pose(s)", + flags = "a", + modifiers = { "pose" }, + min = 1, + max = 2, + permission = "citizens.npc.pose") public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Poses trait = npc.getTrait(Poses.class); if (args.hasValueFlag("save")) { @@ -1131,16 +1331,28 @@ public class NPCCommands { trait.assumePose(location); } - @Command(aliases = { "npc" }, usage = "power", desc = "Toggle a creeper NPC as powered", modifiers = { - "power" }, min = 1, max = 1, permission = "citizens.npc.power") + @Command( + aliases = { "npc" }, + usage = "power", + desc = "Toggle a creeper NPC as powered", + modifiers = { "power" }, + min = 1, + max = 1, + permission = "citizens.npc.power") @Requirements(selected = true, ownership = true, types = { EntityType.CREEPER }) public void power(CommandContext args, CommandSender sender, NPC npc) { Messaging.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED); } - @Command(aliases = { "npc" }, usage = "profession|prof [profession]", desc = "Set a NPC's profession", modifiers = { - "profession", "prof" }, min = 2, max = 2, permission = "citizens.npc.profession") + @Command( + aliases = { "npc" }, + usage = "profession|prof [profession]", + desc = "Set a NPC's profession", + modifiers = { "profession", "prof" }, + min = 2, + max = 2, + permission = "citizens.npc.profession") @Requirements(selected = true, ownership = true) public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException { EntityType type = npc.getTrait(MobType.class).getType(); @@ -1158,8 +1370,13 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession); } - @Command(aliases = { "npc" }, usage = "rabbittype [type]", desc = "Set the Type of a Rabbit NPC", modifiers = { - "rabbittype", "rbtype" }, min = 2, permission = "citizens.npc.rabbittype") + @Command( + aliases = { "npc" }, + usage = "rabbittype [type]", + desc = "Set the Type of a Rabbit NPC", + modifiers = { "rabbittype", "rbtype" }, + min = 2, + permission = "citizens.npc.rabbittype") @Requirements(selected = true, ownership = true, types = { EntityType.RABBIT }) public void rabbitType(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Rabbit.Type type; @@ -1172,9 +1389,13 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name()); } - @Command(aliases = { - "npc" }, usage = "remove|rem (all|id|name|--owner [owner])", desc = "Remove a NPC", modifiers = { "remove", - "rem" }, min = 1, max = 2) + @Command( + aliases = { "npc" }, + usage = "remove|rem (all|id|name|--owner [owner])", + desc = "Remove a NPC", + modifiers = { "remove", "rem" }, + min = 1, + max = 2) @Requirements public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException { if (args.hasValueFlag("owner")) { @@ -1224,8 +1445,13 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.NPC_REMOVED, npc.getName()); } - @Command(aliases = { "npc" }, usage = "rename [name]", desc = "Rename a NPC", modifiers = { - "rename" }, min = 2, permission = "citizens.npc.rename") + @Command( + aliases = { "npc" }, + usage = "rename [name]", + desc = "Rename a NPC", + modifiers = { "rename" }, + min = 2, + permission = "citizens.npc.rename") public void rename(CommandContext args, CommandSender sender, NPC npc) { String oldName = npc.getName(); String newName = Colorizer.parseColors(args.getJoinedStrings(1)); @@ -1244,9 +1470,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.NPC_RENAMED, oldName, newName); } - @Command(aliases = { - "npc" }, usage = "respawn [delay in ticks]", desc = "Sets an NPC's respawn delay in ticks", modifiers = { - "respawn" }, min = 1, max = 2, permission = "citizens.npc.respawn") + @Command( + aliases = { "npc" }, + usage = "respawn [delay in ticks]", + desc = "Sets an NPC's respawn delay in ticks", + modifiers = { "respawn" }, + min = 1, + max = 2, + permission = "citizens.npc.respawn") public void respawn(CommandContext args, CommandSender sender, NPC npc) { if (args.argsLength() > 1) { int delay = args.getInteger(1); @@ -1257,9 +1488,14 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "scoreboard --addtag [tags] --removetag [tags]", desc = "Controls an NPC's scoreboard", modifiers = { - "scoreboard" }, min = 1, max = 1, permission = "citizens.npc.scoreboard") + @Command( + aliases = { "npc" }, + usage = "scoreboard --addtag [tags] --removetag [tags]", + desc = "Controls an NPC's scoreboard", + modifiers = { "scoreboard" }, + min = 1, + max = 1, + permission = "citizens.npc.scoreboard") public void scoreboard(CommandContext args, CommandSender sender, NPC npc) { ScoreboardTrait trait = npc.getTrait(ScoreboardTrait.class); String output = ""; @@ -1280,9 +1516,14 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "script --add [files] --remove [files]", desc = "Controls an NPC's scripts", modifiers = { - "script" }, min = 1, max = 1, permission = "citizens.npc.script") + @Command( + aliases = { "npc" }, + usage = "script --add [files] --remove [files]", + desc = "Controls an NPC's scripts", + modifiers = { "script" }, + min = 1, + max = 1, + permission = "citizens.npc.script") public void script(CommandContext args, CommandSender sender, NPC npc) { ScriptTrait trait = npc.getTrait(ScriptTrait.class); if (args.hasValueFlag("add")) { @@ -1302,9 +1543,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.CURRENT_SCRIPTS, npc.getName(), Joiner.on("]],[[ ").join(trait.getScripts())); } - @Command(aliases = { - "npc" }, usage = "select|sel [id|name] (--r range)", desc = "Select a NPC with the given ID or name", modifiers = { - "select", "sel" }, min = 1, max = 2, permission = "citizens.npc.select") + @Command( + aliases = { "npc" }, + usage = "select|sel [id|name] (--r range)", + desc = "Select a NPC with the given ID or name", + modifiers = { "select", "sel" }, + min = 1, + max = 2, + permission = "citizens.npc.select") @Requirements public void select(CommandContext args, final CommandSender sender, final NPC npc) throws CommandException { NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() { @@ -1345,9 +1591,14 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "sheep (--color [color]) (--sheared [sheared])", desc = "Sets sheep modifiers", modifiers = { - "sheep" }, min = 1, max = 1, permission = "citizens.npc.sheep") + @Command( + aliases = { "npc" }, + usage = "sheep (--color [color]) (--sheared [sheared])", + desc = "Sets sheep modifiers", + modifiers = { "sheep" }, + min = 1, + max = 1, + permission = "citizens.npc.sheep") @Requirements(selected = true, ownership = true, types = { EntityType.SHEEP }) public void sheep(CommandContext args, CommandSender sender, NPC npc) throws CommandException { SheepTrait trait = npc.getTrait(SheepTrait.class); @@ -1371,9 +1622,15 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "skin (-c -l(atest)) [name] (or -t [uuid/name] [data] [signature])", desc = "Sets an NPC's skin name. Use -l to set the skin to always update to the latest", modifiers = { - "skin" }, min = 1, max = 4, flags = "ctl", permission = "citizens.npc.skin") + @Command( + aliases = { "npc" }, + usage = "skin (-c -l(atest)) [name] (or -t [uuid/name] [data] [signature])", + desc = "Sets an NPC's skin name. Use -l to set the skin to always update to the latest", + modifiers = { "skin" }, + min = 1, + max = 4, + flags = "ctl", + permission = "citizens.npc.skin") @Requirements(types = EntityType.PLAYER, selected = true, ownership = true) public void skin(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException { String skinName = npc.getName(); @@ -1409,9 +1666,14 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "skinlayers (--cape [true|false]) (--hat [true|false]) (--jacket [true|false]) (--sleeves [true|false]) (--pants [true|false])", desc = "Sets an NPC's skin layers visibility.", modifiers = { - "skinlayers" }, min = 1, max = 5, permission = "citizens.npc.skinlayers") + @Command( + aliases = { "npc" }, + usage = "skinlayers (--cape [true|false]) (--hat [true|false]) (--jacket [true|false]) (--sleeves [true|false]) (--pants [true|false])", + desc = "Sets an NPC's skin layers visibility.", + modifiers = { "skinlayers" }, + min = 1, + max = 5, + permission = "citizens.npc.skinlayers") @Requirements(types = EntityType.PLAYER, selected = true, ownership = true) public void skinLayers(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException { @@ -1441,8 +1703,14 @@ public class NPCCommands { trait.isVisible(Layer.LEFT_PANTS) || trait.isVisible(Layer.RIGHT_PANTS)); } - @Command(aliases = { "npc" }, usage = "size [size]", desc = "Sets the NPC's size", modifiers = { - "size" }, min = 1, max = 2, permission = "citizens.npc.size") + @Command( + aliases = { "npc" }, + usage = "size [size]", + desc = "Sets the NPC's size", + modifiers = { "size" }, + min = 1, + max = 2, + permission = "citizens.npc.size") @Requirements(selected = true, ownership = true, types = { EntityType.MAGMA_CUBE, EntityType.SLIME }) public void slimeSize(CommandContext args, CommandSender sender, NPC npc) { SlimeSize trait = npc.getTrait(SlimeSize.class); @@ -1455,9 +1723,15 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.SIZE_SET, npc.getName(), size); } - @Command(aliases = { - "npc" }, usage = "sound (--death [death sound|d]) (--ambient [ambient sound|d]) (--hurt [hurt sound|d]) (-n(one)) (-d(efault))", desc = "Sets an NPC's played sounds", modifiers = { - "sound" }, flags = "dns", min = 1, max = 1, permission = "citizens.npc.sound") + @Command( + aliases = { "npc" }, + usage = "sound (--death [death sound|d]) (--ambient [ambient sound|d]) (--hurt [hurt sound|d]) (-n(one)) (-d(efault))", + desc = "Sets an NPC's played sounds", + modifiers = { "sound" }, + flags = "dns", + min = 1, + max = 1, + permission = "citizens.npc.sound") @Requirements(selected = true, ownership = true, livingEntity = true, excludedTypes = { EntityType.PLAYER }) public void sound(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String ambientSound = npc.data().get(NPC.AMBIENT_SOUND_METADATA); @@ -1518,9 +1792,15 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.SOUND_SET, npc.getName(), ambientSound, hurtSound, deathSound); } - @Command(aliases = { - "npc" }, usage = "spawn (id|name) -l(oad chunks)", desc = "Spawn an existing NPC", modifiers = { - "spawn" }, min = 1, max = 2, flags = "l", permission = "citizens.npc.spawn") + @Command( + aliases = { "npc" }, + usage = "spawn (id|name) -l(oad chunks)", + desc = "Spawn an existing NPC", + modifiers = { "spawn" }, + min = 1, + max = 2, + flags = "l", + permission = "citizens.npc.spawn") @Requirements(ownership = true) public void spawn(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException { NPCCommandSelector.Callback callback = new NPCCommandSelector.Callback() { @@ -1560,9 +1840,13 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "speak message to speak --target npcid|player_name --type vocal_type", desc = "Uses the NPCs SpeechController to talk", modifiers = { - "speak" }, min = 2, permission = "citizens.npc.speak") + @Command( + aliases = { "npc" }, + usage = "speak message to speak --target npcid|player_name --type vocal_type", + desc = "Uses the NPCs SpeechController to talk", + modifiers = { "speak" }, + min = 2, + permission = "citizens.npc.speak") public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException { String type = npc.getTrait(Speech.class).getDefaultVocalChord(); String message = Colorizer.parseColors(args.getJoinedStrings(1)); @@ -1596,9 +1880,14 @@ public class NPCCommands { npc.getDefaultSpeechController().speak(context, type); } - @Command(aliases = { - "npc" }, usage = "speed [speed]", desc = "Sets the movement speed of an NPC as a percentage", modifiers = { - "speed" }, min = 2, max = 2, permission = "citizens.npc.speed") + @Command( + aliases = { "npc" }, + usage = "speed [speed]", + desc = "Sets the movement speed of an NPC as a percentage", + modifiers = { "speed" }, + min = 2, + max = 2, + permission = "citizens.npc.speed") public void speed(CommandContext args, CommandSender sender, NPC npc) throws CommandException { float newSpeed = (float) Math.abs(args.getDouble(1)); if (newSpeed >= Setting.MAX_SPEED.asDouble()) @@ -1608,9 +1897,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.SPEED_MODIFIER_SET, newSpeed); } - @Command(aliases = { - "npc" }, usage = "swim (--set [true|false])", desc = "Sets an NPC to swim or not", modifiers = { - "swim" }, min = 1, max = 1, permission = "citizens.npc.swim") + @Command( + aliases = { "npc" }, + usage = "swim (--set [true|false])", + desc = "Sets an NPC to swim or not", + modifiers = { "swim" }, + min = 1, + max = 1, + permission = "citizens.npc.swim") public void swim(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean swim = args.hasValueFlag("set") ? Boolean.parseBoolean(args.getFlag("set")) : !npc.data().get(NPC.SWIMMING_METADATA, true); @@ -1618,8 +1912,14 @@ public class NPCCommands { Messaging.sendTr(sender, swim ? Messages.SWIMMING_SET : Messages.SWIMMING_UNSET, npc.getName()); } - @Command(aliases = { "npc" }, usage = "targetable", desc = "Toggles an NPC's targetability", modifiers = { - "targetable" }, min = 1, max = 1, permission = "citizens.npc.targetable") + @Command( + aliases = { "npc" }, + usage = "targetable", + desc = "Toggles an NPC's targetability", + modifiers = { "targetable" }, + min = 1, + max = 1, + permission = "citizens.npc.targetable") public void targetable(CommandContext args, CommandSender sender, NPC npc) { boolean targetable = !npc.data().get(NPC.TARGETABLE_METADATA, npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)); @@ -1631,8 +1931,14 @@ public class NPCCommands { Messaging.sendTr(sender, targetable ? Messages.TARGETABLE_SET : Messages.TARGETABLE_UNSET, npc.getName()); } - @Command(aliases = { "npc" }, usage = "tp", desc = "Teleport to a NPC", modifiers = { "tp", - "teleport" }, min = 1, max = 1, permission = "citizens.npc.tp") + @Command( + aliases = { "npc" }, + usage = "tp", + desc = "Teleport to a NPC", + modifiers = { "tp", "teleport" }, + min = 1, + max = 1, + permission = "citizens.npc.tp") public void tp(CommandContext args, Player player, NPC npc) { Location to = npc.getTrait(CurrentLocation.class).getLocation(); if (to == null) { @@ -1643,8 +1949,14 @@ public class NPCCommands { Messaging.sendTr(player, Messages.TELEPORTED_TO_NPC, npc.getName()); } - @Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = { "tphere", - "tph", "move" }, min = 1, max = 1, permission = "citizens.npc.tphere") + @Command( + aliases = { "npc" }, + usage = "tphere", + desc = "Teleport a NPC to your location", + modifiers = { "tphere", "tph", "move" }, + min = 1, + max = 1, + permission = "citizens.npc.tphere") public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException { if (args.getSenderLocation() == null) throw new ServerCommandException(); @@ -1667,9 +1979,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName()); } - @Command(aliases = { - "npc" }, usage = "tpto [player name|npc id] [player name|npc id]", desc = "Teleport an NPC or player to another NPC or player", modifiers = { - "tpto" }, min = 2, max = 3, permission = "citizens.npc.tpto") + @Command( + aliases = { "npc" }, + usage = "tpto [player name|npc id] [player name|npc id]", + desc = "Teleport an NPC or player to another NPC or player", + modifiers = { "tpto" }, + min = 2, + max = 3, + permission = "citizens.npc.tpto") @Requirements public void tpto(CommandContext args, CommandSender sender, NPC npc) throws CommandException { Entity from = null, to = null; @@ -1716,8 +2033,14 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.TPTO_SUCCESS); } - @Command(aliases = { "npc" }, usage = "type [type]", desc = "Sets an NPC's entity type", modifiers = { - "type" }, min = 2, max = 2, permission = "citizens.npc.type") + @Command( + aliases = { "npc" }, + usage = "type [type]", + desc = "Sets an NPC's entity type", + modifiers = { "type" }, + min = 2, + max = 2, + permission = "citizens.npc.type") public void type(CommandContext args, CommandSender sender, NPC npc) throws CommandException { EntityType type = Util.matchEntityType(args.getString(1)); if (type == null) @@ -1726,8 +2049,15 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.ENTITY_TYPE_SET, npc.getName(), args.getString(1)); } - @Command(aliases = { "npc" }, usage = "vulnerable (-t)", desc = "Toggles an NPC's vulnerability", modifiers = { - "vulnerable" }, min = 1, max = 1, flags = "t", permission = "citizens.npc.vulnerable") + @Command( + aliases = { "npc" }, + usage = "vulnerable (-t)", + desc = "Toggles an NPC's vulnerability", + modifiers = { "vulnerable" }, + min = 1, + max = 1, + flags = "t", + permission = "citizens.npc.vulnerable") public void vulnerable(CommandContext args, CommandSender sender, NPC npc) { boolean vulnerable = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true); if (args.hasFlag('t')) { @@ -1739,8 +2069,15 @@ public class NPCCommands { Messaging.sendTr(sender, key, npc.getName()); } - @Command(aliases = { "npc" }, usage = "wither (--charged [charged])", desc = "Sets wither modifiers", modifiers = { - "wither" }, min = 1, requiresFlags = true, max = 1, permission = "citizens.npc.wither") + @Command( + aliases = { "npc" }, + usage = "wither (--charged [charged])", + desc = "Sets wither modifiers", + modifiers = { "wither" }, + min = 1, + requiresFlags = true, + max = 1, + permission = "citizens.npc.wither") @Requirements(selected = true, ownership = true, types = { EntityType.WITHER }) public void wither(CommandContext args, CommandSender sender, NPC npc) throws CommandException { WitherTrait trait = npc.getTrait(WitherTrait.class); @@ -1749,9 +2086,16 @@ public class NPCCommands { } } - @Command(aliases = { - "npc" }, usage = "wolf (-s(itting) a(ngry) t(amed) i(nfo)) --collar [hex rgb color|name]", desc = "Sets wolf modifiers", modifiers = { - "wolf" }, min = 1, max = 1, requiresFlags = true, flags = "sati", permission = "citizens.npc.wolf") + @Command( + aliases = { "npc" }, + usage = "wolf (-s(itting) a(ngry) t(amed) i(nfo)) --collar [hex rgb color|name]", + desc = "Sets wolf modifiers", + modifiers = { "wolf" }, + min = 1, + max = 1, + requiresFlags = true, + flags = "sati", + permission = "citizens.npc.wolf") @Requirements(selected = true, ownership = true, types = EntityType.WOLF) public void wolf(CommandContext args, CommandSender sender, NPC npc) throws CommandException { WolfModifiers trait = npc.getTrait(WolfModifiers.class); diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java b/main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java index 4ce003357..df0eaf632 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java @@ -82,7 +82,7 @@ public class CitizensNPCRegistry implements NPCRegistry { for (Trait t : npc.getTraits()) { HandlerList.unregisterAll(t); t.onRemove(); - } + } itr.remove(); if (saves != null) { saves.clearData(npc); diff --git a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchResult.java b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchResult.java index 5197a04d7..be70c648d 100644 --- a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchResult.java +++ b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchResult.java @@ -17,13 +17,11 @@ public enum ProfileFetchResult { */ FAILED, /** - * The profile request failed because the profile - * was not found. + * The profile request failed because the profile was not found. */ NOT_FOUND, /** - * The profile request failed because too many requests - * were sent. + * The profile request failed because too many requests were sent. */ TOO_MANY_REQUESTS } diff --git a/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java b/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java index d6b16c513..0526f4bea 100644 --- a/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java @@ -38,8 +38,7 @@ public class CommandTrait extends Trait { } /** - * Send a brief description of the current state of the trait to the supplied - * {@link CommandSender}. + * Send a brief description of the current state of the trait to the supplied {@link CommandSender}. */ public void describe(CommandSender sender) { List left = Lists.newArrayList(); @@ -96,7 +95,9 @@ public class CommandTrait extends Trait { } public static enum Hand { - BOTH, LEFT, RIGHT; + BOTH, + LEFT, + RIGHT; } private static class NPCCommand { diff --git a/main/src/main/java/net/citizensnpcs/trait/OcelotModifiers.java b/main/src/main/java/net/citizensnpcs/trait/OcelotModifiers.java index be2ac2bca..fd92199fd 100644 --- a/main/src/main/java/net/citizensnpcs/trait/OcelotModifiers.java +++ b/main/src/main/java/net/citizensnpcs/trait/OcelotModifiers.java @@ -15,42 +15,42 @@ import net.citizensnpcs.util.NMS; */ @TraitName("ocelotmodifiers") public class OcelotModifiers extends Trait { - @Persist("sitting") - private boolean sitting; - @Persist("type") - private Ocelot.Type type = Ocelot.Type.WILD_OCELOT; + @Persist("sitting") + private boolean sitting; + @Persist("type") + private Ocelot.Type type = Ocelot.Type.WILD_OCELOT; - public OcelotModifiers() { - super("ocelotmodifiers"); - } + public OcelotModifiers() { + super("ocelotmodifiers"); + } - @Override - public void onSpawn() { - updateModifiers(); - } + @Override + public void onSpawn() { + updateModifiers(); + } - public void setSitting(boolean sit) { - this.sitting = sit; - updateModifiers(); - } + public void setSitting(boolean sit) { + this.sitting = sit; + updateModifiers(); + } - public void setType(Ocelot.Type type) { - this.type = type; - updateModifiers(); - } + public void setType(Ocelot.Type type) { + this.type = type; + updateModifiers(); + } - private void updateModifiers() { - if (npc.getEntity() instanceof Ocelot) { - Ocelot ocelot = (Ocelot) npc.getEntity(); - try { - ocelot.setCatType(type); - } catch (UnsupportedOperationException ex) { - npc.getTrait(CatTrait.class).setSitting(sitting); - npc.getTrait(CatTrait.class).setType(type); - npc.removeTrait(OcelotModifiers.class); - return; - } - NMS.setSitting(ocelot, sitting); - } - } + private void updateModifiers() { + if (npc.getEntity() instanceof Ocelot) { + Ocelot ocelot = (Ocelot) npc.getEntity(); + try { + ocelot.setCatType(type); + } catch (UnsupportedOperationException ex) { + npc.getTrait(CatTrait.class).setSitting(sitting); + npc.getTrait(CatTrait.class).setType(type); + npc.removeTrait(OcelotModifiers.class); + return; + } + NMS.setSitting(ocelot, sitting); + } + } } diff --git a/main/src/main/java/net/citizensnpcs/trait/Powered.java b/main/src/main/java/net/citizensnpcs/trait/Powered.java index 7d0c8402e..35f6af001 100644 --- a/main/src/main/java/net/citizensnpcs/trait/Powered.java +++ b/main/src/main/java/net/citizensnpcs/trait/Powered.java @@ -26,9 +26,9 @@ public class Powered extends Trait implements Toggleable { ((Creeper) npc.getEntity()).setPowered(powered); } } - + public boolean isPowered() { - return powered; + return powered; } @Override diff --git a/main/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java b/main/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java index 714859d09..e83e18c15 100644 --- a/main/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java +++ b/main/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java @@ -11,69 +11,69 @@ import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.util.Messages; public class TextStartPrompt extends StringPrompt { - private final Text text; + private final Text text; - public TextStartPrompt(Text text) { - this.text = text; - } + public TextStartPrompt(Text text) { + this.text = text; + } - @Override - public Prompt acceptInput(ConversationContext context, String original) { - String[] parts = ChatColor.stripColor(original.trim()).split(" "); - String input = parts[0]; - CommandSender sender = (CommandSender) context.getForWhom(); - if (input.equalsIgnoreCase("add")) - return new TextAddPrompt(text); - else if (input.equalsIgnoreCase("edit")) - return new TextEditStartPrompt(text); - else if (input.equalsIgnoreCase("remove")) - return new TextRemovePrompt(text); - else if (input.equalsIgnoreCase("delay")) { - try { - int delay = Integer.parseInt(parts[1]); - text.setDelay(delay); - Messaging.sendTr(sender, Messages.TEXT_EDITOR_DELAY_SET, delay); - } catch (NumberFormatException e) { - Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY); - } catch (ArrayIndexOutOfBoundsException e) { - Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY); - } - } else if (input.equalsIgnoreCase("random")) - Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANDOM_TALKER_SET, text.toggleRandomTalker()); - else if (input.equalsIgnoreCase("realistic looking")) - Messaging.sendTr(sender, Messages.TEXT_EDITOR_REALISTIC_LOOKING_SET, text.toggleRealisticLooking()); - else if (input.equalsIgnoreCase("close") || input.equalsIgnoreCase("talk-close")) - Messaging.sendTr(sender, Messages.TEXT_EDITOR_CLOSE_TALKER_SET, text.toggle()); - else if (input.equalsIgnoreCase("range")) { - try { - double range = Math.min(Math.max(0, Double.parseDouble(parts[1])), Setting.MAX_TEXT_RANGE.asDouble()); - text.setRange(range); - Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANGE_SET, range); - } catch (NumberFormatException e) { - Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE); - } catch (ArrayIndexOutOfBoundsException e) { - Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE); - } - } else if (input.equalsIgnoreCase("item")) { - if (parts.length > 1) { - text.setItemInHandPattern(parts[1]); - Messaging.sendTr(sender, Messages.TEXT_EDITOR_SET_ITEM, parts[1]); - } - } else if (input.equalsIgnoreCase("help")) { - context.setSessionData("said-text", false); - Messaging.send(sender, getPromptText(context)); - } else - Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_EDIT_TYPE); + @Override + public Prompt acceptInput(ConversationContext context, String original) { + String[] parts = ChatColor.stripColor(original.trim()).split(" "); + String input = parts[0]; + CommandSender sender = (CommandSender) context.getForWhom(); + if (input.equalsIgnoreCase("add")) + return new TextAddPrompt(text); + else if (input.equalsIgnoreCase("edit")) + return new TextEditStartPrompt(text); + else if (input.equalsIgnoreCase("remove")) + return new TextRemovePrompt(text); + else if (input.equalsIgnoreCase("delay")) { + try { + int delay = Integer.parseInt(parts[1]); + text.setDelay(delay); + Messaging.sendTr(sender, Messages.TEXT_EDITOR_DELAY_SET, delay); + } catch (NumberFormatException e) { + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY); + } catch (ArrayIndexOutOfBoundsException e) { + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY); + } + } else if (input.equalsIgnoreCase("random")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANDOM_TALKER_SET, text.toggleRandomTalker()); + else if (input.equalsIgnoreCase("realistic looking")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_REALISTIC_LOOKING_SET, text.toggleRealisticLooking()); + else if (input.equalsIgnoreCase("close") || input.equalsIgnoreCase("talk-close")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_CLOSE_TALKER_SET, text.toggle()); + else if (input.equalsIgnoreCase("range")) { + try { + double range = Math.min(Math.max(0, Double.parseDouble(parts[1])), Setting.MAX_TEXT_RANGE.asDouble()); + text.setRange(range); + Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANGE_SET, range); + } catch (NumberFormatException e) { + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE); + } catch (ArrayIndexOutOfBoundsException e) { + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE); + } + } else if (input.equalsIgnoreCase("item")) { + if (parts.length > 1) { + text.setItemInHandPattern(parts[1]); + Messaging.sendTr(sender, Messages.TEXT_EDITOR_SET_ITEM, parts[1]); + } + } else if (input.equalsIgnoreCase("help")) { + context.setSessionData("said-text", false); + Messaging.send(sender, getPromptText(context)); + } else + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_EDIT_TYPE); - return new TextStartPrompt(text); - } + return new TextStartPrompt(text); + } - @Override - public String getPromptText(ConversationContext context) { - if (context.getSessionData("said-text") == Boolean.TRUE) - return ""; - String text = Messaging.tr(Messages.TEXT_EDITOR_START_PROMPT); - context.setSessionData("said-text", Boolean.TRUE); - return text; - } + @Override + public String getPromptText(ConversationContext context) { + if (context.getSessionData("said-text") == Boolean.TRUE) + return ""; + String text = Messaging.tr(Messages.TEXT_EDITOR_START_PROMPT); + context.setSessionData("said-text", Boolean.TRUE); + return text; + } } \ No newline at end of file diff --git a/main/src/main/java/net/citizensnpcs/trait/versioned/CatTrait.java b/main/src/main/java/net/citizensnpcs/trait/versioned/CatTrait.java index 9f2c508d6..50079fa36 100644 --- a/main/src/main/java/net/citizensnpcs/trait/versioned/CatTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/versioned/CatTrait.java @@ -11,66 +11,66 @@ import net.citizensnpcs.util.NMS; @TraitName("cattrait") public class CatTrait extends Trait { - @Persist - private DyeColor collarColor = null; - @Persist - private boolean lying = false; - @Persist - private boolean sitting = false; - @Persist - private Cat.Type type = Cat.Type.BLACK; + @Persist + private DyeColor collarColor = null; + @Persist + private boolean lying = false; + @Persist + private boolean sitting = false; + @Persist + private Cat.Type type = Cat.Type.BLACK; - public CatTrait() { - super("cattrait"); - } + public CatTrait() { + super("cattrait"); + } - public boolean isLyingDown() { - return lying; - } + public boolean isLyingDown() { + return lying; + } - @Override - public void run() { - if (npc.isSpawned() && npc.getEntity() instanceof Cat) { - Cat cat = (Cat) npc.getEntity(); - cat.setSitting(sitting); - cat.setCatType(type); - if (collarColor != null) { - cat.setCollarColor(collarColor); - } - NMS.setLyingDown(cat, lying); - } - } + @Override + public void run() { + if (npc.isSpawned() && npc.getEntity() instanceof Cat) { + Cat cat = (Cat) npc.getEntity(); + cat.setSitting(sitting); + cat.setCatType(type); + if (collarColor != null) { + cat.setCollarColor(collarColor); + } + NMS.setLyingDown(cat, lying); + } + } - public void setCollarColor(DyeColor color) { - this.collarColor = color; - } + public void setCollarColor(DyeColor color) { + this.collarColor = color; + } - public void setLyingDown(boolean lying) { - this.lying = lying; - } + public void setLyingDown(boolean lying) { + this.lying = lying; + } - public void setSitting(boolean sitting) { - this.sitting = sitting; - } + public void setSitting(boolean sitting) { + this.sitting = sitting; + } - public void setType(Cat.Type type) { - this.type = type; - } + public void setType(Cat.Type type) { + this.type = type; + } - public void setType(Type type2) { - switch (type2) { - case WILD_OCELOT: - this.type = Cat.Type.CALICO; - break; - case BLACK_CAT: - this.type = Cat.Type.BLACK; - break; - case RED_CAT: - this.type = Cat.Type.RED; - break; - case SIAMESE_CAT: - this.type = Cat.Type.SIAMESE; - break; - } - } + public void setType(Type type2) { + switch (type2) { + case WILD_OCELOT: + this.type = Cat.Type.CALICO; + break; + case BLACK_CAT: + this.type = Cat.Type.BLACK; + break; + case RED_CAT: + this.type = Cat.Type.RED; + break; + case SIAMESE_CAT: + this.type = Cat.Type.SIAMESE; + break; + } + } } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index dfee9d517..e1d3502a6 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -44,458 +44,458 @@ import net.citizensnpcs.util.Util; * An ordered list of {@link Waypoint}s to walk between. */ public class LinearWaypointProvider implements EnumerableWaypointProvider { - private LinearWaypointGoal currentGoal; - private NPC npc; - private final List waypoints = Lists.newArrayList(); + private LinearWaypointGoal currentGoal; + private NPC npc; + private final List waypoints = Lists.newArrayList(); - public LinearWaypointProvider() { - } + public LinearWaypointProvider() { + } - public LinearWaypointProvider(NPC npc) { - this.npc = npc; - } + public LinearWaypointProvider(NPC npc) { + this.npc = npc; + } - @Override - public WaypointEditor createEditor(CommandSender sender, CommandContext args) { - if (args.hasFlag('h')) { - try { - if (args.getSenderLocation() != null) { - waypoints.add(new Waypoint(args.getSenderLocation())); - } - } catch (CommandException e) { - Messaging.sendError(sender, e.getMessage()); - } - return null; - } else if (args.hasValueFlag("at")) { - try { - Location location = CommandContext.parseLocation(args.getSenderLocation(), args.getFlag("at")); - if (location != null) { - waypoints.add(new Waypoint(location)); - } - } catch (CommandException e) { - Messaging.sendError(sender, e.getMessage()); - } - return null; - } else if (args.hasFlag('c')) { - waypoints.clear(); - return null; - } else if (args.hasFlag('l')) { - if (waypoints.size() > 0) { - waypoints.remove(waypoints.size() - 1); - } - return null; - } else if (args.hasFlag('p')) { - setPaused(!isPaused()); - return null; - } else if (!(sender instanceof Player)) { - Messaging.sendErrorTr(sender, Messages.COMMAND_MUST_BE_INGAME); - return null; - } - return new LinearWaypointEditor((Player) sender); - } + @Override + public WaypointEditor createEditor(CommandSender sender, CommandContext args) { + if (args.hasFlag('h')) { + try { + if (args.getSenderLocation() != null) { + waypoints.add(new Waypoint(args.getSenderLocation())); + } + } catch (CommandException e) { + Messaging.sendError(sender, e.getMessage()); + } + return null; + } else if (args.hasValueFlag("at")) { + try { + Location location = CommandContext.parseLocation(args.getSenderLocation(), args.getFlag("at")); + if (location != null) { + waypoints.add(new Waypoint(location)); + } + } catch (CommandException e) { + Messaging.sendError(sender, e.getMessage()); + } + return null; + } else if (args.hasFlag('c')) { + waypoints.clear(); + return null; + } else if (args.hasFlag('l')) { + if (waypoints.size() > 0) { + waypoints.remove(waypoints.size() - 1); + } + return null; + } else if (args.hasFlag('p')) { + setPaused(!isPaused()); + return null; + } else if (!(sender instanceof Player)) { + Messaging.sendErrorTr(sender, Messages.COMMAND_MUST_BE_INGAME); + return null; + } + return new LinearWaypointEditor((Player) sender); + } - public Waypoint getCurrentWaypoint() { - if (currentGoal != null && currentGoal.currentDestination != null) { - return currentGoal.currentDestination; - } - return null; - } + public Waypoint getCurrentWaypoint() { + if (currentGoal != null && currentGoal.currentDestination != null) { + return currentGoal.currentDestination; + } + return null; + } - @Override - public boolean isPaused() { - return currentGoal == null ? false : currentGoal.isPaused(); - } + @Override + public boolean isPaused() { + return currentGoal == null ? false : currentGoal.isPaused(); + } - @Override - public void load(DataKey key) { - for (DataKey root : key.getRelative("points").getIntegerSubKeys()) { - Waypoint waypoint = PersistenceLoader.load(Waypoint.class, root); - if (waypoint == null) - continue; - waypoints.add(waypoint); - } - } + @Override + public void load(DataKey key) { + for (DataKey root : key.getRelative("points").getIntegerSubKeys()) { + Waypoint waypoint = PersistenceLoader.load(Waypoint.class, root); + if (waypoint == null) + continue; + waypoints.add(waypoint); + } + } - @Override - public void onRemove() { - if (currentGoal != null) { - npc.getDefaultGoalController().removeGoal(currentGoal); - currentGoal = null; - } - } + @Override + public void onRemove() { + if (currentGoal != null) { + npc.getDefaultGoalController().removeGoal(currentGoal); + currentGoal = null; + } + } - @Override - public void onSpawn(NPC npc) { - this.npc = npc; - if (currentGoal == null) { - currentGoal = new LinearWaypointGoal(); - npc.getDefaultGoalController().addGoal(currentGoal, 1); - } - } + @Override + public void onSpawn(NPC npc) { + this.npc = npc; + if (currentGoal == null) { + currentGoal = new LinearWaypointGoal(); + npc.getDefaultGoalController().addGoal(currentGoal, 1); + } + } - @Override - public void save(DataKey key) { - key.removeKey("points"); - key = key.getRelative("points"); - for (int i = 0; i < waypoints.size(); ++i) { - PersistenceLoader.save(waypoints.get(i), key.getRelative(i)); - } - } + @Override + public void save(DataKey key) { + key.removeKey("points"); + key = key.getRelative("points"); + for (int i = 0; i < waypoints.size(); ++i) { + PersistenceLoader.save(waypoints.get(i), key.getRelative(i)); + } + } - @Override - public void setPaused(boolean paused) { - if (currentGoal != null) { - currentGoal.setPaused(paused); - } - } + @Override + public void setPaused(boolean paused) { + if (currentGoal != null) { + currentGoal.setPaused(paused); + } + } - /** - * Returns the modifiable list of waypoints. - */ - @Override - public Iterable waypoints() { - return waypoints; - } + /** + * Returns the modifiable list of waypoints. + */ + @Override + public Iterable waypoints() { + return waypoints; + } - private final class LinearWaypointEditor extends WaypointEditor { - Conversation conversation; - boolean editing = true; - int editingSlot = waypoints.size() - 1; - EntityMarkers markers; - private final Player player; - private boolean showPath; + private final class LinearWaypointEditor extends WaypointEditor { + Conversation conversation; + boolean editing = true; + int editingSlot = waypoints.size() - 1; + EntityMarkers markers; + private final Player player; + private boolean showPath; - private LinearWaypointEditor(Player player) { - this.player = player; - this.markers = new EntityMarkers(); - } + private LinearWaypointEditor(Player player) { + this.player = player; + this.markers = new EntityMarkers(); + } - @Override - public void begin() { - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_BEGIN); - } + @Override + public void begin() { + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_BEGIN); + } - private void clearWaypoints() { - editingSlot = 0; - waypoints.clear(); - onWaypointsModified(); - markers.destroyMarkers(); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_WAYPOINTS_CLEARED); - } + private void clearWaypoints() { + editingSlot = 0; + waypoints.clear(); + onWaypointsModified(); + markers.destroyMarkers(); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_WAYPOINTS_CLEARED); + } - private void createWaypointMarkers() { - for (int i = 0; i < waypoints.size(); i++) { - markers.createMarker(waypoints.get(i), waypoints.get(i).getLocation().clone().add(0, 1, 0)); - } - } + private void createWaypointMarkers() { + for (int i = 0; i < waypoints.size(); i++) { + markers.createMarker(waypoints.get(i), waypoints.get(i).getLocation().clone().add(0, 1, 0)); + } + } - @Override - public void end() { - if (!editing) - return; - if (conversation != null) { - conversation.abandon(); - } - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_END); - editing = false; - if (!showPath) - return; - markers.destroyMarkers(); - } + @Override + public void end() { + if (!editing) + return; + if (conversation != null) { + conversation.abandon(); + } + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_END); + editing = false; + if (!showPath) + return; + markers.destroyMarkers(); + } - private String formatLoc(Location location) { - return String.format("[[%d]], [[%d]], [[%d]]", location.getBlockX(), location.getBlockY(), - location.getBlockZ()); - } + private String formatLoc(Location location) { + return String.format("[[%d]], [[%d]], [[%d]]", location.getBlockX(), location.getBlockY(), + location.getBlockZ()); + } - @Override - public Waypoint getCurrentWaypoint() { - if (waypoints.size() == 0 || !editing) { - return null; - } - normaliseEditingSlot(); - return waypoints.get(editingSlot); - } + @Override + public Waypoint getCurrentWaypoint() { + if (waypoints.size() == 0 || !editing) { + return null; + } + normaliseEditingSlot(); + return waypoints.get(editingSlot); + } - private Location getPreviousWaypoint(int fromSlot) { - if (waypoints.size() <= 1) - return null; - if (--fromSlot < 0) - fromSlot = waypoints.size() - 1; - return waypoints.get(fromSlot).getLocation(); - } + private Location getPreviousWaypoint(int fromSlot) { + if (waypoints.size() <= 1) + return null; + if (--fromSlot < 0) + fromSlot = waypoints.size() - 1; + return waypoints.get(fromSlot).getLocation(); + } - private void normaliseEditingSlot() { - editingSlot = Math.max(0, Math.min(waypoints.size() - 1, editingSlot)); - } + private void normaliseEditingSlot() { + editingSlot = Math.max(0, Math.min(waypoints.size() - 1, editingSlot)); + } - @EventHandler - public void onNPCDespawn(NPCDespawnEvent event) { - if (event.getNPC().equals(npc)) { - Editor.leave(player); - } - } + @EventHandler + public void onNPCDespawn(NPCDespawnEvent event) { + if (event.getNPC().equals(npc)) { + Editor.leave(player); + } + } - @EventHandler - public void onNPCRemove(NPCRemoveEvent event) { - if (event.getNPC().equals(npc)) { - Editor.leave(player); - } - } + @EventHandler + public void onNPCRemove(NPCRemoveEvent event) { + if (event.getNPC().equals(npc)) { + Editor.leave(player); + } + } - @EventHandler(ignoreCancelled = true) - public void onPlayerChat(AsyncPlayerChatEvent event) { - if (!event.getPlayer().equals(player)) - return; - String message = event.getMessage(); - if (message.equalsIgnoreCase("triggers")) { - event.setCancelled(true); - Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { - @Override - public void run() { - conversation = TriggerEditPrompt.start(player, LinearWaypointEditor.this); - } - }); - } else if (message.equalsIgnoreCase("clear")) { - event.setCancelled(true); - Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { - @Override - public void run() { - clearWaypoints(); - } - }); - } else if (message.equalsIgnoreCase("toggle path")) { - event.setCancelled(true); - Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { - @Override - public void run() { - // we need to spawn entities on the main thread. - togglePath(); - } - }); - } - } + @EventHandler(ignoreCancelled = true) + public void onPlayerChat(AsyncPlayerChatEvent event) { + if (!event.getPlayer().equals(player)) + return; + String message = event.getMessage(); + if (message.equalsIgnoreCase("triggers")) { + event.setCancelled(true); + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { + @Override + public void run() { + conversation = TriggerEditPrompt.start(player, LinearWaypointEditor.this); + } + }); + } else if (message.equalsIgnoreCase("clear")) { + event.setCancelled(true); + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { + @Override + public void run() { + clearWaypoints(); + } + }); + } else if (message.equalsIgnoreCase("toggle path")) { + event.setCancelled(true); + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { + @Override + public void run() { + // we need to spawn entities on the main thread. + togglePath(); + } + }); + } + } - @EventHandler(ignoreCancelled = true) - public void onPlayerInteract(PlayerInteractEvent event) { - if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL || !npc.isSpawned() - || event.getPlayer().getWorld() != npc.getEntity().getWorld() || Util.isOffHand(event)) - return; - if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) { - if (event.getClickedBlock() == null) - return; - event.setCancelled(true); - Location at = event.getClickedBlock().getLocation(); - Location prev = getPreviousWaypoint(editingSlot); + @EventHandler(ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEvent event) { + if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL || !npc.isSpawned() + || event.getPlayer().getWorld() != npc.getEntity().getWorld() || Util.isOffHand(event)) + return; + if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) { + if (event.getClickedBlock() == null) + return; + event.setCancelled(true); + Location at = event.getClickedBlock().getLocation(); + Location prev = getPreviousWaypoint(editingSlot); - if (prev != null && prev.getWorld() == at.getWorld()) { - double distance = at.distanceSquared(prev); - double maxDistance = Math.pow(npc.getNavigator().getDefaultParameters().range(), 2); - if (distance > maxDistance) { - Messaging.sendErrorTr(player, Messages.LINEAR_WAYPOINT_EDITOR_RANGE_EXCEEDED, - Math.sqrt(distance), Math.sqrt(maxDistance), ChatColor.RED); - return; - } - } + if (prev != null && prev.getWorld() == at.getWorld()) { + double distance = at.distanceSquared(prev); + double maxDistance = Math.pow(npc.getNavigator().getDefaultParameters().range(), 2); + if (distance > maxDistance) { + Messaging.sendErrorTr(player, Messages.LINEAR_WAYPOINT_EDITOR_RANGE_EXCEEDED, + Math.sqrt(distance), Math.sqrt(maxDistance), ChatColor.RED); + return; + } + } - Waypoint element = new Waypoint(at); - normaliseEditingSlot(); - waypoints.add(editingSlot, element); - if (showPath) { - markers.createMarker(element, element.getLocation().clone().add(0, 1, 0)); - } - editingSlot = Math.min(editingSlot + 1, waypoints.size()); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT, formatLoc(at), editingSlot + 1, - waypoints.size()); - } else if (waypoints.size() > 0) { - event.setCancelled(true); - normaliseEditingSlot(); - Waypoint waypoint = waypoints.remove(editingSlot); - if (showPath) { - markers.removeMarker(waypoint); - } - editingSlot = Math.max(0, editingSlot - 1); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_REMOVED_WAYPOINT, waypoints.size(), - editingSlot + 1); - } - onWaypointsModified(); - } + Waypoint element = new Waypoint(at); + normaliseEditingSlot(); + waypoints.add(editingSlot, element); + if (showPath) { + markers.createMarker(element, element.getLocation().clone().add(0, 1, 0)); + } + editingSlot = Math.min(editingSlot + 1, waypoints.size()); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT, formatLoc(at), editingSlot + 1, + waypoints.size()); + } else if (waypoints.size() > 0) { + event.setCancelled(true); + normaliseEditingSlot(); + Waypoint waypoint = waypoints.remove(editingSlot); + if (showPath) { + markers.removeMarker(waypoint); + } + editingSlot = Math.max(0, editingSlot - 1); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_REMOVED_WAYPOINT, waypoints.size(), + editingSlot + 1); + } + onWaypointsModified(); + } - @EventHandler(ignoreCancelled = true) - public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - if (!player.equals(event.getPlayer()) || !showPath || Util.isOffHand(event)) - return; - if (!event.getRightClicked().hasMetadata("waypointindex")) - return; - editingSlot = event.getRightClicked().getMetadata("waypointindex").get(0).asInt(); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, - formatLoc(waypoints.get(editingSlot).getLocation())); - } + @EventHandler(ignoreCancelled = true) + public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { + if (!player.equals(event.getPlayer()) || !showPath || Util.isOffHand(event)) + return; + if (!event.getRightClicked().hasMetadata("waypointindex")) + return; + editingSlot = event.getRightClicked().getMetadata("waypointindex").get(0).asInt(); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, + formatLoc(waypoints.get(editingSlot).getLocation())); + } - @EventHandler - public void onPlayerItemHeldChange(PlayerItemHeldEvent event) { - if (!event.getPlayer().equals(player) || waypoints.size() == 0) - return; - int previousSlot = event.getPreviousSlot(), newSlot = event.getNewSlot(); - // handle wrap-arounds - if (previousSlot == 0 && newSlot == LARGEST_SLOT) { - editingSlot--; - } else if (previousSlot == LARGEST_SLOT && newSlot == 0) { - editingSlot++; - } else { - int diff = newSlot - previousSlot; - if (Math.abs(diff) != 1) - return; // the player isn't scrolling - editingSlot += diff > 0 ? 1 : -1; - } - normaliseEditingSlot(); - if (conversation != null) { - getCurrentWaypoint().describeTriggers(player); - } - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, - formatLoc(waypoints.get(editingSlot).getLocation())); - } + @EventHandler + public void onPlayerItemHeldChange(PlayerItemHeldEvent event) { + if (!event.getPlayer().equals(player) || waypoints.size() == 0) + return; + int previousSlot = event.getPreviousSlot(), newSlot = event.getNewSlot(); + // handle wrap-arounds + if (previousSlot == 0 && newSlot == LARGEST_SLOT) { + editingSlot--; + } else if (previousSlot == LARGEST_SLOT && newSlot == 0) { + editingSlot++; + } else { + int diff = newSlot - previousSlot; + if (Math.abs(diff) != 1) + return; // the player isn't scrolling + editingSlot += diff > 0 ? 1 : -1; + } + normaliseEditingSlot(); + if (conversation != null) { + getCurrentWaypoint().describeTriggers(player); + } + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, + formatLoc(waypoints.get(editingSlot).getLocation())); + } - private void onWaypointsModified() { - if (currentGoal != null) { - currentGoal.onProviderChanged(); - } - if (conversation != null) { - getCurrentWaypoint().describeTriggers(player); - } - } + private void onWaypointsModified() { + if (currentGoal != null) { + currentGoal.onProviderChanged(); + } + if (conversation != null) { + getCurrentWaypoint().describeTriggers(player); + } + } - private void togglePath() { - showPath = !showPath; - if (showPath) { - createWaypointMarkers(); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_SHOWING_MARKERS); - } else { - markers.destroyMarkers(); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_NOT_SHOWING_MARKERS); - } - } + private void togglePath() { + showPath = !showPath; + if (showPath) { + createWaypointMarkers(); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_SHOWING_MARKERS); + } else { + markers.destroyMarkers(); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_NOT_SHOWING_MARKERS); + } + } - private static final int LARGEST_SLOT = 8; - } + private static final int LARGEST_SLOT = 8; + } - private class LinearWaypointGoal implements Goal { - private final Location cachedLocation = new Location(null, 0, 0, 0); - private Waypoint currentDestination; - private Iterator itr; - private boolean paused; - private GoalSelector selector; + private class LinearWaypointGoal implements Goal { + private final Location cachedLocation = new Location(null, 0, 0, 0); + private Waypoint currentDestination; + private Iterator itr; + private boolean paused; + private GoalSelector selector; - private void ensureItr() { - if (itr == null) { - itr = getUnsafeIterator(); - } else if (!itr.hasNext()) { - itr = getNewIterator(); - } - } + private void ensureItr() { + if (itr == null) { + itr = getUnsafeIterator(); + } else if (!itr.hasNext()) { + itr = getNewIterator(); + } + } - private Navigator getNavigator() { - return npc.getNavigator(); - } + private Navigator getNavigator() { + return npc.getNavigator(); + } - private Iterator getNewIterator() { - LinearWaypointsCompleteEvent event = new LinearWaypointsCompleteEvent(LinearWaypointProvider.this, - getUnsafeIterator()); - Bukkit.getPluginManager().callEvent(event); - Iterator next = event.getNextWaypoints(); - return next; - } + private Iterator getNewIterator() { + LinearWaypointsCompleteEvent event = new LinearWaypointsCompleteEvent(LinearWaypointProvider.this, + getUnsafeIterator()); + Bukkit.getPluginManager().callEvent(event); + Iterator next = event.getNextWaypoints(); + return next; + } - private Iterator getUnsafeIterator() { - return new Iterator() { - int idx = 0; + private Iterator getUnsafeIterator() { + return new Iterator() { + int idx = 0; - @Override - public boolean hasNext() { - return idx < waypoints.size(); - } + @Override + public boolean hasNext() { + return idx < waypoints.size(); + } - @Override - public Waypoint next() { - return waypoints.get(idx++); - } + @Override + public Waypoint next() { + return waypoints.get(idx++); + } - @Override - public void remove() { - waypoints.remove(Math.max(0, idx - 1)); - } - }; - } + @Override + public void remove() { + waypoints.remove(Math.max(0, idx - 1)); + } + }; + } - public boolean isPaused() { - return paused; - } + public boolean isPaused() { + return paused; + } - public void onProviderChanged() { - itr = getUnsafeIterator(); - if (currentDestination != null) { - if (selector != null) { - selector.finish(); - } - if (npc != null && npc.getNavigator().isNavigating()) { - npc.getNavigator().cancelNavigation(); - } - } - } + public void onProviderChanged() { + itr = getUnsafeIterator(); + if (currentDestination != null) { + if (selector != null) { + selector.finish(); + } + if (npc != null && npc.getNavigator().isNavigating()) { + npc.getNavigator().cancelNavigation(); + } + } + } - @Override - public void reset() { - currentDestination = null; - selector = null; - } + @Override + public void reset() { + currentDestination = null; + selector = null; + } - @Override - public void run(GoalSelector selector) { - if (!getNavigator().isNavigating()) { - selector.finish(); - } - } + @Override + public void run(GoalSelector selector) { + if (!getNavigator().isNavigating()) { + selector.finish(); + } + } - public void setPaused(boolean pause) { - if (pause && currentDestination != null) { - selector.finish(); - if (npc != null && npc.getNavigator().isNavigating()) { - npc.getNavigator().cancelNavigation(); - } - } - paused = pause; - } + public void setPaused(boolean pause) { + if (pause && currentDestination != null) { + selector.finish(); + if (npc != null && npc.getNavigator().isNavigating()) { + npc.getNavigator().cancelNavigation(); + } + } + paused = pause; + } - @Override - public boolean shouldExecute(final GoalSelector selector) { - if (paused || currentDestination != null || !npc.isSpawned() || getNavigator().isNavigating()) { - return false; - } - ensureItr(); - boolean shouldExecute = itr.hasNext(); - if (!shouldExecute) { - return false; - } - this.selector = selector; - Waypoint next = itr.next(); - Location npcLoc = npc.getEntity().getLocation(cachedLocation); - if (npcLoc.getWorld() != next.getLocation().getWorld() || npcLoc.distanceSquared(next.getLocation()) < npc - .getNavigator().getLocalParameters().distanceMargin()) { - return false; - } - currentDestination = next; - getNavigator().setTarget(currentDestination.getLocation()); - getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { - @Override - public void onCompletion(@Nullable CancelReason cancelReason) { - if (npc.isSpawned() && currentDestination != null - && Util.locationWithinRange(npc.getStoredLocation(), currentDestination.getLocation(), 2)) { - currentDestination.onReach(npc); - } - selector.finish(); - } - }); - return true; - } - } + @Override + public boolean shouldExecute(final GoalSelector selector) { + if (paused || currentDestination != null || !npc.isSpawned() || getNavigator().isNavigating()) { + return false; + } + ensureItr(); + boolean shouldExecute = itr.hasNext(); + if (!shouldExecute) { + return false; + } + this.selector = selector; + Waypoint next = itr.next(); + Location npcLoc = npc.getEntity().getLocation(cachedLocation); + if (npcLoc.getWorld() != next.getLocation().getWorld() || npcLoc.distanceSquared(next.getLocation()) < npc + .getNavigator().getLocalParameters().distanceMargin()) { + return false; + } + currentDestination = next; + getNavigator().setTarget(currentDestination.getLocation()); + getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { + @Override + public void onCompletion(@Nullable CancelReason cancelReason) { + if (npc.isSpawned() && currentDestination != null + && Util.locationWithinRange(npc.getStoredLocation(), currentDestination.getLocation(), 2)) { + currentDestination.onReach(npc); + } + selector.finish(); + } + }); + return true; + } + } } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java index 4dd902d35..9e452c063 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java @@ -20,124 +20,125 @@ import net.citizensnpcs.util.StringHelper; @TraitName("waypoints") public class Waypoints extends Trait { - private WaypointProvider provider; - private String providerName = "linear"; + private WaypointProvider provider; + private String providerName = "linear"; - public Waypoints() { - super("waypoints"); - } + public Waypoints() { + super("waypoints"); + } - private WaypointProvider create(Class clazz) { - try { - return clazz.newInstance(); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } + private WaypointProvider create(Class clazz) { + try { + return clazz.newInstance(); + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + } - public void onAttach() { - provider = new LinearWaypointProvider(npc); - } + public void onAttach() { + provider = new LinearWaypointProvider(npc); + } - public void describeProviders(CommandSender sender) { - Messaging.sendTr(sender, Messages.AVAILABLE_WAYPOINT_PROVIDERS); - for (String name : PROVIDERS.keySet()) { - Messaging.send(sender, " - " + StringHelper.wrap(name)); - } - } + public void describeProviders(CommandSender sender) { + Messaging.sendTr(sender, Messages.AVAILABLE_WAYPOINT_PROVIDERS); + for (String name : PROVIDERS.keySet()) { + Messaging.send(sender, " - " + StringHelper.wrap(name)); + } + } - /** - * Returns the current {@link WaypointProvider}. May be null during - * initialisation. - * - * @return The current provider - */ - public WaypointProvider getCurrentProvider() { - return provider; - } + /** + * Returns the current {@link WaypointProvider}. May be null during initialisation. + * + * @return The current provider + */ + public WaypointProvider getCurrentProvider() { + return provider; + } - /** - * @return The current provider name - */ - public String getCurrentProviderName() { - return providerName; - } + /** + * @return The current provider name + */ + public String getCurrentProviderName() { + return providerName; + } - public Editor getEditor(CommandSender player, CommandContext args) { - return provider.createEditor(player, args); - } + public Editor getEditor(CommandSender player, CommandContext args) { + return provider.createEditor(player, args); + } - @Override - public void load(DataKey key) throws NPCLoadException { - provider = null; - providerName = key.getString("provider", "linear"); - for (Entry> entry : PROVIDERS.entrySet()) { - if (entry.getKey().equals(providerName)) { - provider = create(entry.getValue()); - break; - } - } - if (provider == null) - return; - if (npc != null) { - provider.onSpawn(npc); - } - PersistenceLoader.load(provider, key.getRelative(providerName)); - } + @Override + public void load(DataKey key) throws NPCLoadException { + provider = null; + providerName = key.getString("provider", "linear"); + for (Entry> entry : PROVIDERS.entrySet()) { + if (entry.getKey().equals(providerName)) { + provider = create(entry.getValue()); + break; + } + } + if (provider == null) + return; + if (npc != null) { + provider.onSpawn(npc); + } + PersistenceLoader.load(provider, key.getRelative(providerName)); + } - @Override - public void onSpawn() { - if (provider != null) { - provider.onSpawn(getNPC()); - } - } + @Override + public void onSpawn() { + if (provider != null) { + provider.onSpawn(getNPC()); + } + } - @Override - public void save(DataKey key) { - if (provider == null) - return; - PersistenceLoader.save(provider, key.getRelative(providerName)); - key.setString("provider", providerName); - } + @Override + public void save(DataKey key) { + if (provider == null) + return; + PersistenceLoader.save(provider, key.getRelative(providerName)); + key.setString("provider", providerName); + } - /** - * Sets the current {@link WaypointProvider} using the given name. - * - * @param name The name of the waypoint provider, registered using - * {@link #registerWaypointProvider(Class, String)} - * @return Whether the operation succeeded - */ - public boolean setWaypointProvider(String name) { - name = name.toLowerCase(); - Class clazz = PROVIDERS.get(name); - if (provider != null) { - provider.onRemove(); - } - if (clazz == null || (provider = create(clazz)) == null) - return false; - providerName = name; - if (npc != null && npc.isSpawned()) { - provider.onSpawn(npc); - } - return true; - } + /** + * Sets the current {@link WaypointProvider} using the given name. + * + * @param name + * The name of the waypoint provider, registered using {@link #registerWaypointProvider(Class, String)} + * @return Whether the operation succeeded + */ + public boolean setWaypointProvider(String name) { + name = name.toLowerCase(); + Class clazz = PROVIDERS.get(name); + if (provider != null) { + provider.onRemove(); + } + if (clazz == null || (provider = create(clazz)) == null) + return false; + providerName = name; + if (npc != null && npc.isSpawned()) { + provider.onSpawn(npc); + } + return true; + } - /** - * Registers a {@link WaypointProvider}, which can be subsequently used by NPCs. - * - * @param clazz The class of the waypoint provider - * @param name The name of the waypoint provider - */ - public static void registerWaypointProvider(Class clazz, String name) { - PROVIDERS.put(name, clazz); - } + /** + * Registers a {@link WaypointProvider}, which can be subsequently used by NPCs. + * + * @param clazz + * The class of the waypoint provider + * @param name + * The name of the waypoint provider + */ + public static void registerWaypointProvider(Class clazz, String name) { + PROVIDERS.put(name, clazz); + } - private static final Map> PROVIDERS = Maps.newHashMap(); + private static final Map> PROVIDERS = Maps.newHashMap(); - static { - PROVIDERS.put("linear", LinearWaypointProvider.class); - PROVIDERS.put("wander", WanderWaypointProvider.class); - PROVIDERS.put("guided", GuidedWaypointProvider.class); - } + static { + PROVIDERS.put("linear", LinearWaypointProvider.class); + PROVIDERS.put("wander", WanderWaypointProvider.class); + PROVIDERS.put("guided", GuidedWaypointProvider.class); + } } \ No newline at end of file diff --git a/main/src/main/java/net/citizensnpcs/util/Util.java b/main/src/main/java/net/citizensnpcs/util/Util.java index c01232768..0c3ad0a78 100644 --- a/main/src/main/java/net/citizensnpcs/util/Util.java +++ b/main/src/main/java/net/citizensnpcs/util/Util.java @@ -103,14 +103,14 @@ public class Util { // 1.8.8 compatibility return true; switch (type) { - case BAT: - case BLAZE: - case ENDER_DRAGON: - case GHAST: - case WITHER: - return true; - default: - return false; + case BAT: + case BLAZE: + case ENDER_DRAGON: + case GHAST: + case WITHER: + return true; + default: + return false; } } diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/CreeperController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/CreeperController.java index d1b06e9bc..eff0788fe 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/CreeperController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/CreeperController.java @@ -75,7 +75,8 @@ public class CreeperController extends MobEntityController { @Override protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) { return npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true) - ? super.a(entityhuman, enumhand, itemstack) : false; + ? super.a(entityhuman, enumhand, itemstack) + : false; } @Override diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerPathfinderNormal.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerPathfinderNormal.java index abe365cf8..dc5979c58 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerPathfinderNormal.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/PlayerPathfinderNormal.java @@ -93,8 +93,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract { } else { return null; } - } - else { + } else { break; } }