Reorder tablist refresh

This commit is contained in:
fullwall 2014-12-28 14:55:15 +08:00
parent bc16fd739d
commit 273a2b358c
4 changed files with 24 additions and 28 deletions

View File

@ -131,7 +131,7 @@ public class EventListen implements Listener {
toRespawn.put(coord, npc); toRespawn.put(coord, npc);
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging 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) { private Location roundLocation(Location input) {
return new Location(input.getWorld(), Math.floor(input.getX()), return new Location(input.getWorld(), Math.floor(input.getX()), Math.floor(input.getY()), Math.floor(input
Math.floor(input.getY()), Math.floor(input.getZ())); .getZ()));
} }
private boolean spawn(NPC npc) { private boolean spawn(NPC npc) {

View File

@ -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.Entity;
import net.minecraft.server.v1_8_R1.EntityPlayer; import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.EnumGamemode; 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.EnumProtocolDirection;
import net.minecraft.server.v1_8_R1.GenericAttributes; import net.minecraft.server.v1_8_R1.GenericAttributes;
import net.minecraft.server.v1_8_R1.MathHelper; import net.minecraft.server.v1_8_R1.MathHelper;
@ -232,8 +231,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
} }
moveOnCurrentHeading(); moveOnCurrentHeading();
} else if (motX != 0 || motZ != 0 || motY != 0) { } else if (motX != 0 || motZ != 0 || motY != 0) {
g(0, 0); // is this necessary? it does controllable but g(0, 0); // is this necessary? it does controllable but sometimes
// sometimes
// players sink into the ground // players sink into the ground
} }

View File

@ -87,8 +87,6 @@ public class HumanController extends AbstractEntityController {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
// Double check that we're still spawned and haven't changed
// type.
if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) {
NMS.sendPlayerlistPacket(false, null, npc); NMS.sendPlayerlistPacket(false, null, npc);
} }
@ -145,8 +143,8 @@ public class HumanController extends AbstractEntityController {
private GameProfile fillProfileProperties(YggdrasilAuthenticationService auth, GameProfile profile, private GameProfile fillProfileProperties(YggdrasilAuthenticationService auth, GameProfile profile,
boolean requireSecure) throws Exception { boolean requireSecure) throws Exception {
URL url = HttpAuthenticationService.constantURL(new StringBuilder() URL url = HttpAuthenticationService.constantURL(new StringBuilder()
.append("https://sessionserver.mojang.com/session/minecraft/profile/") .append("https://sessionserver.mojang.com/session/minecraft/profile/")
.append(UUIDTypeAdapter.fromUUID(profile.getId())).toString()); .append(UUIDTypeAdapter.fromUUID(profile.getId())).toString());
url = HttpAuthenticationService.concatenateURL(url, url = HttpAuthenticationService.concatenateURL(url,
new StringBuilder().append("unsigned=").append(!requireSecure).toString()); new StringBuilder().append("unsigned=").append(!requireSecure).toString());
MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke( MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(
@ -173,7 +171,7 @@ public class HumanController extends AbstractEntityController {
if (cached != null) { if (cached != null) {
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging 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 = new GameProfile(UUID.fromString(realUUID), "");
skinProfile.getProperties().put("textures", cached); skinProfile.getProperties().put("textures", cached);
@ -185,7 +183,7 @@ public class HumanController extends AbstractEntityController {
} catch (Exception e) { } catch (Exception e) {
if ((e.getMessage() != null && e.getMessage().contains("too many requests")) if ((e.getMessage() != null && e.getMessage().contains("too many requests"))
|| (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage() || (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage()
.contains("too many requests"))) { .contains("too many requests"))) {
SKIN_THREAD.delay(); SKIN_THREAD.delay();
SKIN_THREAD.addRunnable(this); SKIN_THREAD.addRunnable(this);
} }
@ -283,21 +281,21 @@ public class HumanController extends AbstractEntityController {
.getGameProfileRepository(); .getGameProfileRepository();
repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT, repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT,
new ProfileLookupCallback() { new ProfileLookupCallback() {
@Override @Override
public void onProfileLookupFailed(GameProfile arg0, Exception arg1) { public void onProfileLookupFailed(GameProfile arg0, Exception arg1) {
} }
@Override @Override
public void onProfileLookupSucceeded(final GameProfile profile) { public void onProfileLookupSucceeded(final GameProfile profile) {
UUID_CACHE.put(reportedUUID, profile.getId().toString()); UUID_CACHE.put(reportedUUID, profile.getId().toString());
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName() Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName()
+ " UUID " + npc.getUniqueId()); + " UUID " + npc.getUniqueId());
} }
npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString()); npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString());
npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName()); npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName());
} }
}); });
return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID); return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID);
} }
} }

View File

@ -495,12 +495,12 @@ public class NMS {
public static void showNPCReset(final Player player, final NPC npc) { public static void showNPCReset(final Player player, final NPC npc) {
sendDestroyPacket(player, npc); sendDestroyPacket(player, npc);
sendPlayerlistPacket(true, player, npc);
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
if (player.isOnline() && player.isValid() && npc.isSpawned() if (player.isOnline() && player.isValid() && npc.isSpawned()
&& npc.getEntity().getType() == EntityType.PLAYER) { && npc.getEntity().getType() == EntityType.PLAYER) {
sendPlayerlistPacket(true, player, npc);
sendSpawnPacket(player, npc); sendSpawnPacket(player, npc);
} }
} }
@ -513,7 +513,7 @@ public class NMS {
sendPlayerlistPacket(false, player, npc); sendPlayerlistPacket(false, player, npc);
} }
} }
}, 2); }, 10);
} }
public static org.bukkit.entity.Entity spawnCustomEntity(org.bukkit.World world, Location at, public static org.bukkit.entity.Entity spawnCustomEntity(org.bukkit.World world, Location at,