diff --git a/core/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerStartGameTask.java b/core/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerStartGameTask.java index ed89ffaf..cdd8fd9b 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerStartGameTask.java +++ b/core/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerStartGameTask.java @@ -16,6 +16,7 @@ */ package de.erethon.dungeonsxl.announcer; +import de.erethon.commons.misc.ProgressBar; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.world.GameWorld; import de.erethon.dungeonsxl.api.world.ResourceWorld; @@ -23,7 +24,6 @@ import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.dungeon.DGame; import de.erethon.dungeonsxl.player.DGamePlayer; import de.erethon.dungeonsxl.player.DGroup; -import de.erethon.dungeonsxl.util.ProgressBar; import java.util.HashSet; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; diff --git a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java index 4e0a11b8..b1fa7962 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java +++ b/core/src/main/java/de/erethon/dungeonsxl/sign/button/ReadySign.java @@ -17,6 +17,7 @@ package de.erethon.dungeonsxl.sign.button; import de.erethon.commons.misc.NumberUtil; +import de.erethon.commons.misc.ProgressBar; import de.erethon.dungeonsxl.api.DungeonsAPI; import de.erethon.dungeonsxl.api.player.GamePlayer; import de.erethon.dungeonsxl.api.sign.Button; @@ -24,7 +25,6 @@ import de.erethon.dungeonsxl.api.world.InstanceWorld; import de.erethon.dungeonsxl.config.DMessage; import de.erethon.dungeonsxl.player.DPermission; import de.erethon.dungeonsxl.trigger.InteractTrigger; -import de.erethon.dungeonsxl.util.ProgressBar; import de.erethon.dungeonsxl.world.DGameWorld; import org.bukkit.ChatColor; import org.bukkit.block.Sign; diff --git a/core/src/main/java/de/erethon/dungeonsxl/trigger/TriggerListener.java b/core/src/main/java/de/erethon/dungeonsxl/trigger/TriggerListener.java index a1a5e213..43f38636 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/trigger/TriggerListener.java +++ b/core/src/main/java/de/erethon/dungeonsxl/trigger/TriggerListener.java @@ -16,7 +16,6 @@ */ package de.erethon.dungeonsxl.trigger; -import de.erethon.caliburn.item.ExItem; import de.erethon.caliburn.item.VanillaItem; import de.erethon.dungeonsxl.DungeonsXL; import de.erethon.dungeonsxl.api.world.GameWorld; diff --git a/core/src/main/java/de/erethon/dungeonsxl/util/ProgressBar.java b/core/src/main/java/de/erethon/dungeonsxl/util/ProgressBar.java deleted file mode 100644 index 43812011..00000000 --- a/core/src/main/java/de/erethon/dungeonsxl/util/ProgressBar.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2012-2020 Frank Baumann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package de.erethon.dungeonsxl.util; - -import de.erethon.commons.chat.MessageUtil; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; - -/** - * A boss bar based progress bar. - * - * @author Daniel Saukel - */ -public class ProgressBar extends BukkitRunnable { - - public static final String BAR = "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"; - - private List players = new ArrayList<>(); - private int seconds; - private int secondsLeft; - - public ProgressBar(Collection players, int seconds) { - for (Player player : players) { - this.players.add(player.getUniqueId()); - } - this.seconds = seconds; - this.secondsLeft = seconds; - } - - public ProgressBar(Player player, int seconds) { - this.players.add(player.getUniqueId()); - this.seconds = seconds; - this.secondsLeft = seconds; - } - - /** - * @param player the player to add - */ - public void addPlayer(Player player) { - players.add(player.getUniqueId()); - } - - /** - * @param player the player to remove - */ - public void removePlayer(Player player) { - players.remove(player.getUniqueId()); - } - - @Override - public void run() { - int i = (int) Math.round(((double) secondsLeft / (double) seconds) * 10); - StringBuilder bar = new StringBuilder(BAR); - bar.insert(10 - i, ChatColor.DARK_RED.toString()); - for (UUID uuid : players) { - Player player = Bukkit.getPlayer(uuid); - if (player != null && player.isOnline()) { - MessageUtil.sendActionBarMessage(player, ChatColor.GREEN.toString() + bar.toString()); - } - } - - if (secondsLeft == 0) { - onFinish(); - cancel(); - } else { - secondsLeft--; - } - } - - /** - * Method to override to set actions when no seconds are left. - */ - public void onFinish() { - } - - /** - * Sends the progress bar to a player - * - * @param plugin the plugin instance - * @return the scheduled BukkitTask - */ - public BukkitTask send(Plugin plugin) { - return runTaskTimer(plugin, 0L, 20L); - } - -} diff --git a/pom.xml b/pom.xml index 328bc8a2..3de3ce70 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ de.erethon.commons commons-dist - 6.1.3 + 6.1.4 compile