mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-26 19:18:31 +01:00
Add ability to specify delay between each task that checks and loads chunks for level calculation. (#76)
Add ability to specify how much chunks should be loaded at the same tick.
This commit is contained in:
parent
7e29ba3ade
commit
0bd5bd4d10
@ -31,8 +31,8 @@ import world.bentobox.level.Level;
|
||||
|
||||
public class CalcIslandLevel {
|
||||
|
||||
private static final int MAX_CHUNKS = 200;
|
||||
private static final long SPEED = 1;
|
||||
private final int MAX_CHUNKS;
|
||||
private final long SPEED;
|
||||
private static final String LINE_BREAK = "==================================";
|
||||
private boolean checking;
|
||||
private final BukkitTask task;
|
||||
@ -80,6 +80,9 @@ public class CalcIslandLevel {
|
||||
// Set the initial island handicap
|
||||
result.initialLevel = addon.getInitialIslandLevel(island);
|
||||
|
||||
SPEED = addon.getSettings().getUpdateTickDelay();
|
||||
MAX_CHUNKS = addon.getSettings().getChunksPerTick();
|
||||
|
||||
// Get chunks to scan
|
||||
chunksToScan = getChunksToScan(island);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package world.bentobox.level.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -23,7 +22,19 @@ public class Settings {
|
||||
private int deathpenalty;
|
||||
private long levelCost;
|
||||
private int levelWait;
|
||||
private List<String> gameModes = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Stores number of chunks that can be updated in single tick.
|
||||
*/
|
||||
private int chunksPerTick;
|
||||
|
||||
/**
|
||||
* Stores number of tick delay between each chunk loading.
|
||||
*/
|
||||
private long updateTickDelay;
|
||||
|
||||
private List<String> gameModes;
|
||||
|
||||
|
||||
public Settings(Level level) {
|
||||
this.level = level;
|
||||
@ -32,6 +43,22 @@ public class Settings {
|
||||
// GameModes
|
||||
gameModes = level.getConfig().getStringList("game-modes");
|
||||
|
||||
// Level calculation chunk load speed
|
||||
this.setUpdateTickDelay(level.getConfig().getLong("updatetickdelay", 1));
|
||||
|
||||
if (this.getUpdateTickDelay() <= 0)
|
||||
{
|
||||
this.setUpdateTickDelay(1);
|
||||
}
|
||||
|
||||
// Level calculation chunk count per update
|
||||
this.setChunksPerTick(level.getConfig().getInt("chunkspertick", 200));
|
||||
|
||||
if (this.getChunksPerTick() <= 0)
|
||||
{
|
||||
this.setChunksPerTick(200);
|
||||
}
|
||||
|
||||
setLevelWait(level.getConfig().getInt("levelwait", 60));
|
||||
if (getLevelWait() < 0) {
|
||||
setLevelWait(0);
|
||||
@ -218,4 +245,46 @@ public class Settings {
|
||||
public boolean isShortHand() {
|
||||
return level.getConfig().getBoolean("shorthand");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the number of chunks that can be processed at single tick.
|
||||
* @return the value of chunksPerTick.
|
||||
*/
|
||||
public int getChunksPerTick()
|
||||
{
|
||||
return this.chunksPerTick;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the chunksPerTick value.
|
||||
* @param chunksPerTick the chunksPerTick new value.
|
||||
*
|
||||
*/
|
||||
public void setChunksPerTick(int chunksPerTick)
|
||||
{
|
||||
this.chunksPerTick = chunksPerTick;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the delay between each update call.
|
||||
* @return the value of updateTickDelay.
|
||||
*/
|
||||
public long getUpdateTickDelay()
|
||||
{
|
||||
return this.updateTickDelay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the updateTickDelay value.
|
||||
* @param updateTickDelay the updateTickDelay new value.
|
||||
*
|
||||
*/
|
||||
public void setUpdateTickDelay(long updateTickDelay)
|
||||
{
|
||||
this.updateTickDelay = updateTickDelay;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,14 @@ levelcost: 100
|
||||
# Cooldown between level requests in seconds
|
||||
levelwait: 60
|
||||
|
||||
# Delay between each task that loads chunks for calculating island level.
|
||||
# Increasing this will increase time to calculate island level.
|
||||
updatetickdelay: 1
|
||||
|
||||
# Number of chunks that will be processed at the same tick.
|
||||
# Decreasing this will increase time to calculate island level.
|
||||
chunkspertick: 200
|
||||
|
||||
# Death penalty
|
||||
# How many block values a player will lose per death.
|
||||
# Default value of 100 means that for every death, the player will lose 1 level (if levelcost is 100)
|
||||
|
Loading…
Reference in New Issue
Block a user