Implement `toString` for registry objects

This commit is contained in:
TheMode 2021-08-13 21:15:43 +02:00
parent 1775de52e4
commit 3ff5a7f414
10 changed files with 57 additions and 0 deletions

View File

@ -254,4 +254,9 @@ final class EntityTypeImpl implements EntityType {
public @NotNull Registry.EntityEntry registry() {
return registry;
}
@Override
public String toString() {
return name();
}
}

View File

@ -35,4 +35,9 @@ final class EnchantmentImpl implements Enchantment {
public @NotNull Registry.EnchantmentEntry registry() {
return registry;
}
@Override
public String toString() {
return name();
}
}

View File

@ -144,6 +144,13 @@ public class ItemMeta implements TagReadable, Writeable {
return nbt.hashCode();
}
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
"nbt=" + nbt +
'}';
}
@Contract(value = "-> new", pure = true)
protected @NotNull ItemMetaBuilder builder() {
return ItemMetaBuilder.fromNBT(metaBuilder, nbt);

View File

@ -195,6 +195,16 @@ public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent
return result;
}
@Override
public String toString() {
return "ItemStack{" +
"stackingRule=" + stackingRule +
", material=" + material +
", amount=" + amount +
", meta=" + meta +
'}';
}
@Contract(value = "_, _ -> new", pure = true)
public <T> @NotNull ItemStack withTag(@NotNull Tag<T> tag, @Nullable T value) {
return builder().meta(metaBuilder -> metaBuilder.set(tag, value)).build();

View File

@ -35,4 +35,9 @@ final class MaterialImpl implements Material {
public @NotNull Registry.MaterialEntry registry() {
return registry;
}
@Override
public String toString() {
return name();
}
}

View File

@ -46,4 +46,9 @@ final class ParticleImpl implements Particle {
public int id() {
return id;
}
@Override
public String toString() {
return name();
}
}

View File

@ -35,4 +35,9 @@ final class PotionEffectImpl implements PotionEffect {
public @NotNull Registry.PotionEffectEntry registry() {
return registry;
}
@Override
public String toString() {
return name();
}
}

View File

@ -46,4 +46,9 @@ final class PotionTypeImpl implements PotionType {
public int id() {
return id;
}
@Override
public String toString() {
return name();
}
}

View File

@ -46,4 +46,9 @@ final class SoundEventImpl implements SoundEvent {
public int id() {
return id;
}
@Override
public String toString() {
return name();
}
}

View File

@ -46,4 +46,9 @@ final class StatisticTypeImpl implements StatisticType {
public int id() {
return id;
}
@Override
public String toString() {
return name();
}
}