mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +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.json.JSONObject;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -34,13 +36,13 @@ import java.io.IOException;
|
|||||||
public class IrisSettings {
|
public class IrisSettings {
|
||||||
public static transient IrisSettings settings;
|
public static transient IrisSettings settings;
|
||||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||||
|
private IrisSettingsWorld world = new IrisSettingsWorld();
|
||||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||||
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
||||||
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
||||||
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
||||||
private IrisSettingsStudio studio = new IrisSettingsStudio();
|
private IrisSettingsStudio studio = new IrisSettingsStudio();
|
||||||
private IrisSettingsPerformance performance = new IrisSettingsPerformance();
|
private IrisSettingsPerformance performance = new IrisSettingsPerformance();
|
||||||
|
|
||||||
public static int getThreadCount(int c) {
|
public static int getThreadCount(int c) {
|
||||||
return switch (c) {
|
return switch (c) {
|
||||||
case -1, -2, -4 -> Runtime.getRuntime().availableProcessors() / -c;
|
case -1, -2, -4 -> Runtime.getRuntime().availableProcessors() / -c;
|
||||||
@ -56,6 +58,24 @@ public class IrisSettings {
|
|||||||
public boolean autoRestartOnCustomBiomeInstall = true;
|
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
|
@Data
|
||||||
public static class IrisSettingsConcurrency {
|
public static class IrisSettingsConcurrency {
|
||||||
public int parallelism = -1;
|
public int parallelism = -1;
|
||||||
|
@ -133,6 +133,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
getEngine().getWorld().tryGetRealWorld();
|
getEngine().getWorld().tryGetRealWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem())
|
||||||
|
{
|
||||||
|
return 3000;
|
||||||
|
}
|
||||||
|
|
||||||
if (getEngine().getWorld().hasRealWorld()) {
|
if (getEngine().getWorld().hasRealWorld()) {
|
||||||
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
||||||
return 5000;
|
return 5000;
|
||||||
@ -179,7 +184,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
onAsyncTick();
|
onAsyncTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 700;
|
return IrisSettings.get().getWorld().getAsyncTickIntervalMS();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
looper.setPriority(Thread.MIN_PRIORITY);
|
looper.setPriority(Thread.MIN_PRIORITY);
|
||||||
@ -195,7 +200,14 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
for (int x = -r; x <= r; x++) {
|
for (int x = -r; x <= r; x++) {
|
||||||
for (int z = -r; z <= r; z++) {
|
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)) {
|
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||||
|
|
||||||
|
if(IrisSettings.get().getWorld().isPostLoadBlockUpdates())
|
||||||
|
{
|
||||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
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);
|
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||||
int finalX = c.getX() + x;
|
int finalX = c.getX() + x;
|
||||||
int finalZ = c.getZ() + z;
|
int finalZ = c.getZ() + z;
|
||||||
@ -216,6 +228,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean onAsyncTick() {
|
private boolean onAsyncTick() {
|
||||||
if (getEngine().isClosed()) {
|
if (getEngine().isClosed()) {
|
||||||
@ -231,12 +244,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
if (!getEngine().getWorld().hasRealWorld()) {
|
if (!getEngine().getWorld().hasRealWorld()) {
|
||||||
Iris.debug("Can't spawn. No real world");
|
Iris.debug("Can't spawn. No real world");
|
||||||
J.sleep(10000);
|
J.sleep(5000);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double epx = getEntitySaturation();
|
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 + ")");
|
Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")");
|
||||||
J.sleep(5000);
|
J.sleep(5000);
|
||||||
return false;
|
return false;
|
||||||
@ -295,10 +308,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
energy += 1.2;
|
energy += 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisBiome biome = getEngine().getSurfaceBiome(c);
|
|
||||||
IrisRegion region = getEngine().getRegion(c);
|
|
||||||
//@builder
|
//@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())
|
.loadAll(getDimension().getEntitySpawners())
|
||||||
.shuffleCopy(RNG.r).stream()
|
.shuffleCopy(RNG.r).stream()
|
||||||
.filter(this::canSpawn)
|
.filter(this::canSpawn)
|
||||||
@ -313,8 +327,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||||
.flatMap((i) -> stream(i, initial))))
|
.flatMap((i) -> stream(i, initial))))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.popRandom(RNG.r);
|
.popRandom(RNG.r) : null;
|
||||||
|
//@done
|
||||||
|
|
||||||
|
if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem())
|
||||||
|
{
|
||||||
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
||||||
if (spawners.isEmpty()) {
|
if (spawners.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -325,6 +342,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||||
() -> spawn(block, s, true)));
|
() -> spawn(block, s, true)));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (v != null && v.getReferenceSpawner() != null) {
|
if (v != null && v.getReferenceSpawner() != null) {
|
||||||
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
||||||
@ -343,7 +361,6 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
J.s(() -> spawn(c, v));
|
J.s(() -> spawn(c, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(Chunk c, IrisEntitySpawn i) {
|
private void spawn(Chunk c, IrisEntitySpawn i) {
|
||||||
@ -521,18 +538,20 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleportAsync(PlayerTeleportEvent e) {
|
public void teleportAsync(PlayerTeleportEvent e) {
|
||||||
|
if(IrisSettings.get().getWorld().getAsyncTeleport().isEnabled())
|
||||||
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
warmupAreaAsync(e.getPlayer(), e.getTo(), ()
|
warmupAreaAsync(e.getPlayer(), e.getTo(), () -> J.s(() -> {
|
||||||
-> J.s(() -> {
|
|
||||||
ignoreTP.set(true);
|
ignoreTP.set(true);
|
||||||
e.getPlayer().teleport(e.getTo(), e.getCause());
|
e.getPlayer().teleport(e.getTo(), e.getCause());
|
||||||
ignoreTP.set(false);
|
ignoreTP.set(false);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void warmupAreaAsync(Player player, Location to, Runnable r) {
|
private void warmupAreaAsync(Player player, Location to, Runnable r) {
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
int viewDistance = 3;
|
int viewDistance = IrisSettings.get().getWorld().getAsyncTeleport().getLoadViewDistance();
|
||||||
KList<Future<Chunk>> futures = new KList<>();
|
KList<Future<Chunk>> futures = new KList<>();
|
||||||
for(int i = -viewDistance; i <= viewDistance; i++)
|
for(int i = -viewDistance; i <= viewDistance; i++)
|
||||||
{
|
{
|
||||||
@ -547,7 +566,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
continue;
|
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