This commit is contained in:
RePixelatedMC
2024-08-22 16:14:58 +02:00
parent 805523d069
commit 3dfdb9654a
@@ -10,9 +10,6 @@ import com.volmit.iris.util.mobs.IrisMobDataHandler;
import com.volmit.iris.util.mobs.IrisMobPiece; import com.volmit.iris.util.mobs.IrisMobPiece;
import com.volmit.iris.util.scheduling.Looper; import com.volmit.iris.util.scheduling.Looper;
import com.volmit.iris.util.scheduling.PrecisionStopwatch; import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
import it.unimi.dsi.fastutil.Hash;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@@ -20,9 +17,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -56,8 +51,7 @@ public class EngineMobHandlerSVC extends IrisEngineService implements IrisMobDat
this.id = engine.getCacheID(); this.id = engine.getCacheID();
this.pieces = new ConcurrentLinkedQueue<>(); this.pieces = new ConcurrentLinkedQueue<>();
this.entityType = (entityType) -> Types.valueOf(INMS.get().getMobCategory(entityType)); this.entityType = (entityType) -> Types.valueOf(INMS.get().getMobCategory(entityType));
this.bukkitLimits = new HashMap<>(); this.bukkitLimits = getBukkitLimits();
//new Ticker(); //new Ticker();
} }
@@ -88,12 +82,12 @@ public class EngineMobHandlerSVC extends IrisEngineService implements IrisMobDat
stopwatch.begin(); stopwatch.begin();
fixEnergy(); fixEnergy();
Predicate<IrisMobPiece> shouldExecutePredicate = IrisMobPiece::shouldTick; Predicate<IrisMobPiece> shouldTick = IrisMobPiece::shouldTick;
Consumer<IrisMobPiece> executeMethod = IrisMobPiece::tick; Consumer<IrisMobPiece> tick = IrisMobPiece::tick;
pieces.stream() pieces.stream()
.filter(shouldExecutePredicate) .filter(shouldTick)
.forEach(executeMethod); .forEach(tick);
stopwatch.end(); stopwatch.end();
Iris.info("Took: " + Form.f(stopwatch.getMilliseconds())); Iris.info("Took: " + Form.f(stopwatch.getMilliseconds()));
@@ -138,27 +132,9 @@ public class EngineMobHandlerSVC extends IrisEngineService implements IrisMobDat
private HashMap<Types, Integer> getBukkitLimits() { private HashMap<Types, Integer> getBukkitLimits() {
HashMap<Types, Integer> temp = new HashMap<>(); HashMap<Types, Integer> temp = new HashMap<>();
FileConfiguration fc = new YamlConfiguration(); FileConfiguration fc = new YamlConfiguration();
try { fc.getConfigurationSection("spawn-limits").getKeys(false).forEach(key -> temp.put(Types.valueOf(key), fc.getInt(key)));
fc.load(new File("bukkit.yml")); return temp;
ConfigurationSection section = fc.getConfigurationSection("spawn-limits");
if (section == null) {
throw new NoSuchFieldException("spawn-limits not found!");
}
for (String s : section.getKeys(false)) {
try {
ConfigurationSection entry = section.getConfigurationSection(s);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
Iris.reportError(e);
}
return null;
} }