Fixes a few problems

Makes sure to actually load the configuration when starting the plugin
Makes sure all numeric configuration values are within expected bounds
Adds improved descriptions of configuration values' bounds
This commit is contained in:
Kristian Knarvik 2023-04-11 13:55:46 +02:00
parent 50978d8baf
commit 2f4d4ff4c6
3 changed files with 32 additions and 5 deletions

View File

@ -111,10 +111,10 @@ public final class Dropper extends JavaPlugin {
// Reload configuration
this.reloadConfig();
configuration.load();
this.configuration.load();
// Clear record caches
dropperRecordExpansion.clearCaches();
this.dropperRecordExpansion.clearCaches();
}
@Override
@ -137,6 +137,7 @@ public final class Dropper extends JavaPlugin {
instance = this;
this.saveDefaultConfig();
this.configuration = new DropperConfiguration(this.getConfig());
this.configuration.load();
this.playerRegistry = new DropperArenaPlayerRegistry();
this.arenaHandler = new DropperArenaHandler();
this.arenaHandler.loadArenas();

View File

@ -170,10 +170,36 @@ public class DropperConfiguration {
this.overrideVerticalVelocity = configuration.getBoolean("overrideVerticalVelocity", true);
this.liquidHitBoxDepth = configuration.getDouble("liquidHitBoxDepth", -0.8);
this.solidHitBoxDistance = configuration.getDouble("solidHitBoxDistance", 0.2);
sanitizeValues();
loadBlockWhitelist();
}
/**
* Sanitizes configuration values to ensure they are within expected bounds
*/
private void sanitizeValues() {
if (this.liquidHitBoxDepth <= -1 || this.liquidHitBoxDepth > 0) {
this.liquidHitBoxDepth = -0.8;
}
if (this.solidHitBoxDistance <= 0 || this.solidHitBoxDistance > 1) {
this.solidHitBoxDistance = 0.2;
}
if (this.horizontalVelocity > 1 || this.horizontalVelocity <= 0) {
this.horizontalVelocity = 1;
}
if (this.verticalVelocity <= 0 || this.verticalVelocity > 75) {
this.verticalVelocity = 1;
}
if (this.randomlyInvertedTimer <= 0 || this.randomlyInvertedTimer > 3600) {
this.randomlyInvertedTimer = 7;
}
}
/**
* Loads the materials specified in the block whitelist
*/

View File

@ -12,7 +12,7 @@ dropper:
# (inclusive).
horizontalVelocity: 1.0
# The number of seconds before the randomly inverted game-mode switches between normal and inverted movement
# The number of seconds before the randomly inverted game-mode switches between normal and inverted movement (0, 3600]
randomlyInvertedTimer: 7
# Whether grouped dropper arenas must be played in the correct sequence
@ -32,11 +32,11 @@ dropper:
# pushing each-other if in the same arena.
disableHitCollision: true
# This decides how far inside a non-solid block the player must go before detection triggers. The closer to -1
# This decides how far inside a non-solid block the player must go before detection triggers (-1, 0). The closer to -1
# it is, the more accurate it will seem to the player, but the likelihood of not detecting the hit increases.
liquidHitBoxDepth: -0.8
# This decides the distance the player must be from a block below them before a hit triggers. If too low, the
# This decides the distance the player must be from a block below them before a hit triggers (0, 1). If too low, the
# likelihood of detecting the hit decreases, but it won't look like the player hit the block without being near.
solidHitBoxDistance: 0.2