added sniffer_state property
This commit is contained in:
parent
8637b5b5c2
commit
82cd0d1a81
5 changed files with 45 additions and 1 deletions
11
api/src/main/java/lol/pyr/znpcsplus/util/SnifferState.java
Normal file
11
api/src/main/java/lol/pyr/znpcsplus/util/SnifferState.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package lol.pyr.znpcsplus.util;
|
||||
|
||||
public enum SnifferState {
|
||||
IDLING,
|
||||
FEELING_HAPPY,
|
||||
SCENTING,
|
||||
SNIFFING,
|
||||
SEARCHING,
|
||||
DIGGING,
|
||||
RISING
|
||||
}
|
|
@ -279,6 +279,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
registerEnumParser(manager, PuffState.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, LookType.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, TropicalFishVariant.TropicalFishPattern.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, SnifferState.class, incorrectUsageMessage);
|
||||
|
||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||
.addSubcommand("center", new CenterCommand(npcRegistry))
|
||||
|
|
|
@ -77,6 +77,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerEnumSerializer(PandaGene.class);
|
||||
registerEnumSerializer(PuffState.class);
|
||||
registerEnumSerializer(TropicalFishVariant.TropicalFishPattern.class);
|
||||
registerEnumSerializer(SnifferState.class);
|
||||
|
||||
registerPrimitiveSerializers(Integer.class, Boolean.class, Double.class, Float.class, Long.class, Short.class, Byte.class, String.class);
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package lol.pyr.znpcsplus.entity.properties;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
|
||||
import lol.pyr.znpcsplus.entity.PacketEntity;
|
||||
import lol.pyr.znpcsplus.util.SnifferState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SnifferStateProperty extends EntityPropertyImpl<SnifferState> {
|
||||
private final int index;
|
||||
|
||||
public SnifferStateProperty(int index) {
|
||||
super("sniffer_state", SnifferState.IDLING, SnifferState.class);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
|
||||
SnifferState state = entity.getProperty(this);
|
||||
if (state == null) return;
|
||||
try {
|
||||
properties.put(index, newEntityData(index, EntityDataTypes.SNIFFER_STATE, com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState.valueOf(state.name())));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
|
@ -352,7 +352,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
|||
if (!version.isNewerThanOrEquals(ServerVersion.V_1_20)) return;
|
||||
|
||||
register(builder(p, "sniffer", EntityTypes.SNIFFER)
|
||||
.setHologramOffset(0.125));
|
||||
.setHologramOffset(0.125)
|
||||
.addProperties("sniffer_state"));
|
||||
|
||||
register(builder(p, "camel", EntityTypes.CAMEL)
|
||||
.setHologramOffset(0.25)
|
||||
|
|
Loading…
Reference in a new issue