From 993cd10b7a13d8c6f4d747b11dd1863ea282665e Mon Sep 17 00:00:00 2001 From: Pyrbu Date: Mon, 24 Jul 2023 02:02:19 +0200 Subject: [PATCH] make a single generic class for dummy properties --- .../entity/EntityPropertyRegistryImpl.java | 5 ++-- .../properties/DummyBooleanProperty.java | 18 --------------- .../entity/properties/DummyProperty.java | 23 +++++++++++++++++++ .../entity/properties/SkinProperty.java | 20 ---------------- 4 files changed, 26 insertions(+), 40 deletions(-) delete mode 100644 plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyBooleanProperty.java create mode 100644 plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyProperty.java delete mode 100644 plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/SkinProperty.java diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java index d6b5ada..026bea6 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/EntityPropertyRegistryImpl.java @@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.entity; import com.github.retrooper.packetevents.protocol.player.EquipmentSlot; import lol.pyr.znpcsplus.api.entity.EntityProperty; import lol.pyr.znpcsplus.api.entity.EntityPropertyRegistry; +import lol.pyr.znpcsplus.api.skin.SkinDescriptor; import lol.pyr.znpcsplus.entity.properties.*; import lol.pyr.znpcsplus.entity.serializers.*; import lol.pyr.znpcsplus.packets.PacketFactory; @@ -250,11 +251,11 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry { register(new EquipmentProperty(packetFactory, "offhand", EquipmentSlot.OFF_HAND)); register(new NameProperty()); - register(new DummyBooleanProperty("look", false)); + register(new DummyProperty<>("look", false)); register(new GlowProperty(packetFactory)); register(new EffectsProperty("fire", 0x01)); register(new EffectsProperty("invisible", 0x20)); - register(new SkinProperty()); + register(new DummyProperty<>("skin", SkinDescriptor.class)); } private void registerSerializer(PropertySerializer serializer) { diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyBooleanProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyBooleanProperty.java deleted file mode 100644 index 105e6ab..0000000 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyBooleanProperty.java +++ /dev/null @@ -1,18 +0,0 @@ -package lol.pyr.znpcsplus.entity.properties; - -import com.github.retrooper.packetevents.protocol.entity.data.EntityData; -import lol.pyr.znpcsplus.entity.EntityPropertyImpl; -import lol.pyr.znpcsplus.entity.PacketEntity; -import org.bukkit.entity.Player; - -import java.util.Map; - -public class DummyBooleanProperty extends EntityPropertyImpl { - public DummyBooleanProperty(String name, boolean def) { - super(name, def, Boolean.class); - } - - @Override - public void apply(Boolean value, Player player, PacketEntity entity, boolean isSpawned, Map properties) { - } -} diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyProperty.java new file mode 100644 index 0000000..e92897c --- /dev/null +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DummyProperty.java @@ -0,0 +1,23 @@ +package lol.pyr.znpcsplus.entity.properties; + +import com.github.retrooper.packetevents.protocol.entity.data.EntityData; +import lol.pyr.znpcsplus.entity.EntityPropertyImpl; +import lol.pyr.znpcsplus.entity.PacketEntity; +import org.bukkit.entity.Player; + +import java.util.Map; + +public class DummyProperty extends EntityPropertyImpl { + @SuppressWarnings("unchecked") + public DummyProperty(String name, T defaultValue) { + super(name, defaultValue, (Class) defaultValue.getClass()); + } + + public DummyProperty(String name, Class clazz) { + super(name, null, clazz); + } + + @Override + public void apply(T value, Player player, PacketEntity entity, boolean isSpawned, Map properties) { + } +} diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/SkinProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/SkinProperty.java deleted file mode 100644 index b0d7579..0000000 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/SkinProperty.java +++ /dev/null @@ -1,20 +0,0 @@ -package lol.pyr.znpcsplus.entity.properties; - -import com.github.retrooper.packetevents.protocol.entity.data.EntityData; -import lol.pyr.znpcsplus.api.skin.SkinDescriptor; -import lol.pyr.znpcsplus.entity.EntityPropertyImpl; -import lol.pyr.znpcsplus.entity.PacketEntity; -import org.bukkit.entity.Player; - -import java.util.Map; - -public class SkinProperty extends EntityPropertyImpl { - public SkinProperty() { - super("skin", null, SkinDescriptor.class); - } - - @Override - public void apply(SkinDescriptor value, Player player, PacketEntity entity, boolean isSpawned, Map properties) { - - } -}