mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-30 12:19:20 +00:00
refactor: Use mappings class for PDC tag type handling
This commit is contained in:
@@ -34,9 +34,9 @@ public class PersistentDataContainerData {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public Optional<BukkitPersistentDataTagType> getTagType(@NotNull final String tagType) {
|
||||
public Optional<PersistentDataTagType> getTagType(@NotNull final String tagType) {
|
||||
if (persistentDataMap.containsKey(tagType)) {
|
||||
return BukkitPersistentDataTagType.getDataType(persistentDataMap.get(tagType).type);
|
||||
return PersistentDataTagType.getDataType(persistentDataMap.get(tagType).type);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -19,16 +19,17 @@ public class PersistentDataTag<T> {
|
||||
*/
|
||||
public T value;
|
||||
|
||||
public PersistentDataTag(@NotNull BukkitPersistentDataTagType type, @NotNull T value) {
|
||||
public PersistentDataTag(@NotNull PersistentDataTagType type, @NotNull T value) {
|
||||
this.type = type.name();
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private PersistentDataTag() {
|
||||
}
|
||||
|
||||
public Optional<BukkitPersistentDataTagType> getType() {
|
||||
return BukkitPersistentDataTagType.getDataType(type);
|
||||
public Optional<PersistentDataTagType> getType() {
|
||||
return PersistentDataTagType.getDataType(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* Represents the type of a {@link PersistentDataTag}
|
||||
*/
|
||||
public enum BukkitPersistentDataTagType {
|
||||
public enum PersistentDataTagType {
|
||||
|
||||
BYTE,
|
||||
SHORT,
|
||||
@@ -23,8 +23,8 @@ public enum BukkitPersistentDataTagType {
|
||||
TAG_CONTAINER;
|
||||
|
||||
|
||||
public static Optional<BukkitPersistentDataTagType> getDataType(@NotNull String typeName) {
|
||||
for (BukkitPersistentDataTagType type : values()) {
|
||||
public static Optional<PersistentDataTagType> getDataType(@NotNull String typeName) {
|
||||
for (PersistentDataTagType type : values()) {
|
||||
if (type.name().equalsIgnoreCase(typeName)) {
|
||||
return Optional.of(type);
|
||||
}
|
||||
Reference in New Issue
Block a user