Created data classes for GlobalOperationItem.
This commit is contained in:
@ -88,7 +88,7 @@ public final class Config {
|
||||
private static void onConfigReload() {
|
||||
blockBreakOperationItems = new ArrayList<>();
|
||||
for (String s : blockBreakOperationsRaw.get()) {
|
||||
blockBreakOperationItems.add(new OperationItem(s));
|
||||
blockBreakOperationItems.add(OperationItem.fromConfig(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package dev.micle.xptools.config;
|
||||
|
||||
import dev.micle.xptools.util.EnumUtils;
|
||||
|
||||
public class GlobalOperationItem extends OperationItem {
|
||||
public GlobalOperationItem(OperationType type, float min, float max, int priority) {
|
||||
super(false, "", type, min, max, priority, false);
|
||||
}
|
||||
|
||||
public static GlobalOperationItem fromConfig(String configString) {
|
||||
String[] splitString = configString.split(",");
|
||||
|
||||
if (splitString.length == 4) {
|
||||
OperationType type = EnumUtils.valueOf(OperationType.class, splitString[0]);
|
||||
float min = Float.parseFloat(splitString[1]);
|
||||
float max = Float.parseFloat(splitString[2]);
|
||||
int priority = Integer.parseInt(splitString[3]);
|
||||
|
||||
return new GlobalOperationItem(type, min, max, priority);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -11,22 +11,31 @@ public class OperationItem {
|
||||
private int priority;
|
||||
private boolean isLast;
|
||||
|
||||
public OperationItem(String configString) {
|
||||
public OperationItem(boolean isTag, String id, OperationType type, float min, float max, int priority, boolean isLast) {
|
||||
this.isTag = isTag;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.priority = priority;
|
||||
this.isLast = isLast;
|
||||
}
|
||||
|
||||
public static OperationItem fromConfig(String configString) {
|
||||
String[] splitString = configString.split(",");
|
||||
|
||||
if (splitString.length == 6) {
|
||||
isTag = splitString[0].startsWith("#");
|
||||
id = isTag ? splitString[0].substring(1) : splitString[0];
|
||||
boolean isTag = splitString[0].startsWith("#");
|
||||
String id = isTag ? splitString[0].substring(1) : splitString[0];
|
||||
OperationType type = EnumUtils.valueOf(OperationType.class, splitString[1]);
|
||||
float min = Float.parseFloat(splitString[2]);
|
||||
float max = Float.parseFloat(splitString[3]);
|
||||
int priority = Integer.parseInt(splitString[4]);
|
||||
boolean isLast = Boolean.parseBoolean(splitString[5]);
|
||||
|
||||
type = EnumUtils.valueOf(OperationType.class, splitString[1]);
|
||||
|
||||
min = Float.parseFloat(splitString[2]);
|
||||
max = Float.parseFloat(splitString[3]);
|
||||
|
||||
priority = Integer.parseInt(splitString[4]);
|
||||
|
||||
isLast = Boolean.parseBoolean(splitString[5]);
|
||||
return new OperationItem(isTag, id, type, min, max, priority, isLast);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
Reference in New Issue
Block a user