mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-28 19:11:47 +01:00
Fix tablist removing
This commit is contained in:
parent
5b64a7cc57
commit
28ea52c742
@ -41,7 +41,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -284,17 +283,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
boolean removeFromPlayerList = npc.data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||
Player otherOnline = null;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(getName()) && !(player instanceof NPCHolder)) {
|
||||
otherOnline = player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
NMS.sendPlayerlistPacket(false, getBukkitEntity(), npc);
|
||||
if (otherOnline != null) {
|
||||
NMS.sendPlayerlistPacket(true, otherOnline, npc);
|
||||
}
|
||||
NMS.sendPlayerlistPacket(false, getBukkitEntity());
|
||||
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
NMS.sendPlayerlistPacket(false, null, getBukkitEntity());
|
||||
NMS.sendPlayerlistPacket(false, getBukkitEntity());
|
||||
super.remove();
|
||||
}
|
||||
|
||||
@ -133,8 +133,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(
|
||||
@ -161,7 +161,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);
|
||||
@ -173,7 +173,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);
|
||||
}
|
||||
@ -270,21 +270,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);
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class NMS {
|
||||
c1 = 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 f2 = 0.1627714F / (c1 * c1 * c1);
|
||||
@ -156,7 +156,7 @@ public class NMS {
|
||||
c1 = 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;
|
||||
}
|
||||
|
||||
entity.move(entity.motX, entity.motY, entity.motZ);
|
||||
@ -178,7 +178,7 @@ public class NMS {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Constructor<?> getCustomEntityConstructor(Class<?> clazz, EntityType type) throws SecurityException,
|
||||
NoSuchMethodException {
|
||||
NoSuchMethodException {
|
||||
Constructor<?> constructor = ENTITY_CONSTRUCTOR_CACHE.get(clazz);
|
||||
if (constructor == null) {
|
||||
constructor = clazz.getConstructor(World.class);
|
||||
@ -410,25 +410,10 @@ public class NMS {
|
||||
NMS.sendPacketsNearby(from, location, Arrays.asList(packets), 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a PlayerInfo packet (adds or removes the NPC to or from the tab
|
||||
* list) to the player.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the packet to, or null for all players.
|
||||
*/
|
||||
public static void sendPlayerlistPacket(boolean showInPlayerlist, Player player, NPC npc) {
|
||||
sendPlayerlistPacket(showInPlayerlist, player, (CraftPlayer) npc.getEntity());
|
||||
}
|
||||
|
||||
public static void sendPlayerlistPacket(boolean showInPlayerlist, Player player, Player npc) {
|
||||
public static void sendPlayerlistPacket(boolean showInPlayerlist, Player npc) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(showInPlayerlist ? EnumPlayerInfoAction.ADD_PLAYER
|
||||
: EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer) npc).getHandle());
|
||||
if (player == null) {
|
||||
sendToOnline(packet);
|
||||
} else {
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
sendToOnline(packet);
|
||||
}
|
||||
|
||||
public static void sendToOnline(Packet... packets) {
|
||||
|
Loading…
Reference in New Issue
Block a user