mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-27 18:41:23 +01:00
Fix NPCShopItem cloning
This commit is contained in:
parent
79cf3f7bac
commit
3cd096f84d
@ -586,10 +586,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
try {
|
||||
protocolListener = new ProtocolLibListener(Citizens.this);
|
||||
} catch (Throwable t) {
|
||||
Messaging.severe("ProtocolLib support not enabled: enable debug to see error");
|
||||
if (Messaging.isDebugging()) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
Messaging.severe("ProtocolLib support not enabled due to following error:");
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
saves.loadInto(npcRegistry);
|
||||
|
@ -66,7 +66,6 @@ public class ProtocolLibListener implements Listener {
|
||||
NPC npc = getNPCFromPacket(event);
|
||||
if (npc == null)
|
||||
return;
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
int version = manager.getProtocolVersion(event.getPlayer());
|
||||
if (npc.data().has(NPC.Metadata.HOLOGRAM_RENDERER)) {
|
||||
@ -223,13 +222,15 @@ public class ProtocolLibListener implements Listener {
|
||||
return;
|
||||
|
||||
PacketRotationSession session = trait.getPacketSession(event.getPlayer());
|
||||
|
||||
if (session == null || !session.isActive())
|
||||
return;
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
PacketType type = event.getPacketType();
|
||||
Messaging.debug(session.getBodyYaw(), session.getHeadYaw(),
|
||||
"OVERWRITTEN " + type + " " + packet.getHandle());
|
||||
Messaging.debug("Modifying body/head yaw for", eid, "->", event.getPlayer().getName(),
|
||||
session.getBodyYaw(), degToByte(session.getBodyYaw()), session.getHeadYaw(),
|
||||
degToByte(session.getHeadYaw()), session.getPitch(), type);
|
||||
if (type == Server.ENTITY_HEAD_ROTATION) {
|
||||
packet.getBytes().write(0, degToByte(session.getHeadYaw()));
|
||||
} else if (type == Server.ENTITY_LOOK || type == Server.ENTITY_MOVE_LOOK
|
||||
|
@ -338,7 +338,7 @@ public class ShopTrait extends Trait {
|
||||
@Persist
|
||||
private String clickToConfirmMessage;
|
||||
@Persist
|
||||
private final List<NPCShopAction> cost = Lists.newArrayList();
|
||||
private List<NPCShopAction> cost = Lists.newArrayList();
|
||||
@Persist
|
||||
private String costMessage;
|
||||
@Persist
|
||||
@ -348,7 +348,7 @@ public class ShopTrait extends Trait {
|
||||
@Persist(keyType = UUID.class)
|
||||
private final Map<UUID, Integer> purchases = Maps.newHashMap();
|
||||
@Persist
|
||||
private final List<NPCShopAction> result = Lists.newArrayList();
|
||||
private List<NPCShopAction> result = Lists.newArrayList();
|
||||
@Persist
|
||||
private String resultMessage;
|
||||
@Persist
|
||||
@ -398,12 +398,12 @@ public class ShopTrait extends Trait {
|
||||
public NPCShopItem clone() {
|
||||
try {
|
||||
NPCShopItem dup = (NPCShopItem) super.clone();
|
||||
dup.cost.clear();
|
||||
for (NPCShopAction src : Lists.newArrayList(cost)) {
|
||||
dup.cost = Lists.newArrayList();
|
||||
for (NPCShopAction src : cost) {
|
||||
dup.cost.add(src.clone());
|
||||
}
|
||||
dup.result.clear();
|
||||
for (NPCShopAction src : Lists.newArrayList(result)) {
|
||||
dup.result = Lists.newArrayList();
|
||||
for (NPCShopAction src : result) {
|
||||
dup.result.add(src.clone());
|
||||
}
|
||||
return dup;
|
||||
|
@ -304,5 +304,5 @@ public class Text extends Trait implements Runnable, Listener {
|
||||
return speechBubbles;
|
||||
}
|
||||
|
||||
private static Random RANDOM = Util.getFastRandom();
|
||||
private static final Random RANDOM = Util.getFastRandom();
|
||||
}
|
@ -112,13 +112,14 @@ public class Util {
|
||||
* Clamps the rotation angle to [-180, 180]
|
||||
*/
|
||||
public static float clamp(float angle) {
|
||||
while (angle < -180.0F) {
|
||||
angle += 360.0F;
|
||||
float d = (float) (angle % 360.0);
|
||||
if (d >= 180.0) {
|
||||
d -= 360.0;
|
||||
}
|
||||
while (angle >= 180.0F) {
|
||||
angle -= 360.0F;
|
||||
if (d < -180.0) {
|
||||
d += 360.0;
|
||||
}
|
||||
return angle;
|
||||
return d;
|
||||
}
|
||||
|
||||
public static float clamp(float angle, float min, float max, float d) {
|
||||
|
Loading…
Reference in New Issue
Block a user