make a single generic class for dummy properties

This commit is contained in:
Pyrbu 2023-07-24 02:02:19 +02:00
parent 6e1d089cc7
commit 993cd10b7a
4 changed files with 26 additions and 40 deletions

@ -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) {

@ -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<Boolean> {
public DummyBooleanProperty(String name, boolean def) {
super(name, def, Boolean.class);
}
@Override
public void apply(Boolean value, Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
}
}

@ -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<T> extends EntityPropertyImpl<T> {
@SuppressWarnings("unchecked")
public DummyProperty(String name, T defaultValue) {
super(name, defaultValue, (Class<T>) defaultValue.getClass());
}
public DummyProperty(String name, Class<T> clazz) {
super(name, null, clazz);
}
@Override
public void apply(T value, Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
}
}

@ -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<SkinDescriptor> {
public SkinProperty() {
super("skin", null, SkinDescriptor.class);
}
@Override
public void apply(SkinDescriptor value, Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
}
}