mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-15 22:55:24 +01:00
Performance update.
This commit is contained in:
parent
d229a7a8c6
commit
cd206b16e1
@ -1,6 +1,8 @@
|
||||
package com.songoda.ultimatestacker.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public enum Check {
|
||||
@ -52,6 +54,13 @@ public enum Check {
|
||||
this.isEnabledByDefault = isEnabledByDefault;
|
||||
}
|
||||
|
||||
public static List<Check> getChecks(List<String> strChecks) {
|
||||
List<Check> checks = new ArrayList<>();
|
||||
for (String checkStr : strChecks)
|
||||
checks.add(getCheck(checkStr));
|
||||
return checks;
|
||||
}
|
||||
|
||||
public boolean isEnabledByDefault() {
|
||||
return isEnabledByDefault;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class EntityUtils {
|
||||
|
||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
|
||||
private final List<String> checks = Settings.STACK_CHECKS.getStringList();
|
||||
private final List<Check> checks = Check.getChecks(Settings.STACK_CHECKS.getStringList());
|
||||
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(),
|
||||
keepFire = Settings.KEEP_FIRE.getBoolean(),
|
||||
keepPotion = Settings.KEEP_POTION.getBoolean(),
|
||||
@ -100,8 +100,7 @@ public class EntityUtils {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12))
|
||||
newEntity.setInvulnerable(false);
|
||||
|
||||
for (String checkStr : checks) {
|
||||
Check check = Check.valueOf(checkStr);
|
||||
for (Check check : checks) {
|
||||
switch (check) {
|
||||
case AGE: {
|
||||
if (!(toClone instanceof Ageable) || ((Ageable) toClone).isAdult()) break;
|
||||
@ -262,8 +261,7 @@ public class EntityUtils {
|
||||
if (stackFlyingDown && Methods.canFly(initialEntity))
|
||||
entityList.removeIf(entity -> entity.getLocation().getY() > initialEntity.getLocation().getY());
|
||||
|
||||
for (String checkStr : checks) {
|
||||
Check check = Check.getCheck(checkStr);
|
||||
for (Check check : checks) {
|
||||
if (check == null) continue;
|
||||
switch (check) {
|
||||
case SPAWN_REASON: {
|
||||
|
Loading…
Reference in New Issue
Block a user