Global Loot Modifiers

This commit is contained in:
LexManos committed 2023-09-20 15:24:46 -07:00
1 parent dd139115ed
commit af6e848227
63 files changed
+1058 -1502

No files matched your search

@@ -10,9 +10,10 @@ import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@SuppressWarnings("ClassCanBeRecord")
public final class ToolAction
{
import com.mojang.serialization.Codec;
public final class ToolAction {
public static final Codec<ToolAction> CODEC = Codec.STRING.xmap(ToolAction::get, ToolAction::name).stable();
private static final Map<String, ToolAction> actions = new ConcurrentHashMap<>();
/**
@@ -20,30 +21,26 @@ public final class ToolAction
* This collection can be kept around, and will update itself in response to changes to the map.
* See {@link ConcurrentHashMap#values()} for details.
*/
public static Collection<ToolAction> getActions()
{
public static Collection<ToolAction> getActions() {
return Collections.unmodifiableCollection(actions.values());
}
/**
* Gets or creates a new ToolAction for the given name.
*/
public static ToolAction get(String name)
{
public static ToolAction get(String name) {
return actions.computeIfAbsent(name, ToolAction::new);
}
/**
* Returns the name of this tool action
*/
public String name()
{
public String name() {
return name;
}
@Override
public String toString()
{
public String toString() {
return "ToolAction[" + name + "]";
}
@@ -52,8 +49,7 @@ public final class ToolAction
/**
* Use {@link #get(String)} to get or create a ToolAction
*/
private ToolAction(String name)
{
private ToolAction(String name) {
this.name = name;
}
}