Files
BlockParty/src/main/java/us/tss3/blockparty/config/ConfigManager.java
T
Michael BurgessandClaude Sonnet 5 4c4f5a1215
Build / build (push) Successful in 1m17s
Scale round difficulty over time and add claimable powerups
Reshuffles the floor so the target color's share shrinks each round
(TargetDensityCalculator) instead of always averaging ~1/paletteSize,
making later rounds progressively harder to read.

Adds Super Speed and Air Blast powerups that spawn on the floor each
round, claimable by walking over or left-clicking their marker, expiring
after 2-3 unclaimed rounds. Usage is tracked in player stats.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-08 11:31:30 -04:00

228 lines
7.5 KiB
Java

package us.tss3.blockparty.config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
/** Wraps global config.yml access: UI toggles, sounds, rewards, default floor palette. */
public class ConfigManager {
private final JavaPlugin plugin;
private FileConfiguration config;
public ConfigManager(JavaPlugin plugin) {
this.plugin = plugin;
}
public void load() {
plugin.saveDefaultConfig();
plugin.reloadConfig();
this.config = plugin.getConfig();
}
public FileConfiguration raw() {
return config;
}
public boolean isScoreboardEnabled() {
return config.getBoolean("ui.scoreboard", true);
}
public boolean isBossbarEnabled() {
return config.getBoolean("ui.bossbar", true);
}
public boolean isBillboardEnabled() {
return config.getBoolean("ui.billboard", true);
}
public boolean isTitlesEnabled() {
return config.getBoolean("ui.titles", true);
}
public boolean isActionbarEnabled() {
return config.getBoolean("ui.actionbar", true);
}
public int getScoreboardUpdateIntervalTicks() {
return config.getInt("ui.scoreboard-update-interval-ticks", 10);
}
public String getSound(String key) {
return config.getString("sounds." + key);
}
public List<String> getRewardCommands() {
return config.getStringList("rewards.winner.commands");
}
public double getRewardMoney() {
return config.getDouble("rewards.winner.money", 0);
}
public boolean isVaultEnabled() {
return config.getBoolean("integrations.vault", true);
}
public boolean isWorldEditEnabled() {
return config.getBoolean("integrations.worldedit", true);
}
public List<String> getDefaultFloorMaterials() {
return config.getStringList("default-floor-materials");
}
public int getDefaultStartingRoundTime() {
return config.getInt("defaults.starting-round-time", 20);
}
public int getDefaultMinimumRoundTime() {
return config.getInt("defaults.minimum-round-time", 4);
}
public int getDefaultRoundReduction() {
return config.getInt("defaults.round-time-reduction", 1);
}
public int getDefaultCountdown() {
return config.getInt("defaults.countdown-duration", 15);
}
public int getFloorBatchBlocksPerTick() {
return config.getInt("performance.floor-blocks-per-tick", 200);
}
public boolean isShuffleFloorEachRound() {
return config.getBoolean("floor.shuffle-each-round", true);
}
/** Fraction of the floor made of the target color on round 1 (0-1). Below the natural
* 1/paletteSize average so even the first round is harder than a plain uniform shuffle. */
public double getStartingTargetBlockFraction() {
return config.getDouble("floor.starting-target-fraction", 0.5);
}
/** Fraction of the floor made of the target color on the hardest (late-game) rounds. */
public double getMinimumTargetBlockFraction() {
return config.getDouble("floor.minimum-target-fraction", 0.06);
}
/** How much the target color's share of the floor shrinks per round after the first. */
public double getTargetBlockFractionReductionPerRound() {
return config.getDouble("floor.target-fraction-reduction-per-round", 0.04);
}
public boolean isPowerupsEnabled() {
return config.getBoolean("powerups.enabled", true);
}
/** Chance (0-1), rolled once per round, that a new powerup spawns on the floor. */
public double getPowerupSpawnChance() {
return config.getDouble("powerups.spawn-chance-per-round", 0.35);
}
/** Cap on how many unclaimed powerups can sit on the floor at once. */
public int getPowerupMaxActive() {
return config.getInt("powerups.max-active", 1);
}
/** Minimum number of rounds an unclaimed powerup lingers before disappearing. */
public int getPowerupMinLifetimeRounds() {
return config.getInt("powerups.min-lifetime-rounds", 2);
}
/** Maximum number of rounds an unclaimed powerup lingers before disappearing. */
public int getPowerupMaxLifetimeRounds() {
return config.getInt("powerups.max-lifetime-rounds", 3);
}
public org.bukkit.Material getPowerupMarkerMaterial(String typeKey) {
String name = config.getString("powerups.types." + typeKey + ".marker-block", "TORCH");
org.bukkit.Material material = org.bukkit.Material.matchMaterial(name);
return material != null ? material : org.bukkit.Material.TORCH;
}
public int getSuperSpeedDurationSeconds() {
return config.getInt("powerups.types.super-speed.duration-seconds", 8);
}
/** Potion effect amplifier, i.e. Speed (amplifier + 1) - amplifier 1 = Speed II. */
public int getSuperSpeedAmplifier() {
return config.getInt("powerups.types.super-speed.amplifier", 1);
}
/** Radius, in blocks, that Air Blast pushes other nearby players within. */
public double getAirBlastRadius() {
return config.getDouble("powerups.types.air-blast.radius", 4.0);
}
/** Horizontal+vertical knockback strength applied to players caught in an Air Blast. */
public double getAirBlastStrength() {
return config.getDouble("powerups.types.air-blast.strength", 1.4);
}
public boolean isMusicEnabled() {
return config.getBoolean("music.enabled", false);
}
public String getMusicTrack() {
return config.getString("music.track", "MUSIC_DISC_PIGSTEP");
}
public float getMusicVolume() {
return (float) config.getDouble("music.volume", 1.0);
}
public boolean isJukeboxEnabled() {
return config.getBoolean("jukebox.enabled", false);
}
public String getJukeboxBindAddress() {
return config.getString("jukebox.bind-address", "127.0.0.1");
}
public int getJukeboxPort() {
return config.getInt("jukebox.port", 8642);
}
public String getJukeboxAllowedOrigin() {
return config.getString("jukebox.allowed-origin", "*");
}
public int getJukeboxVoteCodeMinutes() {
return config.getInt("jukebox.vote-code-minutes", 10);
}
public List<String> getJukeboxTracks() {
return config.getStringList("jukebox.tracks");
}
public boolean isPlaceholderApiEnabled() {
return config.getBoolean("integrations.placeholderapi", true);
}
public StorageSettings getStorageSettings() {
String type = config.getString("storage.type", "sqlite");
return new StorageSettings(
type,
config.getString("storage.mysql.host", "localhost"),
config.getInt("storage.mysql.port", 3306),
config.getString("storage.mysql.database", "blockparty"),
config.getString("storage.mysql.username", "blockparty"),
config.getString("storage.mysql.password", ""),
config.getString("storage.mysql.table-prefix", "bp_"),
config.getString("storage.mysql.connection-parameters", "sslMode=PREFERRED&verifyServerCertificate=false")
);
}
/** Immutable snapshot of the storage.* config section. */
public record StorageSettings(String type, String host, int port, String database,
String username, String password, String tablePrefix, String connectionParameters) {
public boolean isMysql() {
return "mysql".equalsIgnoreCase(type);
}
}
}