mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 18:45:39 +01:00
validate check config strings
This commit is contained in:
parent
817db57ea7
commit
787cfa089b
@ -1,5 +1,8 @@
|
||||
package com.songoda.ultimatestacker.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum Check {
|
||||
|
||||
SPAWN_REASON(false),
|
||||
@ -35,7 +38,14 @@ public enum Check {
|
||||
PHANTOM_SIZE(true),
|
||||
CAT_TYPE(true);
|
||||
|
||||
private boolean isEnabledByDefault;
|
||||
private final boolean isEnabledByDefault;
|
||||
private final static Map<String, Check> checks = new HashMap();
|
||||
|
||||
static {
|
||||
for (Check c : values()) {
|
||||
checks.put(c.name(), c);
|
||||
}
|
||||
}
|
||||
|
||||
Check(boolean isEnabledByDefault) {
|
||||
this.isEnabledByDefault = isEnabledByDefault;
|
||||
@ -44,4 +54,8 @@ public enum Check {
|
||||
public boolean isEnabledByDefault() {
|
||||
return isEnabledByDefault;
|
||||
}
|
||||
|
||||
public static Check getCheck(String name) {
|
||||
return name != null ? checks.get(name.toUpperCase()) : null;
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ public class EntityUtils {
|
||||
|
||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
|
||||
private List<String> checks = Settings.STACK_CHECKS.getStringList();
|
||||
private boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean();
|
||||
private boolean keepFire = Settings.KEEP_FIRE.getBoolean();
|
||||
private boolean keepPotion = Settings.KEEP_POTION.getBoolean();
|
||||
private boolean stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean();
|
||||
private int searchRadius = Settings.SEARCH_RADIUS.getInt();
|
||||
private final List<String> checks = Settings.STACK_CHECKS.getStringList();
|
||||
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean();
|
||||
private final boolean keepFire = Settings.KEEP_FIRE.getBoolean();
|
||||
private final boolean keepPotion = Settings.KEEP_POTION.getBoolean();
|
||||
private final boolean stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean();
|
||||
private final int searchRadius = Settings.SEARCH_RADIUS.getInt();
|
||||
|
||||
private final Map<CachedChunk, Entity[]> cachedChunks = new HashMap<>();
|
||||
|
||||
@ -251,7 +251,8 @@ public class EntityUtils {
|
||||
entityList.removeIf(entity -> entity.getLocation().getY() > initalEntity.getLocation().getY());
|
||||
|
||||
for (String checkStr : checks) {
|
||||
Check check = Check.valueOf(checkStr);
|
||||
Check check = Check.getCheck(checkStr);
|
||||
if (check == null) continue;
|
||||
switch (check) {
|
||||
case SPAWN_REASON: {
|
||||
if (initalEntity.hasMetadata("US_REASON"))
|
||||
|
Loading…
Reference in New Issue
Block a user