Update to Commons 6.1.4

This commit is contained in:
Daniel Saukel 2020-04-19 00:10:07 +02:00
parent 5245c46631
commit 932e46358c
5 changed files with 3 additions and 112 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<UUID> players = new ArrayList<>();
private int seconds;
private int secondsLeft;
public ProgressBar(Collection<Player> 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);
}
}

View File

@ -26,7 +26,7 @@
<dependency>
<groupId>de.erethon.commons</groupId>
<artifactId>commons-dist</artifactId>
<version>6.1.3</version>
<version>6.1.4</version>
<scope>compile</scope>
</dependency>
<dependency>