Skip to content

Commit

Permalink
Added configuration for #9.
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMAVA committed May 5, 2020
1 parent 1cf4417 commit 62ca6dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/me/PauMAVA/UhcPlugin/match/UhcMatchTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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--;
Expand All @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 62ca6dd

Please sign in to comment.