mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
RepairWildcard wip
This commit is contained in:
parent
3a89ba2139
commit
12964a816d
@ -0,0 +1,22 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.serializers;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.hocon.skills.repair.RepairWildcard;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
public class RepairWildcardSerializer implements TypeSerializer<RepairWildcard> {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public RepairWildcard deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(@NonNull TypeToken<?> type, @Nullable RepairWildcard obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
|||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static org.bukkit.Material.*;
|
import static org.bukkit.Material.*;
|
||||||
|
|
||||||
@ -18,6 +17,7 @@ import static org.bukkit.Material.*;
|
|||||||
public class ConfigRepair {
|
public class ConfigRepair {
|
||||||
|
|
||||||
public static final ArrayList<Repairable> CONFIG_REPAIRABLES_DEFAULTS;
|
public static final ArrayList<Repairable> CONFIG_REPAIRABLES_DEFAULTS;
|
||||||
|
public static final HashSet<RepairWildcard> REPAIR_WILDCARDS_DEFAULTS;
|
||||||
public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS};
|
public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS};
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -70,6 +70,13 @@ public class ConfigRepair {
|
|||||||
CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_LEGGINGS, DIAMOND, 1, 0, 2D));
|
CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_LEGGINGS, DIAMOND, 1, 0, 2D));
|
||||||
CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_BOOTS, DIAMOND, 1, 0, 2D));
|
CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_BOOTS, DIAMOND, 1, 0, 2D));
|
||||||
|
|
||||||
|
REPAIR_WILDCARDS_DEFAULTS = new HashSet<>();
|
||||||
|
|
||||||
|
RepairWildcard repairWildcardPlanks = new RepairWildcard("Planks");
|
||||||
|
List<String> planksList = Arrays.asList(new String[]{OAK_PLANKS.getKey().toString(),
|
||||||
|
BIRCH_PLANKS.getKey().toString(), DARK_OAK_PLANKS.getKey().toString(), ACACIA_PLANKS.getKey().toString(), JUNGLE_PLANKS.getKey().toString(), SPRUCE_PLANKS.getKey().toString()});
|
||||||
|
repairWildcardPlanks.addMatchCandidates(planksList);
|
||||||
|
REPAIR_WILDCARDS_DEFAULTS.add(repairWildcardPlanks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Setting(value = "General")
|
@Setting(value = "General")
|
||||||
@ -90,6 +97,9 @@ public class ConfigRepair {
|
|||||||
"\nTIP: You can omit \"minecraft:\" from the Name ID if you want to, for example you can write \"red_wool\" instead of \"minecraft:red_wool\"")
|
"\nTIP: You can omit \"minecraft:\" from the Name ID if you want to, for example you can write \"red_wool\" instead of \"minecraft:red_wool\"")
|
||||||
private ArrayList<Repairable> configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS;
|
private ArrayList<Repairable> configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS;
|
||||||
|
|
||||||
|
@Setting(value = "Z-Repairables-Wildcards", comment = "Used to define an alias that can be matched to several materials.")
|
||||||
|
private HashSet<RepairWildcard> repairWildcards = new HashSet<>();
|
||||||
|
|
||||||
public ConfigRepairGeneral getRepairGeneral() {
|
public ConfigRepairGeneral getRepairGeneral() {
|
||||||
return repairGeneral;
|
return repairGeneral;
|
||||||
}
|
}
|
||||||
@ -113,4 +123,8 @@ public class ConfigRepair {
|
|||||||
public ArrayList<Repairable> getConfigRepairablesList() {
|
public ArrayList<Repairable> getConfigRepairablesList() {
|
||||||
return configRepairablesList;
|
return configRepairablesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<RepairWildcard> getRepairWildcards() {
|
||||||
|
return repairWildcards;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.gmail.nossr50.config.hocon.skills.repair;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class RepairWildcard {
|
||||||
|
|
||||||
|
private String wildcardName;
|
||||||
|
private ArrayList<String> matchCandidates;
|
||||||
|
|
||||||
|
public RepairWildcard(String wildcardName) {
|
||||||
|
this.wildcardName = wildcardName;
|
||||||
|
matchCandidates = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMatchCandidates(List<String> arrayList) {
|
||||||
|
matchCandidates.addAll(arrayList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getMatchCandidates() {
|
||||||
|
return matchCandidates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWildcardName() {
|
||||||
|
return wildcardName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof RepairWildcard)) return false;
|
||||||
|
RepairWildcard that = (RepairWildcard) o;
|
||||||
|
return getWildcardName().equals(that.getWildcardName()) &&
|
||||||
|
Objects.equals(getMatchCandidates(), that.getMatchCandidates());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getWildcardName(), getMatchCandidates());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user