Fix shulker color setting

This commit is contained in:
fullwall 2020-03-01 15:29:47 +08:00
parent 225ede02ce
commit 95ab688877
14 changed files with 29 additions and 71 deletions

View File

@ -346,11 +346,8 @@ public class CitizensNPC extends AbstractNPC {
updateCustomName();
}
String nameplateVisible = data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
if (nameplateVisible.equals("hover")) {
((LivingEntity) getEntity()).setCustomNameVisible(false);
} else {
((LivingEntity) getEntity()).setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
}
((LivingEntity) getEntity()).setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
if (data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
NMS.setKnockbackResistance((LivingEntity) getEntity(), 1D);
} else {
@ -408,7 +405,6 @@ public class CitizensNPC extends AbstractNPC {
}
private static final SetMultimap<ChunkCoord, NPC> CHUNK_LOADERS = HashMultimap.create();
private static final String NPC_METADATA_MARKER = "NPC";
private static boolean SUPPORT_GLOWING = true;
private static boolean SUPPORT_SILENT = true;

View File

@ -150,8 +150,9 @@ public class TabListRemover {
entity.getSkinTracker().notifyRemovePacketSent(entry.player.getUniqueId());
}
if (sendAll)
if (sendAll) {
entryIterator.remove();
}
}
}
}

View File

@ -48,9 +48,7 @@ public class ScoreboardTrait extends Trait {
}
}
if (SUPPORT_TEAM_SETOPTION)
{
if (SUPPORT_TEAM_SETOPTION) {
try {
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisibility ? OptionStatus.ALWAYS : OptionStatus.NEVER);
} catch (NoSuchMethodError e) {

View File

@ -35,7 +35,7 @@ public class ShulkerTrait extends Trait {
NMS.setPeekShulker(npc.getEntity(), peek);
lastPeekSet = peek;
}
NMS.setShulkerColor((Shulker) npc.getEntity(), color);
((Shulker) npc.getEntity()).setColor(color);
}
}

View File

@ -8,7 +8,6 @@ import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@ -402,10 +401,6 @@ public class NMS {
BRIDGE.setShouldJump(entity);
}
public static void setShulkerColor(Entity entity, DyeColor color) {
BRIDGE.setShulkerColor(entity, color);
}
public static void setSitting(Ocelot ocelot, boolean sitting) {
BRIDGE.setSitting(ocelot, sitting);
}

View File

@ -3,7 +3,6 @@ package net.citizensnpcs.util;
import java.util.Collection;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -135,8 +134,6 @@ public interface NMSBridge {
public void setShouldJump(Entity entity);
public void setShulkerColor(Entity entity, DyeColor color);
public void setSitting(Ocelot ocelot, boolean sitting);
public void setSitting(Tameable tameable, boolean sitting);

View File

@ -920,10 +920,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);

View File

@ -979,10 +979,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);

View File

@ -991,10 +991,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);

View File

@ -1026,10 +1026,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);

View File

@ -1073,10 +1073,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed

View File

@ -197,29 +197,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
}
@Override
public void h(double x, double y, double z) {
if (npc == null) {
super.h(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
super.h(x, y, z);
}
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.h(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
@Override
public CraftPlayer getBukkitEntity() {
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
@ -269,6 +246,29 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
return skinTracker;
}
@Override
public void h(double x, double y, double z) {
if (npc == null) {
super.h(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
super.h(x, y, z);
}
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.h(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}
private void initialise(MinecraftServer minecraftServer) {
Socket socket = new EmptySocket();
NetworkManager conn = null;

View File

@ -1079,10 +1079,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed

View File

@ -16,7 +16,6 @@ import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -858,10 +857,6 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);