mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
More settings
This commit is contained in:
parent
4f63db3f70
commit
b0060bcb82
@ -25,6 +25,8 @@ import com.volmit.iris.util.json.JSONException;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.Data;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -34,13 +36,13 @@ import java.io.IOException;
|
||||
public class IrisSettings {
|
||||
public static transient IrisSettings settings;
|
||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||
private IrisSettingsWorld world = new IrisSettingsWorld();
|
||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
||||
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
||||
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
||||
private IrisSettingsStudio studio = new IrisSettingsStudio();
|
||||
private IrisSettingsPerformance performance = new IrisSettingsPerformance();
|
||||
|
||||
public static int getThreadCount(int c) {
|
||||
return switch (c) {
|
||||
case -1, -2, -4 -> Runtime.getRuntime().availableProcessors() / -c;
|
||||
@ -56,6 +58,24 @@ public class IrisSettings {
|
||||
public boolean autoRestartOnCustomBiomeInstall = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisAsyncTeleport {
|
||||
public boolean enabled = true;
|
||||
public int loadViewDistance = 2;
|
||||
public boolean urgent = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsWorld {
|
||||
public IrisAsyncTeleport asyncTeleport = new IrisAsyncTeleport();
|
||||
public boolean postLoadBlockUpdates = true;
|
||||
public boolean anbientEntitySpawningSystem = true;
|
||||
public long asyncTickIntervalMS = 700;
|
||||
public double targetSpawnEntitiesPerChunk = 0.95;
|
||||
public boolean markerEntitySpawningSystem = true;
|
||||
public boolean effectSystem = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsConcurrency {
|
||||
public int parallelism = -1;
|
||||
|
@ -133,6 +133,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
getEngine().getWorld().tryGetRealWorld();
|
||||
}
|
||||
|
||||
if(!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem())
|
||||
{
|
||||
return 3000;
|
||||
}
|
||||
|
||||
if (getEngine().getWorld().hasRealWorld()) {
|
||||
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
||||
return 5000;
|
||||
@ -179,7 +184,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
onAsyncTick();
|
||||
}
|
||||
|
||||
return 700;
|
||||
return IrisSettings.get().getWorld().getAsyncTickIntervalMS();
|
||||
}
|
||||
};
|
||||
looper.setPriority(Thread.MIN_PRIORITY);
|
||||
@ -195,22 +200,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
||||
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||
int finalX = c.getX() + x;
|
||||
int finalZ = c.getZ() + z;
|
||||
J.a(() -> getMantle().raiseFlag(finalX, finalZ, MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> {
|
||||
J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200));
|
||||
getSpawnersFromMarkers(cx).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, true);
|
||||
});
|
||||
}));
|
||||
if(IrisSettings.get().getWorld().isPostLoadBlockUpdates())
|
||||
{
|
||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
||||
}
|
||||
|
||||
if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem())
|
||||
{
|
||||
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||
int finalX = c.getX() + x;
|
||||
int finalZ = c.getZ() + z;
|
||||
J.a(() -> getMantle().raiseFlag(finalX, finalZ, MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> {
|
||||
J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200));
|
||||
getSpawnersFromMarkers(cx).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, true);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,12 +244,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
if (!getEngine().getWorld().hasRealWorld()) {
|
||||
Iris.debug("Can't spawn. No real world");
|
||||
J.sleep(10000);
|
||||
J.sleep(5000);
|
||||
return false;
|
||||
}
|
||||
|
||||
double epx = getEntitySaturation();
|
||||
if (epx > 1) {
|
||||
if (epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) {
|
||||
Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")");
|
||||
J.sleep(5000);
|
||||
return false;
|
||||
@ -295,10 +308,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
energy += 1.2;
|
||||
}
|
||||
|
||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
||||
IrisRegion region = getEngine().getRegion(c);
|
||||
//@builder
|
||||
IrisEntitySpawn v = spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
||||
IrisBiome biome = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||
? getEngine().getSurfaceBiome(c) : null;
|
||||
IrisEntitySpawn v = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||
? spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream()
|
||||
.filter(this::canSpawn)
|
||||
@ -313,18 +327,22 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap((i) -> stream(i, initial))))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r);
|
||||
.popRandom(RNG.r) : null;
|
||||
//@done
|
||||
|
||||
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem())
|
||||
{
|
||||
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, false);
|
||||
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> spawn(block, s, true)));
|
||||
});
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, false);
|
||||
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> spawn(block, s, true)));
|
||||
});
|
||||
}
|
||||
|
||||
if (v != null && v.getReferenceSpawner() != null) {
|
||||
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
||||
@ -343,7 +361,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
J.s(() -> spawn(c, v));
|
||||
}
|
||||
}
|
||||
//@done
|
||||
}
|
||||
|
||||
private void spawn(Chunk c, IrisEntitySpawn i) {
|
||||
@ -521,18 +538,20 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public void teleportAsync(PlayerTeleportEvent e) {
|
||||
e.setCancelled(true);
|
||||
warmupAreaAsync(e.getPlayer(), e.getTo(), ()
|
||||
-> J.s(() -> {
|
||||
ignoreTP.set(true);
|
||||
e.getPlayer().teleport(e.getTo(), e.getCause());
|
||||
ignoreTP.set(false);
|
||||
}));
|
||||
if(IrisSettings.get().getWorld().getAsyncTeleport().isEnabled())
|
||||
{
|
||||
e.setCancelled(true);
|
||||
warmupAreaAsync(e.getPlayer(), e.getTo(), () -> J.s(() -> {
|
||||
ignoreTP.set(true);
|
||||
e.getPlayer().teleport(e.getTo(), e.getCause());
|
||||
ignoreTP.set(false);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void warmupAreaAsync(Player player, Location to, Runnable r) {
|
||||
J.a(() -> {
|
||||
int viewDistance = 3;
|
||||
int viewDistance = IrisSettings.get().getWorld().getAsyncTeleport().getLoadViewDistance();
|
||||
KList<Future<Chunk>> futures = new KList<>();
|
||||
for(int i = -viewDistance; i <= viewDistance; i++)
|
||||
{
|
||||
@ -547,7 +566,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
futures.add(MultiBurst.burst.completeValue(() -> PaperLib.getChunkAtAsync(to.getWorld(), (to.getBlockX() >> 4) + finalI, (to.getBlockZ() >> 4) + finalJ, true).get()));
|
||||
futures.add(MultiBurst.burst.completeValue(()
|
||||
-> PaperLib.getChunkAtAsync(to.getWorld(),
|
||||
(to.getBlockX() >> 4) + finalI,
|
||||
(to.getBlockZ() >> 4) + finalJ,
|
||||
true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user