Fix guardian update method

This commit is contained in:
fullwall 2015-05-26 19:30:58 +08:00
parent c2416d989e
commit 0fa1dff4d6
64 changed files with 409 additions and 375 deletions

View File

@ -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();
}
}

View File

@ -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<EntityPlayer> nearbyNPCs = new ArrayList<EntityPlayer>();
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<EntityPlayer> nearbyNPCs = new ArrayList<EntityPlayer>();
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;
}

View File

@ -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.
*/

View File

@ -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);
}

View File

@ -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();

View File

@ -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<String> added = Lists.newArrayList();
List<String> failed = Lists.newArrayList();

View File

@ -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);
}

View File

@ -57,6 +57,7 @@ public class EquipmentEditor extends Editor {
}
private static final Map<EntityType, Equipper> EQUIPPERS = Maps.newEnumMap(EntityType.class);
static {
EQUIPPERS.put(EntityType.PIG, new PigEquipper());
EQUIPPERS.put(EntityType.SHEEP, new SheepEquipper());

View File

@ -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 {

View File

@ -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);
}

View File

@ -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 {

View File

@ -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());

View File

@ -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 {

View File

@ -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);

View File

@ -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

View File

@ -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>", npc.getName())
.replace("<text>", context.getMessage());
String text = Setting.CHAT_FORMAT.asString().replace("<npc>", npc.getName()).replace("<text>",
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>", npc.getName())
.replace("<text>", context.getMessage());
String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("<npc>", npc.getName()).replace("<text>",
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>", npc.getName())
.replace("<text>", context.getMessage());
String text = Setting.CHAT_FORMAT_TO_TARGET.asString().replace("<npc>", npc.getName()).replace("<text>",
context.getMessage());
List<String> targetNames = new ArrayList<String>();
// Talk to each recipient
for (Talkable entity : context) {

View File

@ -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;

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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().<String> get(CACHED_SKIN_UUID_NAME_METADATA)))) {
skinUUID = npc.data().get(CACHED_SKIN_UUID_METADATA);
}
if (npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)&&npc.data().<String>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().<String> 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().<String>get(PLAYER_SKIN_TEXTURE_PROPERTIES),npc.data().<String>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().<String> get(PLAYER_SKIN_TEXTURE_PROPERTIES),
npc.data().<String> 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().<String>get(PLAYER_SKIN_TEXTURE_PROPERTIES).equals("cache"))) {
if (cached != null && !(npc.data().has(PLAYER_SKIN_TEXTURE_PROPERTIES)
&& npc.data().<String> 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().<String>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().<String> 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<String, Property> TEXTURE_CACHE = Maps.newConcurrentMap();
private static final Map<String, String> UUID_CACHE = Maps.newConcurrentMap();
static {
try {
MAKE_REQUEST = YggdrasilAuthenticationService.class.getDeclaredMethod("makeRequest", URL.class,

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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().<String> get(NPC.ITEM_ID_METADATA,
npc.data().<String> get("falling-block-id"))));
id = CraftMagicNumbers.getBlock(Material.getMaterial(
npc.data().<String> get(NPC.ITEM_ID_METADATA, npc.data().<String> get("falling-block-id"))));
}
final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(),
id.fromLegacyData(data));

View File

@ -372,6 +372,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
.newEnumMap(EntityType.class);
static {
controllerTypes.put(EntityType.BAT, PlayerInputAirController.class);
controllerTypes.put(EntityType.BLAZE, PlayerInputAirController.class);

View File

@ -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

View File

@ -58,7 +58,7 @@ public class WolfModifiers extends Trait {
}
}
public DyeColor getCollarColor() {
return collarColor;
}
public DyeColor getCollarColor() {
return collarColor;
}
}

View File

@ -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<Waypoint>(), 30);
tree.load(Lists.newArrayList(Iterables.transform(Iterables.<Waypoint> concat(available, helpers),
new Function<Waypoint, Region3D<Waypoint>>() {
@Override
public Region3D<Waypoint> apply(Waypoint arg0) {
Location loc = arg0.getLocation();
Vector root = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new Region3D<Waypoint>(root, root, arg0);
}
})));
@Override
public Region3D<Waypoint> apply(Waypoint arg0) {
Location loc = arg0.getLocation();
Vector root = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new Region3D<Waypoint>(root, root, arg0);
}
})));
}
@Override
@ -337,10 +336,10 @@ public class GuidedWaypointProvider implements WaypointProvider {
@Override
public Iterable<AStarNode> getNeighbours() {
List<DistanceResult<Region3D<Waypoint>>> res = tree.nearestNeighbour(Region3D
.<Waypoint> distanceCalculator(), Region3D.<Waypoint> alwaysAcceptNodeFilter(), 15,
new SimplePointND(waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(), waypoint
.getLocation().getBlockZ()));
List<DistanceResult<Region3D<Waypoint>>> res = tree.nearestNeighbour(
Region3D.<Waypoint> distanceCalculator(), Region3D.<Waypoint> alwaysAcceptNodeFilter(), 15,
new SimplePointND(waypoint.getLocation().getBlockX(), waypoint.getLocation().getBlockY(),
waypoint.getLocation().getBlockZ()));
return Iterables.transform(res, new Function<DistanceResult<Region3D<Waypoint>>, AStarNode>() {
@Override
public AStarNode apply(DistanceResult<Region3D<Waypoint>> arg0) {

View File

@ -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();

View File

@ -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

View File

@ -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);

View File

@ -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<WaypointTrigger> triggers = editor.getCurrentWaypoint().getTriggers();

View File

@ -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 <code>null</code> then the prompt is assumed to
* have failed and an error message will be displayed.
* If the returned trigger is <code>null</code> 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";

View File

@ -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] + "';}";
}
}

View File

@ -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);
}

View File

@ -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);
}
},

View File

@ -20,10 +20,10 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* <p>
* Very fast pseudo random number generator. See <a href=
* "http://school.anhb.uwa.edu.au/personalpages/kwessen/shared/Marsaglia03.html"
* >this page</a> 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
* <a href= "http://school.anhb.uwa.edu.au/personalpages/kwessen/shared/Marsaglia03.html" >this page</a> 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.
* </p>
*
* <p>
@ -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.

View File

@ -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;

View File

@ -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);
}