Skip to content

Commit

Permalink
Fix shulker color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 1, 2020
1 parent 225ede0 commit 95ab688
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 71 deletions.
8 changes: 2 additions & 6 deletions main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,8 @@ public void update() {
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 {
Expand Down Expand Up @@ -408,7 +405,6 @@ private void updateFlyableState() {
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ public void run() {
entity.getSkinTracker().notifyRemovePacketSent(entry.player.getUniqueId());
}

if (sendAll)
if (sendAll) {
entryIterator.remove();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public void apply(Team team, boolean nameVisibility) {
}
}

if (SUPPORT_TEAM_SETOPTION)

{
if (SUPPORT_TEAM_SETOPTION) {
try {
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisibility ? OptionStatus.ALWAYS : OptionStatus.NEVER);
} catch (NoSuchMethodError e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void run() {
NMS.setPeekShulker(npc.getEntity(), peek);
lastPeekSet = peek;
}
NMS.setShulkerColor((Shulker) npc.getEntity(), color);
((Shulker) npc.getEntity()).setColor(color);
}
}

Expand Down
5 changes: 0 additions & 5 deletions main/src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;
Expand Down Expand Up @@ -402,10 +401,6 @@ public static void setShouldJump(org.bukkit.entity.Entity entity) {
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);
}
Expand Down
3 changes: 0 additions & 3 deletions main/src/main/java/net/citizensnpcs/util/NMSBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,29 +197,6 @@ public void enderTeleportTo(double d0, double d1, double d2) {
}
}

@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)) {
Expand Down Expand Up @@ -269,6 +246,29 @@ public SkinPacketTracker getSkinTracker() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
Expand Down Expand Up @@ -858,10 +857,6 @@ public void setShouldJump(org.bukkit.entity.Entity entity) {
}
}

@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}

@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
Expand Down

0 comments on commit 95ab688

Please sign in to comment.