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:
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
*/