diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index 0ab64fec6..e3fc260d1 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -131,7 +131,7 @@ 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 + "]"); + .debug("Despawned id", npc.getId(), "due to chunk unload at [" + coord.x + "," + coord.z + "]"); } } } @@ -408,8 +408,8 @@ public class EventListen implements Listener { } private Location roundLocation(Location input) { - return new Location(input.getWorld(), Math.floor(input.getX()), - Math.floor(input.getY()), Math.floor(input.getZ())); + return new Location(input.getWorld(), Math.floor(input.getX()), Math.floor(input.getY()), Math.floor(input + .getZ())); } private boolean spawn(NPC npc) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index 5b3eed33d..0a685a719 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -25,7 +25,6 @@ import net.minecraft.server.v1_8_R1.BlockPosition; import net.minecraft.server.v1_8_R1.Entity; import net.minecraft.server.v1_8_R1.EntityPlayer; import net.minecraft.server.v1_8_R1.EnumGamemode; -import net.minecraft.server.v1_8_R1.EnumPlayerInfoAction; import net.minecraft.server.v1_8_R1.EnumProtocolDirection; import net.minecraft.server.v1_8_R1.GenericAttributes; import net.minecraft.server.v1_8_R1.MathHelper; @@ -232,8 +231,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { } moveOnCurrentHeading(); } else if (motX != 0 || motZ != 0 || motY != 0) { - g(0, 0); // is this necessary? it does controllable but - // sometimes + g(0, 0); // is this necessary? it does controllable but sometimes // players sink into the ground } diff --git a/src/main/java/net/citizensnpcs/npc/entity/HumanController.java b/src/main/java/net/citizensnpcs/npc/entity/HumanController.java index 269bb42da..6051d66b6 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/HumanController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/HumanController.java @@ -87,8 +87,6 @@ public class HumanController extends AbstractEntityController { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { - // Double check that we're still spawned and haven't changed - // type. if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { NMS.sendPlayerlistPacket(false, null, npc); } @@ -145,8 +143,8 @@ 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()); + .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( @@ -173,7 +171,7 @@ public class HumanController extends AbstractEntityController { if (cached != null) { 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); @@ -185,7 +183,7 @@ public class HumanController extends AbstractEntityController { } 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"))) { + .contains("too many requests"))) { SKIN_THREAD.delay(); SKIN_THREAD.addRunnable(this); } @@ -283,21 +281,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); } } diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index ffdb10b9f..2f0e8be93 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -495,12 +495,12 @@ public class NMS { public static void showNPCReset(final Player player, final NPC npc) { sendDestroyPacket(player, npc); + sendPlayerlistPacket(true, player, npc); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { if (player.isOnline() && player.isValid() && npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { - sendPlayerlistPacket(true, player, npc); sendSpawnPacket(player, npc); } } @@ -513,7 +513,7 @@ public class NMS { sendPlayerlistPacket(false, player, npc); } } - }, 2); + }, 10); } public static org.bukkit.entity.Entity spawnCustomEntity(org.bukkit.World world, Location at,