From 62ca6dde8e01d9fe30b8d5f5ab05a236690dc913 Mon Sep 17 00:00:00 2001 From: PauMAVA Date: Tue, 5 May 2020 12:52:26 +0200 Subject: [PATCH] Added configuration for #9. --- .../UhcPlugin/match/UhcMatchHandler.java | 4 +++- .../UhcPlugin/match/UhcMatchTimer.java | 20 +++++++++++++------ src/main/resources/config.yml | 7 ++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchHandler.java b/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchHandler.java index 369308f..4d25410 100644 --- a/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchHandler.java +++ b/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchHandler.java @@ -70,7 +70,9 @@ public void start() { RandomTeleporter.teleportPlayers(); UhcScoreboardManager.setUp(); this.timer = new UhcMatchTimer(this); - this.timer.scheduleAsyncSkinRoll(); + if (UhcPluginCore.getInstance().getConfig().getBoolean("rotate_skins.enabled")) { + this.timer.scheduleAsyncSkinRoll(); + } this.timerTaskID = timer.runTaskTimer(plugin, 0L, 20L).getTaskId(); this.tabTaskID = new UhcTabList().runTaskTimer(plugin, 0L, 20L).getTaskId(); } diff --git a/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchTimer.java b/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchTimer.java index 529c506..a65c6e0 100644 --- a/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchTimer.java +++ b/src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchTimer.java @@ -42,7 +42,9 @@ public class UhcMatchTimer extends BukkitRunnable { private String secondsString, minutesString, totalTimeString; private String season = UhcPluginCore.getInstance().getConfig().getString("season"); private String seasonPrefix = PluginStrings.SEASON_PREFIX.toString(); - private Integer chaptersToSkinRoll = 2; + + private boolean doSkinRoll = UhcPluginCore.getInstance().getConfig().getBoolean("rotate_skins.enabled"); + private Integer chaptersToSkinRoll = UhcPluginCore.getInstance().getConfig().getInt("rotate_skins.period"); public UhcMatchTimer(UhcMatchHandler match) { this.match = match; @@ -55,6 +57,16 @@ private void checkForShulkerGive(int episode) { } } + private void checkForSkinRoll() { + if (doSkinRoll) { + chaptersToSkinRoll--; + if (chaptersToSkinRoll <= 0) { + scheduleAsyncSkinRoll(); + chaptersToSkinRoll = UhcPluginCore.getInstance().getConfig().getInt("rotate_skins.period"); + } + } + } + @Override public void run() { seconds--; @@ -67,11 +79,7 @@ public void run() { UhcPluginCore.getInstance().getMatchHandler().episodeAnnouncement(episode); UhcWorldBorder.refreshBorder(episode); checkForShulkerGive(episode); - chaptersToSkinRoll--; - if (chaptersToSkinRoll <= 0) { - scheduleAsyncSkinRoll(); - chaptersToSkinRoll = 2; - } + checkForSkinRoll(); } } if(seconds < 10) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1cdd16c..4376a3c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,7 +6,12 @@ border_radius: 1500 closable_border: true final_radius: 150 border_closing_episode: 8 -rotate_skins: true + + +# If this feature is enabled all player's will be randomly disguised with other participant's skin and names periodically +rotate_skins: + enabled: true + period: 2 # The period in episodes when a skin rotations cycle will be executed # If this feature is enabled, the plugin will give a shulkerbox to all alive players on the specified episode. # If the player has got no space in their inventory, a shulkerbox item will be dropped at their location.