mirror of
https://github.com/Maxlego08/zKoth.git
synced 2024-11-26 12:35:17 +01:00
🚧 Add new koth type
This commit is contained in:
parent
5fde905e24
commit
e7e4a5ba40
@ -79,6 +79,9 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
this.kothType = KothType.CLASSIC;
|
this.kothType = KothType.CLASSIC;
|
||||||
this.maxPoints = 60;
|
this.maxPoints = 60;
|
||||||
this.maxSecondsCap = 60;
|
this.maxSecondsCap = 60;
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -156,6 +159,10 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
@Override
|
@Override
|
||||||
public void spawn(CommandSender sender, boolean now) {
|
public void spawn(CommandSender sender, boolean now) {
|
||||||
|
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.minLocation == null || this.maxLocation == null) {
|
if (this.minLocation == null || this.maxLocation == null) {
|
||||||
message(sender, Message.ZKOTH_SPAWN_ERROR);
|
message(sender, Message.ZKOTH_SPAWN_ERROR);
|
||||||
} else if (this.isCooldown) {
|
} else if (this.isCooldown) {
|
||||||
@ -175,6 +182,10 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
@Override
|
@Override
|
||||||
public void spawn(boolean now) {
|
public void spawn(boolean now) {
|
||||||
|
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.minLocation == null || this.maxLocation == null) {
|
if (this.minLocation == null || this.maxLocation == null) {
|
||||||
return;
|
return;
|
||||||
} else if (this.isCooldown) {
|
} else if (this.isCooldown) {
|
||||||
@ -196,6 +207,10 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
*/
|
*/
|
||||||
private void spawn() {
|
private void spawn() {
|
||||||
|
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
this.isCooldown = true;
|
this.isCooldown = true;
|
||||||
this.isEnable = true;
|
this.isEnable = true;
|
||||||
this.currentCaptureSeconds = new AtomicInteger(Config.cooldownInSecond);
|
this.currentCaptureSeconds = new AtomicInteger(Config.cooldownInSecond);
|
||||||
@ -243,6 +258,10 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
*/
|
*/
|
||||||
private void spawnNow() {
|
private void spawnNow() {
|
||||||
|
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
KothSpawnEvent event = new KothSpawnEvent(this);
|
KothSpawnEvent event = new KothSpawnEvent(this);
|
||||||
event.callEvent();
|
event.callEvent();
|
||||||
|
|
||||||
@ -327,7 +346,7 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
message = message.replace("%z%", String.valueOf(center.getBlockZ()));
|
message = message.replace("%z%", String.valueOf(center.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int seconds = this.currentCaptureSeconds == null ? this.captureSeconds : currentCaptureSeconds.get();
|
int seconds = this.currentCaptureSeconds == null ? this.captureSeconds : this.currentCaptureSeconds.get();
|
||||||
message = message.replace("%capture%", TimerBuilder.getStringTime(seconds));
|
message = message.replace("%capture%", TimerBuilder.getStringTime(seconds));
|
||||||
message = message.replace("%world%", center.getWorld().getName());
|
message = message.replace("%world%", center.getWorld().getName());
|
||||||
message = message.replace("%name%", this.name);
|
message = message.replace("%name%", this.name);
|
||||||
@ -336,6 +355,25 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
: this.currentPlayer.getName();
|
: this.currentPlayer.getName();
|
||||||
message = message.replace("%player%", player);
|
message = message.replace("%player%", player);
|
||||||
|
|
||||||
|
int value = (int) this.getValue(this.currentPlayer);
|
||||||
|
message = message.replace("%points%", String.valueOf(value));
|
||||||
|
message = message.replace("%maxPoints%", String.valueOf(this.maxPoints));
|
||||||
|
message = message.replace("%pointsPercent%",
|
||||||
|
String.valueOf(this.format(this.percent(value, this.maxPoints), Config.percentPrecision)));
|
||||||
|
|
||||||
|
message = message.replace("%timer%", TimerBuilder.getStringTime(value));
|
||||||
|
message = message.replace("%maxTimer%", TimerBuilder.getStringTime(this.maxSecondsCap));
|
||||||
|
|
||||||
|
message = message.replace("%timerSeconds%", String.valueOf(value));
|
||||||
|
message = message.replace("%maxTimerSeconds%", String.valueOf(this.maxSecondsCap));
|
||||||
|
|
||||||
|
message = message.replace("%timerPercent%",
|
||||||
|
String.valueOf(this.format(this.percent(value, this.maxSecondsCap), Config.percentPrecision)));
|
||||||
|
|
||||||
|
message = message.replace("%timerProgress%", this.getProgressBar(value, this.maxSecondsCap, Config.progressBarTimer));
|
||||||
|
message = message.replace("%pointsProgress%", this.getProgressBar(value, this.maxPoints, Config.progressBarPoints));
|
||||||
|
message = message.replace("%classicProgress%", this.getProgressBar(this.captureSeconds - seconds, this.captureSeconds, Config.progressBarClassic));
|
||||||
|
|
||||||
String faction = this.currentPlayer == null ? Message.ZKOHT_EVENT_FACION.getMessage()
|
String faction = this.currentPlayer == null ? Message.ZKOHT_EVENT_FACION.getMessage()
|
||||||
: this.factionListener.getFactionTag(this.currentPlayer);
|
: this.factionListener.getFactionTag(this.currentPlayer);
|
||||||
message = message.replace("%faction%", faction);
|
message = message.replace("%faction%", faction);
|
||||||
@ -455,7 +493,7 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
broadcast(Message.ZKOHT_EVENT_TIMER);
|
broadcast(Message.ZKOHT_EVENT_TIMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpCapture <= 0) {
|
if (this.hasWin()) {
|
||||||
|
|
||||||
this.endKoth(task, cuboid, player);
|
this.endKoth(task, cuboid, player);
|
||||||
|
|
||||||
@ -465,7 +503,16 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
this.factionListener.getFactionTag(player));
|
this.factionListener.getFactionTag(player));
|
||||||
capEvent.callEvent();
|
capEvent.callEvent();
|
||||||
|
|
||||||
this.currentCaptureSeconds.decrementAndGet();
|
switch (this.getType()) {
|
||||||
|
case CLASSIC:
|
||||||
|
default:
|
||||||
|
this.currentCaptureSeconds.decrementAndGet();
|
||||||
|
break;
|
||||||
|
case POINT:
|
||||||
|
case TIMER:
|
||||||
|
this.playersValues.put(this.currentPlayer, this.getValue(this.currentPlayer) + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -475,11 +522,11 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
|
|
||||||
switch (this.getType()) {
|
switch (this.getType()) {
|
||||||
case CLASSIC:
|
case CLASSIC:
|
||||||
return this.currentCaptureSeconds != null && this.currentCaptureSeconds.get() <= 0;
|
return this.currentCaptureSeconds == null && this.currentCaptureSeconds.get() <= 0;
|
||||||
case POINT:
|
case POINT:
|
||||||
return this.currentPlayer != null ? false : this.getValue(this.currentPlayer) >= this.maxPoints;
|
return this.currentPlayer == null ? false : this.getValue(this.currentPlayer) >= this.maxPoints;
|
||||||
case TIMER:
|
case TIMER:
|
||||||
return this.currentPlayer != null ? false : this.getValue(this.currentPlayer) >= this.maxSecondsCap;
|
return this.currentPlayer == null ? false : this.getValue(this.currentPlayer) >= this.maxSecondsCap;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -663,12 +710,18 @@ public class ZKoth extends ZUtils implements Koth {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Player, Long> getValues() {
|
public Map<Player, Long> getValues() {
|
||||||
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
return this.playersValues;
|
return this.playersValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getValue(Player player) {
|
public long getValue(Player player) {
|
||||||
return this.playersValues.getOrDefault(player, 0l);
|
if (this.playersValues == null) {
|
||||||
|
this.playersValues = new HashMap<>();
|
||||||
|
}
|
||||||
|
return player == null ? 0l : this.playersValues.getOrDefault(player, 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -446,10 +446,12 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
|
|||||||
String location = center.getWorld().getName() + ", " + center.getBlockX() + ", " + center.getBlockY() + ", "
|
String location = center.getWorld().getName() + ", " + center.getBlockX() + ", " + center.getBlockY() + ", "
|
||||||
+ center.getBlockZ();
|
+ center.getBlockZ();
|
||||||
|
|
||||||
message(sender, "§fName: §b%s", koth.getName());
|
message(sender, "§fName: §b%name%", "%name%", koth.getName());
|
||||||
message(sender, "§fCoordinate: §b%s", location);
|
message(sender, "§fCoordinate: §b%location%", "%location%", location);
|
||||||
message(sender, "§fType: §b%s", koth.getType().name());
|
message(sender, "§fType: §b%type%", "%type%", name(koth.getType().name()));
|
||||||
message(sender, "§fLoot type: §b%s", koth.getLootType().name());
|
message(sender, "§fMax points: §b%points%", "%points%", koth.getMaxPoints());
|
||||||
|
message(sender, "§fMax timer seconds: §b%timer%", "%timer%", koth.getMaxSecondsCap());
|
||||||
|
message(sender, "§fLoot type: §b%lootType%", "%lootType%", name(koth.getLootType().name()));
|
||||||
message(sender, "§fCommands §8(§7" + koth.getCommands().size() + "§8):");
|
message(sender, "§fCommands §8(§7" + koth.getCommands().size() + "§8):");
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
koth.getCommands().forEach(command -> messageWO(sender, " §7" + command));
|
koth.getCommands().forEach(command -> messageWO(sender, " §7" + command));
|
||||||
@ -540,7 +542,38 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
|
|||||||
|
|
||||||
this.save(this.plugin.getPersist());
|
this.save(this.plugin.getPersist());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setKothPoints(CommandSender sender, String name, int points) {
|
||||||
|
|
||||||
|
Optional<Koth> optional = getKoth(name);
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
message(sender, Message.ZKOTH_DOESNT_EXIST, "%name%", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Koth koth = optional.get();
|
||||||
|
koth.setMaxPoints(points);
|
||||||
|
message(sender, Message.ZKOTH_POINTS_EDIT, "%points%", points, "%name%", koth.getName());
|
||||||
|
|
||||||
|
this.save(this.plugin.getPersist());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setKothTimerSeconds(CommandSender sender, String name, int seconds) {
|
||||||
|
Optional<Koth> optional = getKoth(name);
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
message(sender, Message.ZKOTH_DOESNT_EXIST, "%name%", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Koth koth = optional.get();
|
||||||
|
koth.setMaxSecondsCap(seconds);
|
||||||
|
message(sender, Message.ZKOTH_TIMER_EDIT, "%seconds%", seconds, "%name%", koth.getName());
|
||||||
|
|
||||||
|
this.save(this.plugin.getPersist());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLoots(Player player, String name) {
|
public void updateLoots(Player player, String name) {
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public interface KothManager extends Saveable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Koth> getActiveKoths();
|
public List<Koth> getActiveKoths();
|
||||||
|
|
||||||
public List<Koth> getEnableKoths();
|
public List<Koth> getEnableKoths();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +147,7 @@ public interface KothManager extends Saveable {
|
|||||||
* @param second
|
* @param second
|
||||||
*/
|
*/
|
||||||
public void setCaptureSeconds(CommandSender sender, String name, int second);
|
public void setCaptureSeconds(CommandSender sender, String name, int second);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@ -162,4 +162,20 @@ public interface KothManager extends Saveable {
|
|||||||
*/
|
*/
|
||||||
public void setKothType(CommandSender sender, String name, KothType kothType);
|
public void setKothType(CommandSender sender, String name, KothType kothType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param name
|
||||||
|
* @param seconds
|
||||||
|
*/
|
||||||
|
public void setKothTimerSeconds(CommandSender sender, String name, int seconds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param name
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
|
public void setKothPoints(CommandSender sender, String name, int points);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class CommandKoth extends VCommand {
|
|||||||
this.addSubCommand(new CommandKothRemove(plugin));
|
this.addSubCommand(new CommandKothRemove(plugin));
|
||||||
this.addSubCommand(new CommandKothSetType(plugin));
|
this.addSubCommand(new CommandKothSetType(plugin));
|
||||||
this.addSubCommand(new CommandKothSetLootType(plugin));
|
this.addSubCommand(new CommandKothSetLootType(plugin));
|
||||||
|
this.addSubCommand(new CommandKothSetTimer(plugin));
|
||||||
|
this.addSubCommand(new CommandKothSetPoints(plugin));
|
||||||
this.addSubCommand(new CommandKothLoot(plugin));
|
this.addSubCommand(new CommandKothLoot(plugin));
|
||||||
this.addSubCommand(new CommandKothSetCapture(plugin));
|
this.addSubCommand(new CommandKothSetCapture(plugin));
|
||||||
this.addSubCommand(new CommandKothAxe(plugin));
|
this.addSubCommand(new CommandKothAxe(plugin));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.maxlego08.zkoth.command.commands;
|
package fr.maxlego08.zkoth.command.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import fr.maxlego08.zkoth.ZKothPlugin;
|
import fr.maxlego08.zkoth.ZKothPlugin;
|
||||||
@ -21,11 +22,14 @@ public class CommandKothAxe extends VCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected CommandType perform(ZKothPlugin plugin) {
|
protected CommandType perform(ZKothPlugin plugin) {
|
||||||
|
|
||||||
|
|
||||||
ItemStack itemStack = this.manager.getKothAxe();
|
ItemStack itemStack = this.manager.getKothAxe();
|
||||||
this.player.getInventory().addItem(itemStack);
|
this.player.getInventory().addItem(itemStack);
|
||||||
message(this.sender, Message.ZKOTH_AXE_RECEIVE);
|
message(this.sender, Message.ZKOTH_AXE_RECEIVE);
|
||||||
|
|
||||||
|
for (int a = 0; a != 200; a++) {
|
||||||
|
Bukkit.broadcastMessage("");
|
||||||
|
}
|
||||||
|
|
||||||
return CommandType.SUCCESS;
|
return CommandType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package fr.maxlego08.zkoth.command.commands;
|
||||||
|
|
||||||
|
import fr.maxlego08.zkoth.ZKothPlugin;
|
||||||
|
import fr.maxlego08.zkoth.command.VCommand;
|
||||||
|
import fr.maxlego08.zkoth.zcore.enums.Message;
|
||||||
|
import fr.maxlego08.zkoth.zcore.enums.Permission;
|
||||||
|
import fr.maxlego08.zkoth.zcore.utils.commands.CommandType;
|
||||||
|
|
||||||
|
public class CommandKothSetPoints extends VCommand {
|
||||||
|
|
||||||
|
public CommandKothSetPoints(ZKothPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
this.addCompletion(0, (a, b) -> plugin.getKothManager().getKothNames());
|
||||||
|
this.setPermission(Permission.ZKOTH_POINTS);
|
||||||
|
this.addSubCommand("setpoints");
|
||||||
|
this.setDescription(Message.DESCRIPTION_POINTS);
|
||||||
|
this.addRequireArg("points");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandType perform(ZKothPlugin plugin) {
|
||||||
|
|
||||||
|
String name = this.argAsString(0);
|
||||||
|
int points = this.argAsInteger(1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.manager.setKothPoints(this.sender, name, points);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return CommandType.SYNTAX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommandType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package fr.maxlego08.zkoth.command.commands;
|
||||||
|
|
||||||
|
import fr.maxlego08.zkoth.ZKothPlugin;
|
||||||
|
import fr.maxlego08.zkoth.command.VCommand;
|
||||||
|
import fr.maxlego08.zkoth.zcore.enums.Message;
|
||||||
|
import fr.maxlego08.zkoth.zcore.enums.Permission;
|
||||||
|
import fr.maxlego08.zkoth.zcore.utils.commands.CommandType;
|
||||||
|
|
||||||
|
public class CommandKothSetTimer extends VCommand {
|
||||||
|
|
||||||
|
public CommandKothSetTimer(ZKothPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
this.addCompletion(0, (a, b) -> plugin.getKothManager().getKothNames());
|
||||||
|
this.setPermission(Permission.ZKOTH_TIMER);
|
||||||
|
this.addSubCommand("settimer");
|
||||||
|
this.setDescription(Message.DESCRIPTION_TIMER);
|
||||||
|
this.addRequireArg("seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandType perform(ZKothPlugin plugin) {
|
||||||
|
|
||||||
|
String name = this.argAsString(0);
|
||||||
|
int seconds = this.argAsInteger(1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.manager.setKothTimerSeconds(this.sender, name, seconds);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return CommandType.SYNTAX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommandType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,10 @@ public class Config implements Saveable {
|
|||||||
public static long schedulerMillisecond = 1000;
|
public static long schedulerMillisecond = 1000;
|
||||||
public static int cooldownInSecond = 300;
|
public static int cooldownInSecond = 300;
|
||||||
public static int removeChestSec = 120;
|
public static int removeChestSec = 120;
|
||||||
|
public static String percentPrecision = "#.#";
|
||||||
|
public static ProgressBar progressBarPoints = new ProgressBar(10, '|', "§b", "§7");
|
||||||
|
public static ProgressBar progressBarTimer = new ProgressBar(10, '|', "§b", "§7");
|
||||||
|
public static ProgressBar progressBarClassic = new ProgressBar(10, '|', "§b", "§7");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
@ -32,16 +36,22 @@ public class Config implements Saveable {
|
|||||||
scoreboard.add("§6§l⟣ §fFaction: §b%faction%");
|
scoreboard.add("§6§l⟣ §fFaction: §b%faction%");
|
||||||
scoreboard.add("§0");
|
scoreboard.add("§0");
|
||||||
scoreboard.add("§6§l⟣ §fTime: §d%capture%");
|
scoreboard.add("§6§l⟣ §fTime: §d%capture%");
|
||||||
|
scoreboard.add("§b");
|
||||||
|
scoreboard.add("§6§l⟣ §fPoints: §b%points%§f/§a%maxPoints%");
|
||||||
|
scoreboard.add("§6§l⟣ §fPercent: §b%pointsPercent%§7%");
|
||||||
|
scoreboard.add("§6§l⟣ §fTimer: §b%timer%");
|
||||||
|
scoreboard.add("§6§l⟣ §fTimer: §b%timerSeconds%§f/§a%maxTimerSeconds%");
|
||||||
|
scoreboard.add("§6§l⟣ §fPercent: §b%timerPercent%§7%");
|
||||||
scoreboard.add("§1");
|
scoreboard.add("§1");
|
||||||
scoreboard.add("§6§l⟣ §fhttps://groupez.dev");
|
scoreboard.add("§6§l⟣ §fhttps://groupez.dev");
|
||||||
|
|
||||||
scoreboardCooldown.add("§r");
|
scoreboardCooldown.add("§r");
|
||||||
scoreboardCooldown.add("§6§l⟣ §fKoth: §b%name%");
|
scoreboardCooldown.add("§6§l⟣ §fKoth: §b%name%");
|
||||||
scoreboardCooldown.add("§6§l⟣ §fCoordinate: §b%x% %y% %z%");
|
scoreboardCooldown.add("§6§l⟣ §fCoordinate: §b%x% %y% %z%");
|
||||||
scoreboardCooldown.add("§6§l⟣ §fStarts in: §d%capture%");
|
scoreboardCooldown.add("§6§l⟣ §fStarts in: §d%capture%");
|
||||||
scoreboardCooldown.add("§1");
|
scoreboardCooldown.add("§1");
|
||||||
scoreboardCooldown.add("§6§l⟣ §fhttps://groupez.dev");
|
scoreboardCooldown.add("§6§l⟣ §fhttps://groupez.dev");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
52
src/fr/maxlego08/zkoth/save/ProgressBar.java
Normal file
52
src/fr/maxlego08/zkoth/save/ProgressBar.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package fr.maxlego08.zkoth.save;
|
||||||
|
|
||||||
|
public class ProgressBar {
|
||||||
|
|
||||||
|
private final int lenght;
|
||||||
|
private final char symbol;
|
||||||
|
private final String completedColor;
|
||||||
|
private final String notCompletedColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lenght
|
||||||
|
* @param symbol
|
||||||
|
* @param completedColor
|
||||||
|
* @param notCompletedColor
|
||||||
|
*/
|
||||||
|
public ProgressBar(int lenght, char symbol, String completedColor, String notCompletedColor) {
|
||||||
|
super();
|
||||||
|
this.lenght = lenght;
|
||||||
|
this.symbol = symbol;
|
||||||
|
this.completedColor = completedColor;
|
||||||
|
this.notCompletedColor = notCompletedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lenght
|
||||||
|
*/
|
||||||
|
public int getLenght() {
|
||||||
|
return lenght;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the symbol
|
||||||
|
*/
|
||||||
|
public char getSymbol() {
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the completedColor
|
||||||
|
*/
|
||||||
|
public String getCompletedColor() {
|
||||||
|
return completedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the notCompletedColor
|
||||||
|
*/
|
||||||
|
public String getNotCompletedColor() {
|
||||||
|
return notCompletedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,7 +55,9 @@ public class ScoreBoardManager extends ZUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.boards.forEach((player, board) -> board.updateLines(this.lines.accept(player)));
|
this.boards.forEach((player, board) -> {
|
||||||
|
board.updateLines(this.lines.accept(player));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,8 @@ public enum Message {
|
|||||||
ZKOTH_COMMAND_DELETE("§aYou have just deleted a command."),
|
ZKOTH_COMMAND_DELETE("§aYou have just deleted a command."),
|
||||||
ZKOTH_LOOT_EDIT("§aYou have just set the loot type to §f%type%§a."),
|
ZKOTH_LOOT_EDIT("§aYou have just set the loot type to §f%type%§a."),
|
||||||
ZKOTH_TYPE_EDIT("§aYou have just set the type to §f%type%§a."),
|
ZKOTH_TYPE_EDIT("§aYou have just set the type to §f%type%§a."),
|
||||||
|
ZKOTH_POINTS_EDIT("§aYou have just set the points to §f%points%§a."),
|
||||||
|
ZKOTH_TIMER_EDIT("§aYou have just set the timer to §f%seconds%§a."),
|
||||||
ZKOTH_LOOT_INVENTORY("§7Loots §b%name%"),
|
ZKOTH_LOOT_INVENTORY("§7Loots §b%name%"),
|
||||||
ZKOTH_LOOT_CHANGE("§aYou have just modified the loots of the koth §2%name%§a."),
|
ZKOTH_LOOT_CHANGE("§aYou have just modified the loots of the koth §2%name%§a."),
|
||||||
ZKOTH_CAPUTRE_EDIT("§aYou have just modified the capture time of the koth §n%name%§a to §f%seconds%§a."),
|
ZKOTH_CAPUTRE_EDIT("§aYou have just modified the capture time of the koth §n%name%§a to §f%seconds%§a."),
|
||||||
@ -131,6 +133,8 @@ public enum Message {
|
|||||||
DESCRIPTION_SPAWN("Spawn a koth with cooldown"),
|
DESCRIPTION_SPAWN("Spawn a koth with cooldown"),
|
||||||
DESCRIPTION_CAPTURE("Set capture time for a koth"),
|
DESCRIPTION_CAPTURE("Set capture time for a koth"),
|
||||||
DESCRIPTION_TYPE("Set koth type (classic, point, timer)"),
|
DESCRIPTION_TYPE("Set koth type (classic, point, timer)"),
|
||||||
|
DESCRIPTION_TIMER("Set koth max second for timer type"),
|
||||||
|
DESCRIPTION_POINTS("Set koth max point for point type"),
|
||||||
DESCRIPTION_LOOTTYPE("Set loot type for a koth"),
|
DESCRIPTION_LOOTTYPE("Set loot type for a koth"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -17,6 +17,8 @@ public enum Permission {
|
|||||||
ZKOTH_COMMAND_REMOVE,
|
ZKOTH_COMMAND_REMOVE,
|
||||||
ZKOTH_LOOT,
|
ZKOTH_LOOT,
|
||||||
ZKOTH_TYPE,
|
ZKOTH_TYPE,
|
||||||
|
ZKOTH_TIMER,
|
||||||
|
ZKOTH_POINTS,
|
||||||
ZKOTH_LOOT_TYPE,
|
ZKOTH_LOOT_TYPE,
|
||||||
ZKOTH_SETCAPTURE,
|
ZKOTH_SETCAPTURE,
|
||||||
ZKOTH_SCHEDULER,
|
ZKOTH_SCHEDULER,
|
||||||
|
@ -44,11 +44,13 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
import fr.maxlego08.zkoth.ZKothPlugin;
|
import fr.maxlego08.zkoth.ZKothPlugin;
|
||||||
import fr.maxlego08.zkoth.api.enums.DefaultFontInfo;
|
import fr.maxlego08.zkoth.api.enums.DefaultFontInfo;
|
||||||
|
import fr.maxlego08.zkoth.save.ProgressBar;
|
||||||
import fr.maxlego08.zkoth.zcore.ZPlugin;
|
import fr.maxlego08.zkoth.zcore.ZPlugin;
|
||||||
import fr.maxlego08.zkoth.zcore.enums.EnumInventory;
|
import fr.maxlego08.zkoth.zcore.enums.EnumInventory;
|
||||||
import fr.maxlego08.zkoth.zcore.enums.Permission;
|
import fr.maxlego08.zkoth.zcore.enums.Permission;
|
||||||
@ -334,7 +336,7 @@ public abstract class ZUtils extends MessageUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected double percent(double value, double total) {
|
protected double percent(double value, double total) {
|
||||||
return (double) ((value * 100) / total);
|
return total == 0 ? 0 : (double) ((value * 100) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -507,11 +509,11 @@ public abstract class ZUtils extends MessageUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String color(String message) {
|
protected String color(String message) {
|
||||||
|
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NMSUtils.isHexColor()) {
|
if (NMSUtils.isHexColor()) {
|
||||||
Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
|
Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
|
||||||
Matcher matcher = pattern.matcher(message);
|
Matcher matcher = pattern.matcher(message);
|
||||||
@ -521,7 +523,7 @@ public abstract class ZUtils extends MessageUtils {
|
|||||||
matcher = pattern.matcher(message);
|
matcher = pattern.matcher(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return message.replace("&", "§");
|
return message.replace("&", "§");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,4 +1138,21 @@ public abstract class ZUtils extends MessageUtils {
|
|||||||
|| day.equalsIgnoreCase("SATURDAY") || day.equalsIgnoreCase("SUNDAY");
|
|| day.equalsIgnoreCase("SATURDAY") || day.equalsIgnoreCase("SUNDAY");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProgressBar(int current, int max, int totalBars, char symbol, String completedColor,
|
||||||
|
String notCompletedColor) {
|
||||||
|
try {
|
||||||
|
float percent = (float) current / max;
|
||||||
|
int progressBars = (int) (totalBars * percent);
|
||||||
|
return Strings.repeat(completedColor + symbol, progressBars)
|
||||||
|
+ Strings.repeat(notCompletedColor + symbol, totalBars - progressBars);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Strings.repeat(notCompletedColor + symbol, totalBars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProgressBar(int current, int max, ProgressBar progressBar) {
|
||||||
|
return this.getProgressBar(current, max, progressBar.getLenght(), progressBar.getSymbol(),
|
||||||
|
progressBar.getCompletedColor(), progressBar.getNotCompletedColor());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user