diff --git a/src/main/java/net/citizensnpcs/Citizens.java b/src/main/java/net/citizensnpcs/Citizens.java index 4e7ac247e..a2472004d 100644 --- a/src/main/java/net/citizensnpcs/Citizens.java +++ b/src/main/java/net/citizensnpcs/Citizens.java @@ -6,6 +6,16 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; + import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensPlugin; @@ -51,16 +61,6 @@ import net.citizensnpcs.util.StringHelper; import net.citizensnpcs.util.Util; import net.milkbowl.vault.economy.Economy; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.plugin.java.JavaPlugin; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; - public class Citizens extends JavaPlugin implements CitizensPlugin { private final CommandManager commands = new CommandManager(); private boolean compatible; @@ -134,8 +134,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName()); plugin.onLoad(); } catch (Throwable ex) { - Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(), plugin.getDescription() - .getFullName()); + Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(), + plugin.getDescription().getFullName()); ex.printStackTrace(); } } diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index cad901e18..b2f514fa4 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -131,8 +131,8 @@ public class EventListen implements Listener { } toRespawn.put(coord, npc); if (Messaging.isDebugging()) { - Messaging - .debug("Despawned id", npc.getId(), "due to chunk unload at [" + coord.x + "," + coord.z + "]"); + Messaging.debug("Despawned id", npc.getId(), + "due to chunk unload at [" + coord.x + "," + coord.z + "]"); } } } @@ -228,8 +228,8 @@ public class EventListen implements Listener { NPC npc = npcRegistry.getNPC(event.getTarget()); if (npc == null) return; - event.setCancelled(!npc.data().get(NPC.TARGETABLE_METADATA, - !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))); + event.setCancelled( + !npc.data().get(NPC.TARGETABLE_METADATA, !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))); Bukkit.getPluginManager().callEvent(new EntityTargetNPCEvent(event, npc)); } @@ -300,27 +300,27 @@ public class EventListen implements Listener { new BukkitRunnable() { @Override public void run() { - final List nearbyNPCs = new ArrayList(); - for (NPC npc : getAllNPCs()) { - Entity npcEntity = npc.getEntity(); - if (npcEntity instanceof Player && player.canSee((Player) npcEntity) - && player.getWorld().equals(npcEntity.getWorld()) - && player.getLocation().distanceSquared(npcEntity.getLocation()) < 100 * 100) { - nearbyNPCs.add(((CraftPlayer) npcEntity).getHandle()); + final List nearbyNPCs = new ArrayList(); + for (NPC npc : getAllNPCs()) { + Entity npcEntity = npc.getEntity(); + if (npcEntity instanceof Player && player.canSee((Player) npcEntity) + && player.getWorld().equals(npcEntity.getWorld()) + && player.getLocation().distanceSquared(npcEntity.getLocation()) < 100 * 100) { + nearbyNPCs.add(((CraftPlayer) npcEntity).getHandle()); + } } - } - new BukkitRunnable() { - @Override - public void run() { - sendToPlayer(player, nearbyNPCs); - } - }.runTaskLater(CitizensAPI.getPlugin(), 30); - new BukkitRunnable() { - @Override - public void run() { - sendToPlayer(player, nearbyNPCs); - } - }.runTaskLater(CitizensAPI.getPlugin(), 70); + new BukkitRunnable() { + @Override + public void run() { + sendToPlayer(player, nearbyNPCs); + } + }.runTaskLater(CitizensAPI.getPlugin(), 30); + new BukkitRunnable() { + @Override + public void run() { + sendToPlayer(player, nearbyNPCs); + } + }.runTaskLater(CitizensAPI.getPlugin(), 70); } }.runTaskLater(CitizensAPI.getPlugin(), 10); @@ -405,8 +405,8 @@ public class EventListen implements Listener { boolean success = spawn(npc); if (!success) { if (Messaging.isDebugging()) { - Messaging.debug("Couldn't respawn id", npc.getId(), "during chunk event at [" + coord.x + "," - + coord.z + "]"); + Messaging.debug("Couldn't respawn id", npc.getId(), + "during chunk event at [" + coord.x + "," + coord.z + "]"); } continue; } diff --git a/src/main/java/net/citizensnpcs/Metrics.java b/src/main/java/net/citizensnpcs/Metrics.java index f5f3e7a3b..4ba2114a7 100644 --- a/src/main/java/net/citizensnpcs/Metrics.java +++ b/src/main/java/net/citizensnpcs/Metrics.java @@ -129,8 +129,7 @@ public class Metrics { } /** - * Add a Graph object to BukkitMetrics that represents data for the plugin - * that should be sent to the backend + * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend * * @param graph * The name of the graph @@ -144,14 +143,12 @@ public class Metrics { } /** - * Construct and create a Graph that can be used to separate specific - * plotters to their own graphs on the metrics website. Plotters can be - * added to the graph object returned. + * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics + * website. Plotters can be added to the graph object returned. * * @param name * The name of the graph - * @return Graph object created. Will never return NULL under normal - * circumstances unless bad parameters are given + * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given */ public Graph createGraph(final String name) { if (name == null) { @@ -169,8 +166,7 @@ public class Metrics { } /** - * Disables metrics for the server by setting "opt-out" to true in the - * config file and canceling the metrics task. + * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * * @throws java.io.IOException */ @@ -194,8 +190,7 @@ public class Metrics { } /** - * Enables metrics for the server by setting "opt-out" to false in the - * config file and starting the metrics task. + * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * * @throws java.io.IOException */ @@ -218,8 +213,7 @@ public class Metrics { } /** - * Gets the File object of the config file that should be used to store data - * such as the GUID and opt-out status + * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status * * @return the File object for the config file */ @@ -237,8 +231,7 @@ public class Metrics { } /** - * Check if mineshafter is present. If it is, we need to bypass it to send - * POST requests + * Check if mineshafter is present. If it is, we need to bypass it to send POST requests * * @return true if mineshafter is installed on the server */ @@ -443,10 +436,9 @@ public class Metrics { } /** - * Start measuring statistics. This will immediately create an async - * repeating task as the plugin and send the initial data to the metrics - * backend, and then after that it will post in increments of PING_INTERVAL - * * 1200 ticks. + * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the + * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 + * ticks. * * @return True if statistics measuring is running, otherwise false. */ @@ -514,8 +506,8 @@ public class Metrics { public static class Graph { /** - * The graph's name, alphanumeric and spaces only :) If it does not - * comply to the above when submitted, it is rejected + * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is + * rejected */ private final String name; @@ -572,8 +564,7 @@ public class Metrics { } /** - * Called when the server owner decides to opt-out of BukkitMetrics - * while the server is running. + * Called when the server owner decides to opt-out of BukkitMetrics while the server is running. */ protected void onOptOut() { } @@ -610,8 +601,7 @@ public class Metrics { * Construct a plotter with a specific plot name * * @param name - * the name of the plotter to use, which will show up on the - * website + * the name of the plotter to use, which will show up on the website */ public Plotter(final String name) { this.name = name; @@ -637,11 +627,9 @@ public class Metrics { } /** - * Get the current value for the plotted point. Since this function - * defers to an external function it may or may not return immediately - * thus cannot be guaranteed to be thread friendly or safe. This - * function can be called from any thread so care should be taken when - * accessing resources that need to be synchronized. + * Get the current value for the plotted point. Since this function defers to an external function it may or may + * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called + * from any thread so care should be taken when accessing resources that need to be synchronized. * * @return the current value for the point to be plotted. */ diff --git a/src/main/java/net/citizensnpcs/commands/NPCCommandSelector.java b/src/main/java/net/citizensnpcs/commands/NPCCommandSelector.java index a6bdf0b5d..8cb2c11eb 100644 --- a/src/main/java/net/citizensnpcs/commands/NPCCommandSelector.java +++ b/src/main/java/net/citizensnpcs/commands/NPCCommandSelector.java @@ -104,10 +104,8 @@ public class NPCCommandSelector extends NumericPrompt { } for (NPC test : npcRegistry) { if (test.getName().equalsIgnoreCase(name)) { - if (range > 0 - && test.isSpawned() - && !Util.locationWithinRange(args.getSenderLocation(), test.getEntity().getLocation(), - range)) + if (range > 0 && test.isSpawned() && !Util.locationWithinRange(args.getSenderLocation(), + test.getEntity().getLocation(), range)) continue; possible.add(test); } diff --git a/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 53a2c0490..26e3f9281 100644 --- a/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -227,8 +227,8 @@ public class NPCCommands { 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("_", ""))) + if ((npc.isSpawned() && !sender.hasPermission( + "citizens.npc.controllable." + npc.getEntity().getType().name().toLowerCase().replace("_", ""))) || !sender.hasPermission("citizens.npc.controllable")) throw new NoPermissionsException(); if (!npc.hasTrait(Controllable.class)) { @@ -272,7 +272,7 @@ public class NPCCommands { } CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy) - : new CommandSenderCreateNPCEvent(sender, copy); + : new CommandSenderCreateNPCEvent(sender, copy); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { event.getNPC().destroy(); @@ -348,7 +348,7 @@ public class NPCCommands { spawnLoc = args.getSenderLocation(); } CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc) - : new CommandSenderCreateNPCEvent(sender, npc); + : new CommandSenderCreateNPCEvent(sender, npc); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { npc.destroy(); @@ -448,8 +448,11 @@ public class NPCCommands { 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 }) + @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); @@ -470,8 +473,8 @@ public class NPCCommands { public void gamemode(CommandContext args, CommandSender sender, NPC npc) { Player player = (Player) npc.getEntity(); if (args.argsLength() == 1) { - Messaging.sendTr(sender, Messages.GAMEMODE_DESCRIBE, npc.getName(), player.getGameMode().name() - .toLowerCase()); + Messaging.sendTr(sender, Messages.GAMEMODE_DESCRIBE, npc.getName(), + player.getGameMode().name().toLowerCase()); return; } GameMode mode = null; @@ -584,8 +587,10 @@ public class NPCCommands { max = 3, flags = "", permission = "citizens.npc.item") - @Requirements(selected = true, ownership = true, types = { EntityType.DROPPED_ITEM, EntityType.ITEM_FRAME, - EntityType.FALLING_BLOCK }) + @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) @@ -702,8 +707,9 @@ public class NPCCommands { max = 1, permission = "citizens.npc.lookclose") public void lookClose(CommandContext args, CommandSender sender, NPC npc) { - Messaging.sendTr(sender, npc.getTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET - : Messages.LOOKCLOSE_STOPPED, npc.getName()); + Messaging.sendTr(sender, + npc.getTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET : Messages.LOOKCLOSE_STOPPED, + npc.getName()); } @Command( @@ -715,9 +721,12 @@ public class NPCCommands { 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 }) + @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"); @@ -906,8 +915,8 @@ public class NPCCommands { 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); + boolean passive = args.hasValueFlag("set") ? Boolean.parseBoolean(args.getFlag("set")) + : npc.data().get(NPC.DAMAGE_OTHERS_METADATA, true); npc.data().setPersistent(NPC.DAMAGE_OTHERS_METADATA, !passive); Messaging.sendTr(sender, passive ? Messages.PASSIVE_SET : Messages.PASSIVE_UNSET, npc.getName()); } @@ -932,8 +941,14 @@ 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); @@ -1024,8 +1039,8 @@ public class NPCCommands { 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); + Messaging.sendTr(sender, + npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED); } @Command( @@ -1041,15 +1056,20 @@ public class NPCCommands { String profession = args.getString(1); Profession parsed = Util.matchEnum(Profession.values(), profession.toUpperCase()); if (parsed == null) { - throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1), StringUtils.join( - Profession.values(), ",")); + throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1), + StringUtils.join(Profession.values(), ",")); } npc.getTrait(VillagerProfession.class).setProfession(parsed); 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 { RabbitTypes type; @@ -1062,8 +1082,13 @@ public class NPCCommands { Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name()); } - @Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove", - "rem" }, min = 1, max = 2) + @Command( + aliases = { "npc" }, + usage = "remove|rem (all|id|name)", + 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.argsLength() == 2) { @@ -1222,8 +1247,14 @@ public class NPCCommands { } } - @Command(aliases = { "npc" }, usage = "skeletontype [type]", desc = "Sets the NPC's skeleton type", modifiers = { - "skeletontype", "sktype" }, min = 2, max = 2, permission = "citizens.npc.skeletontype") + @Command( + aliases = { "npc" }, + usage = "skeletontype [type]", + desc = "Sets the NPC's skeleton type", + modifiers = { "skeletontype", "sktype" }, + min = 2, + max = 2, + permission = "citizens.npc.skeletontype") @Requirements(selected = true, ownership = true, types = EntityType.SKELETON) public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException { SkeletonType type; @@ -1450,8 +1481,8 @@ public class NPCCommands { 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); + boolean swim = args.hasValueFlag("set") ? Boolean.parseBoolean(args.getFlag("set")) + : !npc.data().get(NPC.SWIMMING_METADATA, true); npc.data().setPersistent(NPC.SWIMMING_METADATA, swim); Messaging.sendTr(sender, swim ? Messages.SWIMMING_SET : Messages.SWIMMING_UNSET, npc.getName()); } @@ -1493,8 +1524,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(); diff --git a/src/main/java/net/citizensnpcs/commands/TraitCommands.java b/src/main/java/net/citizensnpcs/commands/TraitCommands.java index b073fd5ba..7de240746 100644 --- a/src/main/java/net/citizensnpcs/commands/TraitCommands.java +++ b/src/main/java/net/citizensnpcs/commands/TraitCommands.java @@ -25,8 +25,13 @@ import com.google.common.collect.Lists; @Requirements(selected = true, ownership = true) public class TraitCommands { - @Command(aliases = { "trait", "tr" }, usage = "add [trait name]...", desc = "Adds traits to the NPC", modifiers = { - "add", "a" }, min = 1, permission = "citizens.npc.trait") + @Command( + aliases = { "trait", "tr" }, + usage = "add [trait name]...", + desc = "Adds traits to the NPC", + modifiers = { "add", "a" }, + min = 1, + permission = "citizens.npc.trait") public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException { List added = Lists.newArrayList(); List failed = Lists.newArrayList(); diff --git a/src/main/java/net/citizensnpcs/editor/Editor.java b/src/main/java/net/citizensnpcs/editor/Editor.java index 5a49589b0..956440b97 100644 --- a/src/main/java/net/citizensnpcs/editor/Editor.java +++ b/src/main/java/net/citizensnpcs/editor/Editor.java @@ -20,8 +20,8 @@ public abstract class Editor implements Listener { private static void enter(Player player, Editor editor) { editor.begin(); - player.getServer().getPluginManager() - .registerEvents(editor, player.getServer().getPluginManager().getPlugin("Citizens")); + player.getServer().getPluginManager().registerEvents(editor, + player.getServer().getPluginManager().getPlugin("Citizens")); EDITING.put(player.getName(), editor); } diff --git a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index 3f9798af7..c04b602e4 100644 --- a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -57,6 +57,7 @@ public class EquipmentEditor extends Editor { } private static final Map EQUIPPERS = Maps.newEnumMap(EntityType.class); + static { EQUIPPERS.put(EntityType.PIG, new PigEquipper()); EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper()); diff --git a/src/main/java/net/citizensnpcs/editor/SheepEquipper.java b/src/main/java/net/citizensnpcs/editor/SheepEquipper.java index 06916d4a9..0f6211485 100644 --- a/src/main/java/net/citizensnpcs/editor/SheepEquipper.java +++ b/src/main/java/net/citizensnpcs/editor/SheepEquipper.java @@ -27,8 +27,8 @@ public class SheepEquipper implements Equipper { return; DyeColor color = dye.getColor(); toEquip.getTrait(WoolColor.class).setColor(color); - Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(), color.name() - .toLowerCase().replace("_", " ")); + Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(), + color.name().toLowerCase().replace("_", " ")); hand.setAmount(hand.getAmount() - 1); } else { diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index 16701ff3c..ef3bb9838 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -4,6 +4,22 @@ import java.util.Arrays; import java.util.Collection; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.scheduler.BukkitRunnable; + +import com.google.common.base.Preconditions; +import com.google.common.base.Throwables; + import net.citizensnpcs.NPCNeedsRespawnEvent; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; @@ -26,23 +42,7 @@ import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; - import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.metadata.FixedMetadataValue; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import org.bukkit.scheduler.BukkitRunnable; public class CitizensNPC extends AbstractNPC { private EntityController entityController; @@ -224,15 +224,21 @@ public class CitizensNPC extends AbstractNPC { final CraftPlayer player = (CraftPlayer) getEntity(); NMS.replaceTrackerEntry(player); new BukkitRunnable() { + @Override public void run() { - NMS.sendPacketsNearby(player, player.getLocation(), Arrays.asList((Packet) new PacketPlayOutPlayerInfo( - PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, player.getHandle())), 200.0); + NMS.sendPacketsNearby(player, player.getLocation(), + Arrays.asList((Packet) new PacketPlayOutPlayerInfo( + PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, player.getHandle())), + 200.0); new BukkitRunnable() { @Override public void run() { - NMS.sendPacketsNearby(player, player.getLocation(), Arrays.asList((Packet) new PacketPlayOutPlayerInfo( - PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, player.getHandle())), 200.0); + NMS.sendPacketsNearby(player, player.getLocation(), + Arrays.asList((Packet) new PacketPlayOutPlayerInfo( + PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, + player.getHandle())), + 200.0); } }.runTaskLater(CitizensAPI.getPlugin(), 2); } diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java b/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java index 08113575d..bd62cf638 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java @@ -236,6 +236,7 @@ public class CitizensNPCRegistry implements NPCRegistry { }; private static boolean TROVE_EXISTS = false; + static { // allow trove dependency to be optional for debugging purposes try { diff --git a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java index 35b9c01bc..a89e74f73 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java @@ -32,8 +32,9 @@ public class AStarNavigationStrategy extends AbstractPathStrategy { this.npc = npc; Location location = Util.getEyeLocation(npc.getEntity()); VectorGoal goal = new VectorGoal(dest, (float) params.pathDistanceMargin()); - plan = ASTAR.runFully(goal, new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), - params.examiners()), 50000); + plan = ASTAR.runFully(goal, + new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), params.examiners()), + 50000); if (plan == null || plan.isComplete()) { setCancelReason(CancelReason.STUCK); } else { @@ -76,8 +77,8 @@ public class AStarNavigationStrategy extends AbstractPathStrategy { double xzDistance = dX * dX + dZ * dZ; double distance = xzDistance + dY * dY; if (Setting.DEBUG_PATHFINDING.asBoolean()) { - npc.getEntity().getWorld() - .playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL, 0); + npc.getEntity().getWorld().playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL, + 0); } if (distance > 0 && dY > 0 && dY < 1 && xzDistance <= 2.75) { NMS.setShouldJump(npc.getEntity()); diff --git a/src/main/java/net/citizensnpcs/npc/ai/FlyingAStarNavigationStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/FlyingAStarNavigationStrategy.java index c95f54a99..2234284e8 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/FlyingAStarNavigationStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/FlyingAStarNavigationStrategy.java @@ -44,8 +44,9 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy { if (!found) { params.examiner(new FlyingBlockExaminer()); } - plan = ASTAR.runFully(goal, new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), - params.examiners()), 50000); + plan = ASTAR.runFully(goal, + new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), params.examiners()), + 50000); if (plan == null || plan.isComplete()) { setCancelReason(CancelReason.STUCK); } else { diff --git a/src/main/java/net/citizensnpcs/npc/ai/MCNavigationStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/MCNavigationStrategy.java index 175e9bfa8..b3863890c 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/MCNavigationStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/MCNavigationStrategy.java @@ -65,10 +65,9 @@ public class MCNavigationStrategy extends AbstractPathStrategy { } return NMS.isNavigationFinished(navigation); } - + private double distanceSquared() { - return handle.getBukkitEntity().getLocation(HANDLE_LOCATION) - .distanceSquared(target); + return handle.getBukkitEntity().getLocation(HANDLE_LOCATION).distanceSquared(target); } private static final Location HANDLE_LOCATION = new Location(null, 0, 0, 0); diff --git a/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java index 02d97eed2..c79813373 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java @@ -34,14 +34,15 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget { this.target = ((CraftEntity) target).getHandle(); NavigationAbstract nav = NMS.getNavigation(this.handle); this.targetNavigator = nav != null && !params.useNewPathfinder() ? new NavigationFieldWrapper(nav) - : new AStarTargeter(); + : new AStarTargeter(); this.aggro = aggro; } private boolean canAttack() { return attackTicks == 0 - && (handle.getBoundingBox().e > target.getBoundingBox().b && handle.getBoundingBox().b < target - .getBoundingBox().e) && closeEnough(distanceSquared()) && hasLineOfSight(); + && (handle.getBoundingBox().e > target.getBoundingBox().b + && handle.getBoundingBox().b < target.getBoundingBox().e) + && closeEnough(distanceSquared()) && hasLineOfSight(); } @Override @@ -161,7 +162,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget { private void setStrategy() { Location location = target.getBukkitEntity().getLocation(TARGET_LOCATION); strategy = npc.isFlyable() ? new FlyingAStarNavigationStrategy(npc, location, parameters) - : new AStarNavigationStrategy(npc, location, parameters); + : new AStarNavigationStrategy(npc, location, parameters); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java b/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java index 8ffd565a6..fd1afcf45 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java +++ b/src/main/java/net/citizensnpcs/npc/ai/speech/Chat.java @@ -31,16 +31,16 @@ public class Chat implements VocalChord { // chat to the world with CHAT_FORMAT and CHAT_RANGE settings if (!context.hasRecipients()) { - String text = Setting.CHAT_FORMAT.asString().replace("", npc.getName()) - .replace("", context.getMessage()); + String text = Setting.CHAT_FORMAT.asString().replace("", npc.getName()).replace("", + context.getMessage()); talkToBystanders(npc, text, context); return; } // Assumed recipients at this point else if (context.size() <= 1) { - String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()) - .replace("", context.getMessage()); + String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()).replace("", + context.getMessage()); String targetName = ""; // For each recipient for (Talkable entity : context) { @@ -58,8 +58,8 @@ public class Chat implements VocalChord { } else { // Multiple recipients - String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()) - .replace("", context.getMessage()); + String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("", npc.getName()).replace("", + context.getMessage()); List targetNames = new ArrayList(); // Talk to each recipient for (Talkable entity : context) { diff --git a/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java b/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java index 7fd8563b3..0453cddd8 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java +++ b/src/main/java/net/citizensnpcs/npc/ai/speech/TalkableEntity.java @@ -31,8 +31,7 @@ public class TalkableEntity implements Talkable { /** * Used to compare a LivingEntity to this TalkableEntity * - * @return 0 if the Entities are the same, 1 if they are not, -1 if the - * object compared is not a valid LivingEntity + * @return 0 if the Entities are the same, 1 if they are not, -1 if the object compared is not a valid LivingEntity */ @Override public int compareTo(Object o) { @@ -40,8 +39,7 @@ public class TalkableEntity implements Talkable { if (!(o instanceof Entity)) { return -1; // If NPC and matches, return 0 - } else if (CitizensAPI.getNPCRegistry().isNPC((Entity) o) - && CitizensAPI.getNPCRegistry().isNPC(entity) + } else if (CitizensAPI.getNPCRegistry().isNPC((Entity) o) && CitizensAPI.getNPCRegistry().isNPC(entity) && CitizensAPI.getNPCRegistry().getNPC((Entity) o).getUniqueId() .equals(CitizensAPI.getNPCRegistry().getNPC(entity).getUniqueId())) { return 0; diff --git a/src/main/java/net/citizensnpcs/npc/entity/BatController.java b/src/main/java/net/citizensnpcs/npc/entity/BatController.java index 45a8d7acc..1805eda5a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/BatController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/BatController.java @@ -60,14 +60,14 @@ public class BatController extends MobEntityController { @Override protected String bo() { - return npc == null || !npc.data().has(NPC.HURT_SOUND_METADATA) ? super.bo() : npc.data().get( - NPC.HURT_SOUND_METADATA, super.bo()); + return npc == null || !npc.data().has(NPC.HURT_SOUND_METADATA) ? super.bo() + : npc.data().get(NPC.HURT_SOUND_METADATA, super.bo()); } @Override protected String bp() { - return npc == null || !npc.data().has(NPC.DEATH_SOUND_METADATA) ? super.bp() : npc.data().get( - NPC.DEATH_SOUND_METADATA, super.bp()); + return npc == null || !npc.data().has(NPC.DEATH_SOUND_METADATA) ? super.bp() + : npc.data().get(NPC.DEATH_SOUND_METADATA, super.bp()); } @Override @@ -156,8 +156,8 @@ public class BatController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/BlazeController.java b/src/main/java/net/citizensnpcs/npc/entity/BlazeController.java index cc207d1ca..a13e1247e 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/BlazeController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/BlazeController.java @@ -145,8 +145,8 @@ public class BlazeController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CaveSpiderController.java b/src/main/java/net/citizensnpcs/npc/entity/CaveSpiderController.java index d7b3d2cb3..5cc665d56 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CaveSpiderController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CaveSpiderController.java @@ -182,8 +182,8 @@ public class CaveSpiderController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/ChickenController.java b/src/main/java/net/citizensnpcs/npc/entity/ChickenController.java index 7f6024057..ed24de659 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/ChickenController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/ChickenController.java @@ -191,8 +191,8 @@ public class ChickenController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CowController.java b/src/main/java/net/citizensnpcs/npc/entity/CowController.java index 654d6c9e8..1dbe89449 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CowController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CowController.java @@ -192,8 +192,8 @@ public class CowController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/CreeperController.java b/src/main/java/net/citizensnpcs/npc/entity/CreeperController.java index 4429932d1..f36793636 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CreeperController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CreeperController.java @@ -192,8 +192,8 @@ public class CreeperController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java index d84766449..fb3e948e8 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java @@ -162,8 +162,8 @@ public class EnderDragonController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/EndermanController.java b/src/main/java/net/citizensnpcs/npc/entity/EndermanController.java index cfc453abf..4e11d7ac6 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EndermanController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EndermanController.java @@ -186,8 +186,8 @@ public class EndermanController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/EndermiteController.java b/src/main/java/net/citizensnpcs/npc/entity/EndermiteController.java index d13415805..d035d74e1 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EndermiteController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EndermiteController.java @@ -178,8 +178,8 @@ public class EndermiteController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/GiantController.java b/src/main/java/net/citizensnpcs/npc/entity/GiantController.java index ec6b8ce3c..753cc6091 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/GiantController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/GiantController.java @@ -157,8 +157,8 @@ public class GiantController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/GuardianController.java b/src/main/java/net/citizensnpcs/npc/entity/GuardianController.java index 44365dedf..268f1f42c 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/GuardianController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/GuardianController.java @@ -1,5 +1,12 @@ package net.citizensnpcs.npc.entity; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.CraftServer; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftGuardian; +import org.bukkit.entity.Guardian; +import org.bukkit.util.Vector; + import net.citizensnpcs.api.event.NPCPushEvent; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.npc.CitizensNPC; @@ -13,13 +20,6 @@ import net.minecraft.server.v1_8_R3.EntityGuardian; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_8_R3.CraftServer; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftGuardian; -import org.bukkit.entity.Guardian; -import org.bukkit.util.Vector; - public class GuardianController extends MobEntityController { public GuardianController() { super(EntityGuardianNPC.class); @@ -42,18 +42,6 @@ public class GuardianController extends MobEntityController { this.npc = (CitizensNPC) npc; if (npc != null) { NMS.clearGoals(goalSelector, targetSelector); - - } - } - - @Override - public void setElder(boolean flag) { - float oldw = width; - float oldl = length; - super.setElder(flag); - if (oldw != width || oldl != length) { - this.setPosition(locX - 0.01, locY, locZ - 0.01); - this.setPosition(locX + 0.01, locY, locZ + 0.01); } } @@ -116,14 +104,6 @@ public class GuardianController extends MobEntityController { } } - @Override - public void E() { - super.E(); - if (npc != null) { - npc.update(); - } - } - @Override public void g(double x, double y, double z) { if (npc == null) { @@ -180,13 +160,26 @@ public class GuardianController extends MobEntityController { public void m() { if (npc == null) { super.m(); + } else { + npc.update(); + } + } + + @Override + public void setElder(boolean flag) { + float oldw = width; + float oldl = length; + super.setElder(flag); + if (oldw != width || oldl != length) { + this.setPosition(locX - 0.01, locY, locZ - 0.01); + this.setPosition(locX + 0.01, locY, locZ + 0.01); } } @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/HorseController.java b/src/main/java/net/citizensnpcs/npc/entity/HorseController.java index 56f347c5a..c7224239b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/HorseController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/HorseController.java @@ -188,8 +188,8 @@ public class HorseController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/HumanController.java b/src/main/java/net/citizensnpcs/npc/entity/HumanController.java index d9cf06905..933e8bdf4 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/HumanController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/HumanController.java @@ -97,31 +97,32 @@ public class HumanController extends AbstractEntityController { } private void updateSkin(final NPC npc, final WorldServer nmsWorld, GameProfile profile) { - + String skinUUID = npc.data().get(NPC.PLAYER_SKIN_UUID_METADATA); if (skinUUID == null) { skinUUID = npc.getName(); } - if (npc.data().has(CACHED_SKIN_UUID_METADATA) - && npc.data().has(CACHED_SKIN_UUID_NAME_METADATA) + if (npc.data().has(CACHED_SKIN_UUID_METADATA) && npc.data().has(CACHED_SKIN_UUID_NAME_METADATA) && ChatColor.stripColor(skinUUID).equalsIgnoreCase( ChatColor.stripColor(npc.data(). get(CACHED_SKIN_UUID_NAME_METADATA)))) { skinUUID = npc.data().get(CACHED_SKIN_UUID_METADATA); } - if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)&&npc.data().get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache")) { - SKIN_THREAD.addRunnable(new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().aD(), - npc)); - return; - } + if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES) + && npc.data(). get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache")) { + SKIN_THREAD.addRunnable( + new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().aD(), npc)); + return; + } Property cached = TEXTURE_CACHE.get(skinUUID); - if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)&&npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN)) { - cached = new Property("textures",npc.data().get(PLAYER_SKIN_TEXTURE_PROPERTIES),npc.data().get(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN)); + if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES) && npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN)) { + cached = new Property("textures", npc.data(). get(PLAYER_SKIN_TEXTURE_PROPERTIES), + npc.data(). get(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN)); } if (cached != null) { profile.getProperties().put("textures", cached); } else { - SKIN_THREAD.addRunnable(new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().aD(), - npc)); + SKIN_THREAD.addRunnable( + new SkinFetcher(new UUIDFetcher(skinUUID, npc), nmsWorld.getMinecraftServer().aD(), npc)); } } @@ -141,13 +142,13 @@ public class HumanController extends AbstractEntityController { */ private GameProfile fillProfileProperties(YggdrasilAuthenticationService auth, GameProfile profile, boolean requireSecure) throws Exception { - URL url = HttpAuthenticationService.constantURL(new StringBuilder() - .append("https://sessionserver.mojang.com/session/minecraft/profile/") - .append(UUIDTypeAdapter.fromUUID(profile.getId())).toString()); + URL url = HttpAuthenticationService.constantURL( + new StringBuilder().append("https://sessionserver.mojang.com/session/minecraft/profile/") + .append(UUIDTypeAdapter.fromUUID(profile.getId())).toString()); url = HttpAuthenticationService.concatenateURL(url, new StringBuilder().append("unsigned=").append(!requireSecure).toString()); - MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke( - auth, url, null, MinecraftProfilePropertiesResponse.class); + MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(auth, + url, null, MinecraftProfilePropertiesResponse.class); if (response == null) { return profile; } @@ -167,10 +168,11 @@ public class HumanController extends AbstractEntityController { } GameProfile skinProfile = null; Property cached = TEXTURE_CACHE.get(realUUID); - if (cached != null && !(npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)&&npc.data().get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache"))) { + if (cached != null && !(npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES) + && npc.data(). get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache"))) { if (Messaging.isDebugging()) { Messaging - .debug("Using cached skin texture for NPC " + npc.getName() + " UUID " + npc.getUniqueId()); + .debug("Using cached skin texture for NPC " + npc.getName() + " UUID " + npc.getUniqueId()); } skinProfile = new GameProfile(UUID.fromString(realUUID), ""); skinProfile.getProperties().put("textures", cached); @@ -181,8 +183,8 @@ public class HumanController extends AbstractEntityController { new GameProfile(UUID.fromString(realUUID), ""), true); } catch (Exception e) { if ((e.getMessage() != null && e.getMessage().contains("too many requests")) - || (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage() - .contains("too many requests"))) { + || (e.getCause() != null && e.getCause().getMessage() != null + && e.getCause().getMessage().contains("too many requests"))) { SKIN_THREAD.delay(); SKIN_THREAD.addRunnable(this); } @@ -194,13 +196,14 @@ public class HumanController extends AbstractEntityController { Property textures = Iterables.getFirst(skinProfile.getProperties().get("textures"), null); if (textures.getValue() == null || textures.getSignature() == null) return; - if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)&&npc.data().get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache")) { - npc.data().setPersistent(PLAYER_SKIN_TEXTURE_PROPERTIES, textures.getValue()); - npc.data().setPersistent(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN, textures.getSignature()); + if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES) + && npc.data(). get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache")) { + npc.data().setPersistent(PLAYER_SKIN_TEXTURE_PROPERTIES, textures.getValue()); + npc.data().setPersistent(PLAYER_SKIN_TEXTURE_PROPERTIES_SIGN, textures.getSignature()); } if (Messaging.isDebugging()) { - Messaging.debug("Fetched skin texture for UUID " + realUUID + " for NPC " + npc.getName() - + " UUID " + npc.getUniqueId()); + Messaging.debug("Fetched skin texture for UUID " + realUUID + " for NPC " + npc.getName() + " UUID " + + npc.getUniqueId()); } TEXTURE_CACHE.put(realUUID, new Property("textures", textures.getValue(), textures.getSignature())); } @@ -282,21 +285,21 @@ public class HumanController extends AbstractEntityController { .getGameProfileRepository(); repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT, new ProfileLookupCallback() { - @Override - public void onProfileLookupFailed(GameProfile arg0, Exception arg1) { - } + @Override + public void onProfileLookupFailed(GameProfile arg0, Exception arg1) { + } - @Override - public void onProfileLookupSucceeded(final GameProfile profile) { - UUID_CACHE.put(reportedUUID, profile.getId().toString()); - if (Messaging.isDebugging()) { - Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName() - + " UUID " + npc.getUniqueId()); - } - npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString()); - npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName()); - } - }); + @Override + public void onProfileLookupSucceeded(final GameProfile profile) { + UUID_CACHE.put(reportedUUID, profile.getId().toString()); + if (Messaging.isDebugging()) { + Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName() + + " UUID " + npc.getUniqueId()); + } + npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString()); + npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName()); + } + }); return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID); } } @@ -309,6 +312,7 @@ public class HumanController extends AbstractEntityController { private static SkinThread SKIN_THREAD; private static final Map TEXTURE_CACHE = Maps.newConcurrentMap(); private static final Map UUID_CACHE = Maps.newConcurrentMap(); + static { try { MAKE_REQUEST = YggdrasilAuthenticationService.class.getDeclaredMethod("makeRequest", URL.class, diff --git a/src/main/java/net/citizensnpcs/npc/entity/IronGolemController.java b/src/main/java/net/citizensnpcs/npc/entity/IronGolemController.java index e64602329..47e2f829c 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/IronGolemController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/IronGolemController.java @@ -164,8 +164,8 @@ public class IronGolemController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/MagmaCubeController.java b/src/main/java/net/citizensnpcs/npc/entity/MagmaCubeController.java index db19edc5c..ece0db224 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/MagmaCubeController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/MagmaCubeController.java @@ -165,8 +165,8 @@ public class MagmaCubeController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/MushroomCowController.java b/src/main/java/net/citizensnpcs/npc/entity/MushroomCowController.java index 49e9e2bbb..fd07c1024 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/MushroomCowController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/MushroomCowController.java @@ -176,8 +176,8 @@ public class MushroomCowController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/OcelotController.java b/src/main/java/net/citizensnpcs/npc/entity/OcelotController.java index 5f89a1b35..31bcc360c 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/OcelotController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/OcelotController.java @@ -175,8 +175,8 @@ public class OcelotController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/PigController.java b/src/main/java/net/citizensnpcs/npc/entity/PigController.java index a1483ad38..c05219f6a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/PigController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/PigController.java @@ -184,8 +184,8 @@ public class PigController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/PigZombieController.java b/src/main/java/net/citizensnpcs/npc/entity/PigZombieController.java index b7d3de934..844777b02 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/PigZombieController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/PigZombieController.java @@ -166,8 +166,8 @@ public class PigZombieController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SheepController.java b/src/main/java/net/citizensnpcs/npc/entity/SheepController.java index 717b768c2..13f078626 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SheepController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SheepController.java @@ -175,8 +175,8 @@ public class SheepController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SilverfishController.java b/src/main/java/net/citizensnpcs/npc/entity/SilverfishController.java index 62634b8b0..c0ac8bd8e 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SilverfishController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SilverfishController.java @@ -164,8 +164,8 @@ public class SilverfishController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SkeletonController.java b/src/main/java/net/citizensnpcs/npc/entity/SkeletonController.java index 2acf31ccf..e9c2d6650 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SkeletonController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SkeletonController.java @@ -165,8 +165,8 @@ public class SkeletonController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SlimeController.java b/src/main/java/net/citizensnpcs/npc/entity/SlimeController.java index 3b89d9299..9d2bd7557 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SlimeController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SlimeController.java @@ -185,8 +185,8 @@ public class SlimeController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SnowmanController.java b/src/main/java/net/citizensnpcs/npc/entity/SnowmanController.java index 5bb42c3be..2dc95fccc 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SnowmanController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SnowmanController.java @@ -164,8 +164,8 @@ public class SnowmanController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SpiderController.java b/src/main/java/net/citizensnpcs/npc/entity/SpiderController.java index 107b63121..e1f804e3f 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SpiderController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SpiderController.java @@ -164,8 +164,8 @@ public class SpiderController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/SquidController.java b/src/main/java/net/citizensnpcs/npc/entity/SquidController.java index b37aeb85b..34e08f94e 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/SquidController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/SquidController.java @@ -157,8 +157,8 @@ public class SquidController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/VillagerController.java b/src/main/java/net/citizensnpcs/npc/entity/VillagerController.java index fd627cf86..0342647f0 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/VillagerController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/VillagerController.java @@ -193,8 +193,8 @@ public class VillagerController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/WitchController.java b/src/main/java/net/citizensnpcs/npc/entity/WitchController.java index d37b680b9..cb7b0fbd9 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/WitchController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/WitchController.java @@ -164,8 +164,8 @@ public class WitchController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/WitherController.java b/src/main/java/net/citizensnpcs/npc/entity/WitherController.java index 444a541f5..c1541cf5b 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/WitherController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/WitherController.java @@ -140,8 +140,8 @@ public class WitherController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/WolfController.java b/src/main/java/net/citizensnpcs/npc/entity/WolfController.java index 8303d8e48..3c31ca994 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/WolfController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/WolfController.java @@ -177,8 +177,8 @@ public class WolfController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/ZombieController.java b/src/main/java/net/citizensnpcs/npc/entity/ZombieController.java index 151c489d3..f6bf45f49 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/ZombieController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/ZombieController.java @@ -165,8 +165,8 @@ public class ZombieController extends MobEntityController { @Override protected String z() { - return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( - NPC.AMBIENT_SOUND_METADATA, super.z()); + return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() + : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.z()); } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/nonliving/FallingBlockController.java b/src/main/java/net/citizensnpcs/npc/entity/nonliving/FallingBlockController.java index b65a80fd4..833b64579 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/nonliving/FallingBlockController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/nonliving/FallingBlockController.java @@ -37,8 +37,8 @@ public class FallingBlockController extends AbstractEntityController { Block id = Blocks.STONE; int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0)); if (npc.data().has("falling-block-id") || npc.data().has(NPC.ITEM_ID_METADATA)) { - id = CraftMagicNumbers.getBlock(Material.getMaterial(npc.data(). get(NPC.ITEM_ID_METADATA, - npc.data(). get("falling-block-id")))); + id = CraftMagicNumbers.getBlock(Material.getMaterial( + npc.data(). get(NPC.ITEM_ID_METADATA, npc.data(). get("falling-block-id")))); } final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(), id.fromLegacyData(data)); diff --git a/src/main/java/net/citizensnpcs/trait/Controllable.java b/src/main/java/net/citizensnpcs/trait/Controllable.java index d9a429e4f..c95999e9c 100644 --- a/src/main/java/net/citizensnpcs/trait/Controllable.java +++ b/src/main/java/net/citizensnpcs/trait/Controllable.java @@ -372,6 +372,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab private static final Map> controllerTypes = Maps .newEnumMap(EntityType.class); + static { controllerTypes.put(EntityType.BAT, PlayerInputAirController.class); controllerTypes.put(EntityType.BLAZE, PlayerInputAirController.class); diff --git a/src/main/java/net/citizensnpcs/trait/LookClose.java b/src/main/java/net/citizensnpcs/trait/LookClose.java index 5ee930675..d714ed99b 100644 --- a/src/main/java/net/citizensnpcs/trait/LookClose.java +++ b/src/main/java/net/citizensnpcs/trait/LookClose.java @@ -30,8 +30,8 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable } private boolean canSeeTarget() { - return realisticLooking && npc.getEntity() instanceof LivingEntity ? ((LivingEntity) npc.getEntity()) - .hasLineOfSight(lookingAt) : true; + return realisticLooking && npc.getEntity() instanceof LivingEntity + ? ((LivingEntity) npc.getEntity()).hasLineOfSight(lookingAt) : true; } @Override diff --git a/src/main/java/net/citizensnpcs/trait/WolfModifiers.java b/src/main/java/net/citizensnpcs/trait/WolfModifiers.java index 78a6f6ff5..fb02c9b79 100644 --- a/src/main/java/net/citizensnpcs/trait/WolfModifiers.java +++ b/src/main/java/net/citizensnpcs/trait/WolfModifiers.java @@ -58,7 +58,7 @@ public class WolfModifiers extends Trait { } } - public DyeColor getCollarColor() { - return collarColor; - } + public DyeColor getCollarColor() { + return collarColor; + } } diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java b/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java index 83102d6b4..11ba45522 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/GuidedWaypointProvider.java @@ -111,9 +111,8 @@ public class GuidedWaypointProvider implements WaypointProvider { @EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { - if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL - || event.getAction() == Action.RIGHT_CLICK_AIR - || event.getAction() == Action.RIGHT_CLICK_BLOCK + if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL + || event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null) return; if (event.getPlayer().getWorld() != npc.getEntity().getWorld()) @@ -206,13 +205,13 @@ public class GuidedWaypointProvider implements WaypointProvider { tree = PRTree.create(new Region3D.Converter(), 30); tree.load(Lists.newArrayList(Iterables.transform(Iterables. concat(available, helpers), new Function>() { - @Override - public Region3D apply(Waypoint arg0) { - Location loc = arg0.getLocation(); - Vector root = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - return new Region3D(root, root, arg0); - } - }))); + @Override + public Region3D apply(Waypoint arg0) { + Location loc = arg0.getLocation(); + Vector root = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + return new Region3D(root, root, arg0); + } + }))); } @Override @@ -337,10 +336,10 @@ public class GuidedWaypointProvider implements WaypointProvider { @Override public Iterable getNeighbours() { - List>> res = tree.nearestNeighbour(Region3D - . distanceCalculator(), Region3D. alwaysAcceptNodeFilter(), 15, - new SimplePointND(waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(), waypoint - .getLocation().getBlockZ())); + List>> res = tree.nearestNeighbour( + Region3D. distanceCalculator(), Region3D. alwaysAcceptNodeFilter(), 15, + new SimplePointND(waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(), + waypoint.getLocation().getBlockZ())); return Iterables.transform(res, new Function>, AStarNode>() { @Override public AStarNode apply(DistanceResult> arg0) { diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index 008566119..8b0537b6f 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -274,8 +274,8 @@ public class LinearWaypointProvider implements WaypointProvider { markers.createWaypointMarker(element); } editingSlot = Math.min(editingSlot + 1, waypoints.size()); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT, formatLoc(at), - 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(); @@ -297,8 +297,8 @@ public class LinearWaypointProvider implements WaypointProvider { 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())); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, + formatLoc(waypoints.get(editingSlot).getLocation())); } @EventHandler @@ -318,8 +318,8 @@ public class LinearWaypointProvider implements WaypointProvider { editingSlot += diff > 0 ? 1 : -1; } normaliseEditingSlot(); - Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, formatLoc(waypoints - .get(editingSlot).getLocation())); + Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_EDIT_SLOT_SET, editingSlot, + formatLoc(waypoints.get(editingSlot).getLocation())); } private void onWaypointsModified() { @@ -417,9 +417,8 @@ public class LinearWaypointProvider implements WaypointProvider { 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()) { + if (npcLoc.getWorld() != next.getLocation().getWorld() || npcLoc.distanceSquared(next.getLocation()) < npc + .getNavigator().getLocalParameters().distanceMargin()) { return false; } currentDestination = next; @@ -427,10 +426,8 @@ public class LinearWaypointProvider implements WaypointProvider { getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { @Override public void onCompletion(@Nullable CancelReason cancelReason) { - if (npc.isSpawned() - && currentDestination != null - && Util.locationWithinRange(npc.getEntity().getLocation(), - currentDestination.getLocation(), 4)) { + if (npc.isSpawned() && currentDestination != null && Util + .locationWithinRange(npc.getEntity().getLocation(), currentDestination.getLocation(), 4)) { currentDestination.onReach(npc); } selector.finish(); diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java b/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java index 3a87e30c9..b10a83bd3 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/Waypoints.java @@ -42,8 +42,7 @@ public class Waypoints extends Trait { } /** - * Returns the current {@link WaypointProvider}. May be null during - * initialisation. + * Returns the current {@link WaypointProvider}. May be null during initialisation. * * @return The current provider */ @@ -96,8 +95,7 @@ public class Waypoints extends Trait { * Sets the current {@link WaypointProvider} using the given name. * * @param name - * The name of the waypoint provider, registered using - * {@link #registerWaypointProvider(Class, String)} + * The name of the waypoint provider, registered using {@link #registerWaypointProvider(Class, String)} * @return Whether the operation succeeded */ public boolean setWaypointProvider(String name) { @@ -116,8 +114,7 @@ public class Waypoints extends Trait { } /** - * Registers a {@link WaypointProvider}, which can be subsequently used by - * NPCs. + * Registers a {@link WaypointProvider}, which can be subsequently used by NPCs. * * @param clazz * The class of the waypoint provider diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TeleportTriggerPrompt.java b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TeleportTriggerPrompt.java index 0d30adda3..c64b1d3b8 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TeleportTriggerPrompt.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TeleportTriggerPrompt.java @@ -29,7 +29,8 @@ public class TeleportTriggerPrompt extends RegexPrompt implements WaypointTrigge return (Prompt) context.getSessionData("previous"); if (input.equalsIgnoreCase("here")) { Player player = (Player) context.getForWhom(); - context.setSessionData(WaypointTriggerPrompt.CREATED_TRIGGER_KEY, new TeleportTrigger(player.getLocation())); + context.setSessionData(WaypointTriggerPrompt.CREATED_TRIGGER_KEY, + new TeleportTrigger(player.getLocation())); return (Prompt) context.getSessionData(WaypointTriggerPrompt.RETURN_PROMPT_KEY); } String[] parts = Iterables.toArray(Splitter.on(':').split(input), String.class); diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java index e68fa074f..65b1d2219 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java @@ -32,8 +32,8 @@ public class TriggerRemovePrompt extends StringPrompt { try { index = Math.max(0, Integer.parseInt(input) - 1); } catch (NumberFormatException e) { - Messaging - .sendErrorTr((CommandSender) context.getForWhom(), Messages.WAYPOINT_TRIGGER_REMOVE_INVALID_NUMBER); + Messaging.sendErrorTr((CommandSender) context.getForWhom(), + Messages.WAYPOINT_TRIGGER_REMOVE_INVALID_NUMBER); return this; } List triggers = editor.getCurrentWaypoint().getTriggers(); diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerPrompt.java b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerPrompt.java index 58c68a43f..a23a1d562 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerPrompt.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerPrompt.java @@ -6,12 +6,11 @@ import org.bukkit.conversations.Prompt; /** * Marker interface for waypoint trigger prompts. * - * Prompts are expected to return to the prompt specified under the - * {@link #RETURN_PROMPT_KEY} key in the {@link ConversationContext} and to set - * the specified trigger under {@link #CREATED_TRIGGER_KEY} prior to returning. + * Prompts are expected to return to the prompt specified under the {@link #RETURN_PROMPT_KEY} key in the + * {@link ConversationContext} and to set the specified trigger under {@link #CREATED_TRIGGER_KEY} prior to returning. * - * If the returned trigger is null then the prompt is assumed to - * have failed and an error message will be displayed. + * If the returned trigger is null then the prompt is assumed to have failed and an error message will be + * displayed. */ public interface WaypointTriggerPrompt extends Prompt { static final String CREATED_TRIGGER_KEY = "created-trigger"; diff --git a/src/main/java/net/citizensnpcs/util/Anchor.java b/src/main/java/net/citizensnpcs/util/Anchor.java index 21f1d7d0a..c70cc619a 100644 --- a/src/main/java/net/citizensnpcs/util/Anchor.java +++ b/src/main/java/net/citizensnpcs/util/Anchor.java @@ -26,8 +26,8 @@ public class Anchor { public Anchor(String name, Location location) { this.location = location; this.name = name; - this.unloaded_value = location.getWorld().getName() + ';' - + location.getX() + ';' + location.getY() + ';' + location.getZ(); + this.unloaded_value = location.getWorld().getName() + ';' + location.getX() + ';' + location.getY() + ';' + + location.getZ(); } public boolean isLoaded() { @@ -37,8 +37,8 @@ public class Anchor { public boolean load() { try { String[] parts = getUnloadedValue(); - this.location = new Location(Bukkit.getWorld(parts[0]), - Double.valueOf(parts[1]), Double.valueOf(parts[2]), Double.valueOf(parts[3])); + this.location = new Location(Bukkit.getWorld(parts[0]), Double.valueOf(parts[1]), Double.valueOf(parts[2]), + Double.valueOf(parts[3])); } catch (Exception e) { // Still not able to be loaded } @@ -67,8 +67,8 @@ public class Anchor { } /** - * Returns a String[] of the 'world_name, x, y, z' information needed to create the Location - * that is associated with the Anchor, in that order. + * Returns a String[] of the 'world_name, x, y, z' information needed to create the Location that is associated with + * the Anchor, in that order. * * @return a String array of the anchor's location data */ @@ -89,7 +89,8 @@ public class Anchor { @Override public String toString() { String[] parts = getUnloadedValue(); - return "Anchor{Name='" + name + "';World='" + parts[0] + "';Location='" + parts[1] + ',' + parts[2] + ',' + parts[3] + "';}"; + return "Anchor{Name='" + name + "';World='" + parts[0] + "';Location='" + parts[1] + ',' + parts[2] + ',' + + parts[3] + "';}"; } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index 80d743299..5d2b4d1e6 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -95,8 +95,8 @@ public class NMS { if (!flag) return; if (i > 0) { - target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) - * i * 0.5F); + target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, + Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F); handle.motX *= 0.6D; handle.motZ *= 0.6D; } @@ -180,10 +180,10 @@ public class NMS { float f5 = 0.91F; if (entity.onGround) { - f5 = entity.world.getType( - new BlockPosition(MathHelper.floor(entity.locX), + f5 = entity.world + .getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))) - .getBlock().frictionFactor * 0.91F; + .getBlock().frictionFactor * 0.91F; } float f6 = 0.1627714F / (f5 * f5 * f5); @@ -197,10 +197,10 @@ public class NMS { entity.a(f, f1, f3); f5 = 0.91F; if (entity.onGround) { - f5 = entity.world.getType( - new BlockPosition(MathHelper.floor(entity.locX), + f5 = entity.world + .getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))) - .getBlock().frictionFactor * 0.91F; + .getBlock().frictionFactor * 0.91F; } if (entity.k_()) { @@ -224,9 +224,11 @@ public class NMS { entity.motY = 0.2D; } - if ((entity.world.isClientSide) - && ((!entity.world.isLoaded(new BlockPosition((int) entity.locX, 0, (int) entity.locZ))) || (!entity.world - .getChunkAtWorldCoords(new BlockPosition((int) entity.locX, 0, (int) entity.locZ)).o()))) { + if ((entity.world.isClientSide) && ((!entity.world + .isLoaded(new BlockPosition((int) entity.locX, 0, (int) entity.locZ))) + || (!entity.world + .getChunkAtWorldCoords(new BlockPosition((int) entity.locX, 0, (int) entity.locZ)) + .o()))) { if (entity.locY > 0.0D) entity.motY = -0.1D; else @@ -255,8 +257,8 @@ public class NMS { } @SuppressWarnings("deprecation") - private static Constructor getCustomEntityConstructor(Class clazz, EntityType type) throws SecurityException, - NoSuchMethodException { + private static Constructor getCustomEntityConstructor(Class clazz, EntityType type) + throws SecurityException, NoSuchMethodException { Constructor constructor = ENTITY_CONSTRUCTOR_CACHE.get(clazz); if (constructor == null) { constructor = clazz.getConstructor(World.class); @@ -485,8 +487,9 @@ public class NMS { } public static void sendPlayerlistPacket(boolean showInPlayerlist, Player npc) { - PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(showInPlayerlist ? EnumPlayerInfoAction.ADD_PLAYER - : EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer) npc).getHandle()); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo( + showInPlayerlist ? EnumPlayerInfoAction.ADD_PLAYER : EnumPlayerInfoAction.REMOVE_PLAYER, + ((CraftPlayer) npc).getHandle()); sendToOnline(packet); } diff --git a/src/main/java/net/citizensnpcs/util/PlayerAnimation.java b/src/main/java/net/citizensnpcs/util/PlayerAnimation.java index 8092d511a..969434c71 100644 --- a/src/main/java/net/citizensnpcs/util/PlayerAnimation.java +++ b/src/main/java/net/citizensnpcs/util/PlayerAnimation.java @@ -74,8 +74,8 @@ public enum PlayerAnimation { SLEEP { @Override protected void playAnimation(EntityPlayer player, int radius) { - PacketPlayOutBed packet = new PacketPlayOutBed(player, new BlockPosition((int) player.locX, - (int) player.locY, (int) player.locZ)); + PacketPlayOutBed packet = new PacketPlayOutBed(player, + new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ)); sendPacketNearby(packet, player, radius); } }, diff --git a/src/main/java/net/citizensnpcs/util/XORShiftRNG.java b/src/main/java/net/citizensnpcs/util/XORShiftRNG.java index 09cd6d51f..2d434a688 100644 --- a/src/main/java/net/citizensnpcs/util/XORShiftRNG.java +++ b/src/main/java/net/citizensnpcs/util/XORShiftRNG.java @@ -20,10 +20,10 @@ import java.util.concurrent.locks.ReentrantLock; /** *

- * Very fast pseudo random number generator. See this page for a description. This RNG has a period of about 2^160, which - * is not as long as the {@link MersenneTwisterRNG} but it is faster. + * Very fast pseudo random number generator. See + * this page for a + * description. This RNG has a period of about 2^160, which is not as long as the {@link MersenneTwisterRNG} but it is + * faster. *

* *

@@ -103,8 +103,8 @@ public class XORShiftRNG extends Random { private static final long serialVersionUID = -1843001897066722618L; /** - * Take four bytes from the specified position in the specified block and - * convert them into a 32-bit int, using the big-endian convention. + * Take four bytes from the specified position in the specified block and convert them into a 32-bit int, using the + * big-endian convention. * * @param bytes * The data to read from. @@ -118,8 +118,8 @@ public class XORShiftRNG extends Random { } /** - * Convert an array of bytes into an array of ints. 4 bytes from the input - * data map to a single int in the output data. + * Convert an array of bytes into an array of ints. 4 bytes from the input data map to a single int in the output + * data. * * @param bytes * The data to read from. diff --git a/src/main/java/net/citizensnpcs/util/nms/PlayerNavigation.java b/src/main/java/net/citizensnpcs/util/nms/PlayerNavigation.java index e4b1c08ba..d9a328078 100644 --- a/src/main/java/net/citizensnpcs/util/nms/PlayerNavigation.java +++ b/src/main/java/net/citizensnpcs/util/nms/PlayerNavigation.java @@ -61,8 +61,8 @@ public class PlayerNavigation extends NavigationAbstract { BlockPosition localBlockPosition = new BlockPosition(this.b); int k = (int) (f1 + 8.0F); - ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), localBlockPosition.a(k, - k, k), 0); + ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), + localBlockPosition.a(k, k, k), 0); PathEntity localPathEntity = this.j.a(localChunkCache, this.b, paramBlockPosition, f1); this.c.methodProfiler.b(); return localPathEntity; @@ -95,8 +95,8 @@ public class PlayerNavigation extends NavigationAbstract { BlockPosition localBlockPosition = new BlockPosition(this.b).up(); int k = (int) (f1 + 16.0F); - ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), localBlockPosition.a(k, - k, k), 0); + ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), + localBlockPosition.a(k, k, k), 0); PathEntity localPathEntity = this.j.a(localChunkCache, this.b, paramEntity, f1); this.c.methodProfiler.b(); return localPathEntity; @@ -411,13 +411,14 @@ public class PlayerNavigation extends NavigationAbstract { } int i = (int) this.b.getBoundingBox().b; - Block localBlock = this.c.getType( - new BlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ))).getBlock(); + Block localBlock = this.c + .getType(new BlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ))).getBlock(); int j = 0; while ((localBlock == Blocks.FLOWING_WATER) || (localBlock == Blocks.WATER)) { i++; - localBlock = this.c.getType( - new BlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ))).getBlock(); + localBlock = this.c + .getType(new BlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ))) + .getBlock(); j++; if (j > 16) { return (int) this.b.getBoundingBox().b; diff --git a/src/main/java/net/citizensnpcs/util/nms/PlayerlistTrackerEntry.java b/src/main/java/net/citizensnpcs/util/nms/PlayerlistTrackerEntry.java index 654a3c431..a9aa99d6f 100644 --- a/src/main/java/net/citizensnpcs/util/nms/PlayerlistTrackerEntry.java +++ b/src/main/java/net/citizensnpcs/util/nms/PlayerlistTrackerEntry.java @@ -25,7 +25,8 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { public void updatePlayer(final EntityPlayer entityplayer) { if (entityplayer != this.tracker && c(entityplayer)) { if (!this.trackedPlayers.contains(entityplayer) - && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, this.tracker.ae, this.tracker.ag)) || (this.tracker.attachedToPlayer))) { + && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, this.tracker.ae, this.tracker.ag)) + || (this.tracker.attachedToPlayer))) { if ((this.tracker instanceof EntityPlayer)) { Player player = ((EntityPlayer) this.tracker).getBukkitEntity(); if (!entityplayer.getBukkitEntity().canSee(player)) { @@ -37,7 +38,8 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { @Override public void run() { entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo( - PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, (EntityPlayer) tracker)); + PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, + (EntityPlayer) tracker)); } }.runTaskLater(CitizensAPI.getPlugin(), 2); }