diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/PropertiesCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/PropertiesCommand.java index 0bfc233..f1e93b7 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/PropertiesCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/PropertiesCommand.java @@ -22,7 +22,6 @@ public class PropertiesCommand implements CommandHandler { if (!npc.getType().getAllowedProperties().contains(property)) context.halt(Component.text("Property " + property.getName() + " not allowed for npc type " + npc.getType().getName())); - // TODO: implement all the parsers for the types used in EntityPropertyImpl Object value = context.parse(property.getType()); npc.UNSAFE_setProperty(property, value); context.send(Component.text("Set property " + property.getName() + " for NPC " + entry.getId() + " to " + value.toString(), NamedTextColor.GREEN)); @@ -33,6 +32,12 @@ public class PropertiesCommand implements CommandHandler { if (context.argSize() == 1) return context.suggestCollection(NpcRegistryImpl.get().modifiableIds()); if (context.argSize() == 2) return context.suggestStream(context.suggestionParse(0, NpcEntryImpl.class) .getNpc().getType().getAllowedProperties().stream().map(EntityPropertyImpl::getName)); + if (context.argSize() == 3) { + EntityPropertyImpl property = context.suggestionParse(1, EntityPropertyImpl.class); + Class type = property.getType(); + if (type == Boolean.class) return context.suggestLiteral("true", "false"); + if (type == NamedTextColor.class) return context.suggestCollection(NamedTextColor.NAMES.keys()); + } return Collections.emptyList(); } } diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyImpl.java index 98b6274..f377463 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyImpl.java @@ -91,11 +91,12 @@ public class EntityPropertyImpl implements EntityProperty { private final static PropertySerializer DESCRIPTOR_SERIALIZER = descriptor -> ((BaseSkinDescriptor) descriptor).serialize(); private final static PropertyDeserializer DESCRIPTOR_DESERIALIZER = BaseSkinDescriptor::deserialize; - public static EntityPropertyImpl SKIN_LAYERS = new EntityPropertyImpl<>("skin_layers", true, BOOLEAN_SERIALIZER, BOOLEAN_DESERIALIZER); - public static EntityPropertyImpl SKIN = new EntityPropertyImpl<>("skin", SkinDescriptor.class, DESCRIPTOR_SERIALIZER, DESCRIPTOR_DESERIALIZER); public static EntityPropertyImpl GLOW = new EntityPropertyImpl<>("glow", NamedTextColor.class, COLOR_SERIALIZER, COLOR_DESERIALIZER); + public static EntityPropertyImpl SKIN_LAYERS = new EntityPropertyImpl<>("skin_layers", true, BOOLEAN_SERIALIZER, BOOLEAN_DESERIALIZER); public static EntityPropertyImpl FIRE = new EntityPropertyImpl<>("fire", false, BOOLEAN_SERIALIZER, BOOLEAN_DESERIALIZER); public static EntityPropertyImpl INVISIBLE = new EntityPropertyImpl<>("invisible", false, BOOLEAN_SERIALIZER, BOOLEAN_DESERIALIZER); public static EntityPropertyImpl SILENT = new EntityPropertyImpl<>("silent", false, BOOLEAN_SERIALIZER, BOOLEAN_DESERIALIZER); + + public static EntityPropertyImpl SKIN = new EntityPropertyImpl<>("skin", SkinDescriptor.class, DESCRIPTOR_SERIALIZER, DESCRIPTOR_DESERIALIZER); public static EntityPropertyImpl NAME = new EntityPropertyImpl<>("name", Component.class, COMPONENT_SERIALIZER, COMPONENT_DESERIALIZER); } \ No newline at end of file diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/PacketEntity.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/PacketEntity.java index 6501712..0b1b126 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/PacketEntity.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/PacketEntity.java @@ -62,6 +62,11 @@ public class PacketEntity { PacketFactory.get().sendAllMetadata(player, this, properties); } + public void remakeTeam(Player player) { + PacketFactory.get().removeTeam(player, this); + PacketFactory.get().createTeam(player, this, properties); + } + private static int reserveEntityID() { if (VersionUtil.isNewerThan(14)) return Reflections.ATOMIC_ENTITY_ID_FIELD.get().incrementAndGet(); else { diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java index 0450ddc..644f861 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java @@ -95,6 +95,10 @@ public class NpcImpl extends Viewable implements Npc { for (Player viewer : getViewers()) entity.refreshMeta(viewer); } + private void _remakeTeam() { + for (Player viewer : getViewers()) entity.remakeTeam(viewer); + } + @SuppressWarnings("unchecked") public T getProperty(EntityProperty key) { return hasProperty(key) ? (T) propertyMap.get((EntityPropertyImpl) key) : key.getDefaultValue(); @@ -108,6 +112,7 @@ public class NpcImpl extends Viewable implements Npc { if (value.equals(key.getDefaultValue())) removeProperty(key); else propertyMap.put(key, value); _refreshMeta(); + if (key == EntityPropertyImpl.GLOW) _remakeTeam(); } @SuppressWarnings("unchecked") @@ -118,6 +123,7 @@ public class NpcImpl extends Viewable implements Npc { public void removeProperty(EntityPropertyImpl key) { propertyMap.remove(key); _refreshMeta(); + if (key == EntityPropertyImpl.GLOW) _remakeTeam(); } public Set> getAppliedProperties() { diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/reflection/ReflectionLazyLoader.java b/plugin/src/main/java/lol/pyr/znpcsplus/reflection/ReflectionLazyLoader.java index 1c92a4a..55a7076 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/reflection/ReflectionLazyLoader.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/reflection/ReflectionLazyLoader.java @@ -34,7 +34,7 @@ public abstract class ReflectionLazyLoader { if (eval == null) throw new RuntimeException("Returned value is null"); } catch (Throwable throwable) { if (strict) { - warn(" ----- REFLECTION FAILURE DEBUG INFORMATION, REPORT THIS ON OUR GITHUB ----- "); + warn(" ----- REFLECTION FAILURE DEBUG INFORMATION, REPORT THIS ON THE ZNPCSPLUS GITHUB ----- "); warn(getClass().getSimpleName() + " failed!"); warn("Class Names: " + possibleClassNames); warn("Reflection Type: " + getClass().getCanonicalName()); @@ -42,7 +42,7 @@ public abstract class ReflectionLazyLoader { printDebugInfo(this::warn); warn("Exception:"); throwable.printStackTrace(); - warn(" ----- REFLECTION FAILURE DEBUG INFORMATION, REPORT THIS ON OUR GITHUB ----- "); + warn(" ----- REFLECTION FAILURE DEBUG INFORMATION, REPORT THIS ON THE ZNPCSPLUS GITHUB ----- "); } } this.loaded = true;