Implemented Cat Properties
This commit is contained in:
parent
f472ddf5a5
commit
2d7f573d7d
11 changed files with 133 additions and 6 deletions
25
api/src/main/java/lol/pyr/znpcsplus/util/CatVariant.java
Normal file
25
api/src/main/java/lol/pyr/znpcsplus/util/CatVariant.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package lol.pyr.znpcsplus.util;
|
||||||
|
|
||||||
|
public enum CatVariant {
|
||||||
|
TABBY(0),
|
||||||
|
BLACK(1),
|
||||||
|
RED(2),
|
||||||
|
SIAMESE(3),
|
||||||
|
BRITISH_SHORTHAIR(4),
|
||||||
|
CALICO(5),
|
||||||
|
PERSIAN(6),
|
||||||
|
RAGDOLL(7),
|
||||||
|
WHITE(8),
|
||||||
|
JELLIE(9),
|
||||||
|
ALL_BLACK(10);
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
CatVariant(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
|
@ -280,6 +280,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
|
|
||||||
registerEnumParser(manager, NpcPose.class, incorrectUsageMessage);
|
registerEnumParser(manager, NpcPose.class, incorrectUsageMessage);
|
||||||
registerEnumParser(manager, DyeColor.class, incorrectUsageMessage);
|
registerEnumParser(manager, DyeColor.class, incorrectUsageMessage);
|
||||||
|
registerEnumParser(manager, CatVariant.class, incorrectUsageMessage);
|
||||||
|
|
||||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||||
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
||||||
|
|
|
@ -10,11 +10,13 @@ import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcImpl;
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.NpcPose;
|
import lol.pyr.znpcsplus.util.NpcPose;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -80,6 +82,8 @@ public class PropertySetCommand implements CommandHandler {
|
||||||
if (type == NamedTextColor.class) return context.suggestCollection(NamedTextColor.NAMES.keys());
|
if (type == NamedTextColor.class) return context.suggestCollection(NamedTextColor.NAMES.keys());
|
||||||
if (type == NpcPose.class) return context.suggestEnum(NpcPose.values());
|
if (type == NpcPose.class) return context.suggestEnum(NpcPose.values());
|
||||||
if (type == Color.class) return context.suggestLiteral("0x0F00FF", "#FFFFFF");
|
if (type == Color.class) return context.suggestLiteral("0x0F00FF", "#FFFFFF");
|
||||||
|
if (type == DyeColor.class) return context.suggestEnum(DyeColor.values());
|
||||||
|
if (type == CatVariant.class) return context.suggestEnum(CatVariant.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import lol.pyr.znpcsplus.api.entity.EntityPropertyRegistry;
|
||||||
import lol.pyr.znpcsplus.api.skin.SkinDescriptor;
|
import lol.pyr.znpcsplus.api.skin.SkinDescriptor;
|
||||||
import lol.pyr.znpcsplus.entity.serializers.*;
|
import lol.pyr.znpcsplus.entity.serializers.*;
|
||||||
import lol.pyr.znpcsplus.skin.cache.SkinCache;
|
import lol.pyr.znpcsplus.skin.cache.SkinCache;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.NpcPose;
|
import lol.pyr.znpcsplus.util.NpcPose;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
@ -35,6 +36,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
|
|
||||||
registerEnumSerializer(NpcPose.class);
|
registerEnumSerializer(NpcPose.class);
|
||||||
registerEnumSerializer(DyeColor.class);
|
registerEnumSerializer(DyeColor.class);
|
||||||
|
registerEnumSerializer(CatVariant.class);
|
||||||
|
|
||||||
registerType("glow", NamedTextColor.class);
|
registerType("glow", NamedTextColor.class);
|
||||||
registerType("fire", false);
|
registerType("fire", false);
|
||||||
|
@ -98,6 +100,11 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
// Blaze
|
// Blaze
|
||||||
registerType("blaze_on_fire", false);
|
registerType("blaze_on_fire", false);
|
||||||
|
|
||||||
|
// Cat
|
||||||
|
registerType("cat_variant", CatVariant.BLACK);
|
||||||
|
registerType("cat_lying", false);
|
||||||
|
registerType("cat_collar_color", DyeColor.RED);
|
||||||
|
|
||||||
// Pufferfish
|
// Pufferfish
|
||||||
registerType("puff_state", null); // TODO: Make a puff state enum class
|
registerType("puff_state", null); // TODO: Make a puff state enum class
|
||||||
|
|
||||||
|
@ -149,11 +156,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
registerType("strider_shaking", false); // TODO
|
registerType("strider_shaking", false); // TODO
|
||||||
registerType("strider_saddle", false); // TODO
|
registerType("strider_saddle", false); // TODO
|
||||||
|
|
||||||
// Cat
|
|
||||||
registerType("cat_variant", null); // TODO: Custom type
|
|
||||||
registerType("cat_laying", false); // TODO
|
|
||||||
registerType("cat_collar_color", DyeColor.RED); // TODO
|
|
||||||
|
|
||||||
// Wolf
|
// Wolf
|
||||||
registerType("wolf_collar_color", DyeColor.RED); // TODO
|
registerType("wolf_collar_color", DyeColor.RED); // TODO
|
||||||
registerType("wolf_angry", false); // TODO
|
registerType("wolf_angry", false); // TODO
|
||||||
|
|
|
@ -2,8 +2,10 @@ package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.8 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7415">...</a>
|
* 1.8 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7415">...</a>
|
||||||
|
@ -53,4 +55,10 @@ public interface MetadataFactory {
|
||||||
|
|
||||||
// Blaze
|
// Blaze
|
||||||
EntityData blazeOnFire(boolean onFire);
|
EntityData blazeOnFire(boolean onFire);
|
||||||
|
|
||||||
|
// Cat
|
||||||
|
EntityData catVariant(CatVariant variant);
|
||||||
|
EntityData catLying(boolean lying);
|
||||||
|
EntityData catTamed(boolean tamed);
|
||||||
|
EntityData catCollarColor(DyeColor collarColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package lol.pyr.znpcsplus.metadata;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,4 +77,19 @@ public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
||||||
public EntityData blazeOnFire(boolean onFire) {
|
public EntityData blazeOnFire(boolean onFire) {
|
||||||
return newEntityData(14, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
return newEntityData(14, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catVariant(CatVariant variant) {
|
||||||
|
return newEntityData(17, EntityDataTypes.CAT_VARIANT, variant.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catLying(boolean lying) {
|
||||||
|
throw new UnsupportedOperationException("The cat lying entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catCollarColor(DyeColor collarColor) {
|
||||||
|
return newEntityData(20, EntityDataTypes.INT, collarColor.ordinal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,4 +61,19 @@ public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
||||||
public EntityData blazeOnFire(boolean onFire) {
|
public EntityData blazeOnFire(boolean onFire) {
|
||||||
return newEntityData(15, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
return newEntityData(15, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catVariant(CatVariant variant) {
|
||||||
|
return newEntityData(18, EntityDataTypes.CAT_VARIANT, variant.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catLying(boolean lying) {
|
||||||
|
return newEntityData(19, EntityDataTypes.BOOLEAN, lying);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catCollarColor(DyeColor collarColor) {
|
||||||
|
return newEntityData(21, EntityDataTypes.INT, collarColor.ordinal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,4 +101,24 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
||||||
public EntityData blazeOnFire(boolean onFire) {
|
public EntityData blazeOnFire(boolean onFire) {
|
||||||
return newEntityData(16, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
return newEntityData(16, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catVariant(CatVariant variant) {
|
||||||
|
return newEntityData(19, EntityDataTypes.CAT_VARIANT, variant.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catLying(boolean lying) {
|
||||||
|
return newEntityData(20, EntityDataTypes.BOOLEAN, lying);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catTamed(boolean tamed) {
|
||||||
|
return newEntityData(17, EntityDataTypes.BYTE, (byte) (tamed ? 0x04 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catCollarColor(DyeColor collarColor) {
|
||||||
|
return newEntityData(22, EntityDataTypes.INT, collarColor.ordinal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
public class V1_8MetadataFactory implements MetadataFactory {
|
public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,6 +126,26 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
return newEntityData(16, EntityDataTypes.BYTE, (byte) (onFire ? 1 : 0));
|
return newEntityData(16, EntityDataTypes.BYTE, (byte) (onFire ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catVariant(CatVariant variant) {
|
||||||
|
throw new UnsupportedOperationException("The cat variant entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catLying(boolean lying) {
|
||||||
|
throw new UnsupportedOperationException("The cat lying entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catTamed(boolean tamed) {
|
||||||
|
throw new UnsupportedOperationException("The cat tamed entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData catCollarColor(DyeColor collarColor) {
|
||||||
|
throw new UnsupportedOperationException("The cat collar color entity data isn't supported on this version");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData silent(boolean enabled) {
|
public EntityData silent(boolean enabled) {
|
||||||
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
||||||
|
|
|
@ -54,7 +54,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
||||||
.addProperties("blaze_on_fire"));
|
.addProperties("blaze_on_fire"));
|
||||||
|
|
||||||
register(builder(p, "cat", EntityTypes.CAT)
|
register(builder(p, "cat", EntityTypes.CAT)
|
||||||
.setHologramOffset(-1.275));
|
.setHologramOffset(-1.275)
|
||||||
|
.addProperties("cat_variant", "cat_lying", "cat_collar_color"));
|
||||||
|
|
||||||
register(builder(p, "cave_spider", EntityTypes.CAVE_SPIDER)
|
register(builder(p, "cave_spider", EntityTypes.CAVE_SPIDER)
|
||||||
.setHologramOffset(-1.475));
|
.setHologramOffset(-1.475));
|
||||||
|
|
|
@ -16,6 +16,7 @@ import lol.pyr.znpcsplus.entity.PacketEntity;
|
||||||
import lol.pyr.znpcsplus.metadata.MetadataFactory;
|
import lol.pyr.znpcsplus.metadata.MetadataFactory;
|
||||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||||
import lol.pyr.znpcsplus.skin.BaseSkinDescriptor;
|
import lol.pyr.znpcsplus.skin.BaseSkinDescriptor;
|
||||||
|
import lol.pyr.znpcsplus.util.CatVariant;
|
||||||
import lol.pyr.znpcsplus.util.NpcLocation;
|
import lol.pyr.znpcsplus.util.NpcLocation;
|
||||||
import lol.pyr.znpcsplus.util.PapiUtil;
|
import lol.pyr.znpcsplus.util.PapiUtil;
|
||||||
import lol.pyr.znpcsplus.util.Vector3f;
|
import lol.pyr.znpcsplus.util.Vector3f;
|
||||||
|
@ -23,6 +24,7 @@ import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
@ -178,6 +180,12 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
else if (entity.getType().equals(EntityTypes.BLAZE)) {
|
else if (entity.getType().equals(EntityTypes.BLAZE)) {
|
||||||
add(data, metadataFactory.blazeOnFire(properties.getProperty(propertyRegistry.getByName("blaze_on_fire", Boolean.class))));
|
add(data, metadataFactory.blazeOnFire(properties.getProperty(propertyRegistry.getByName("blaze_on_fire", Boolean.class))));
|
||||||
}
|
}
|
||||||
|
else if (entity.getType().equals(EntityTypes.CAT)) {
|
||||||
|
add(data, metadataFactory.catVariant(properties.getProperty(propertyRegistry.getByName("cat_variant", CatVariant.class))));
|
||||||
|
add(data, metadataFactory.catLying(properties.getProperty(propertyRegistry.getByName("cat_lying", Boolean.class))));
|
||||||
|
add(data, metadataFactory.catCollarColor(properties.getProperty(propertyRegistry.getByName("cat_collar_color", DyeColor.class))));
|
||||||
|
add(data, metadataFactory.catTamed(properties.hasProperty(propertyRegistry.getByName("cat_collar_color", DyeColor.class))));
|
||||||
|
}
|
||||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) {
|
if (properties.hasProperty(propertyRegistry.getByName("name"))) {
|
||||||
add(data, metadataFactory.name(PapiUtil.set(textSerializer, player, properties.getProperty(propertyRegistry.getByName("name", Component.class)))));
|
add(data, metadataFactory.name(PapiUtil.set(textSerializer, player, properties.getProperty(propertyRegistry.getByName("name", Component.class)))));
|
||||||
add(data, metadataFactory.nameShown());
|
add(data, metadataFactory.nameShown());
|
||||||
|
|
Loading…
Reference in a new issue