![JAR search and dependency download from the Maven repository](/logo.png)
net.minestom.server.item.component.DebugStickState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.item.component;
import net.kyori.adventure.nbt.BinaryTag;
import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.kyori.adventure.nbt.StringBinaryTag;
import net.minestom.server.utils.nbt.BinaryTagSerializer;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public record DebugStickState(@NotNull Map state) {
public static final DebugStickState EMPTY = new DebugStickState(Map.of());
public static final BinaryTagSerializer NBT_TYPE = BinaryTagSerializer.COMPOUND.map(
tag -> {
Map state = new HashMap<>();
for (Map.Entry entry : tag) {
if (!(entry.getValue() instanceof StringBinaryTag property))
continue;
state.put(entry.getKey(), property.value());
}
return new DebugStickState(state);
},
state -> {
CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder();
for (Map.Entry entry : state.state().entrySet()) {
builder.put(entry.getKey(), StringBinaryTag.stringBinaryTag(entry.getValue()));
}
return builder.build();
}
);
public DebugStickState {
state = Map.copyOf(state);
}
public @NotNull DebugStickState set(@NotNull String key, @NotNull String value) {
Map newState = new HashMap<>(state);
newState.put(key, value);
return new DebugStickState(newState);
}
public @NotNull DebugStickState remove(@NotNull String key) {
Map newState = new HashMap<>(state);
newState.remove(key);
return new DebugStickState(newState);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy