From f09825061659753372f8d51e5b19c1315b6d8339 Mon Sep 17 00:00:00 2001 From: PMFRTT <37709302+PMFRTT@users.noreply.github.com> Date: Sun, 21 Mar 2021 18:57:13 +0100 Subject: [PATCH] upped version to 16.5.23 --- pom.xml | 2 +- src/main/java/bingo/BingoInventory.java | 2 +- src/main/java/bingo/BingoPlugin.java | 56 ++++--------------- .../commandExecutor/BingoCommandExecutor.java | 2 +- .../bingo/eventhandler/CheckInventory.java | 2 +- 5 files changed, 14 insertions(+), 50 deletions(-) diff --git a/pom.xml b/pom.xml index 4d2bec0..7dd2c2d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ Bingo Bingo - 16.5.21 + 16.5.23 jar Bingo diff --git a/src/main/java/bingo/BingoInventory.java b/src/main/java/bingo/BingoInventory.java index 628413b..5f91e8b 100644 --- a/src/main/java/bingo/BingoInventory.java +++ b/src/main/java/bingo/BingoInventory.java @@ -21,7 +21,7 @@ private static ItemStack createItemStack() { ItemStack itemStack = new ItemStack(Material.TURTLE_HELMET, 1); ItemMeta itemMeta = itemStack.getItemMeta(); assert itemMeta != null; - itemMeta.setDisplayName(ChatColor.GOLD + "Abgeschlossen!" + BingoPlugin.seconds); + //itemMeta.setDisplayName(ChatColor.GOLD + "Abgeschlossen!" + BingoPlugin.seconds); itemMeta.hasEnchants(); itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); itemMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, true); diff --git a/src/main/java/bingo/BingoPlugin.java b/src/main/java/bingo/BingoPlugin.java index 8d35396..4bf0e6e 100644 --- a/src/main/java/bingo/BingoPlugin.java +++ b/src/main/java/bingo/BingoPlugin.java @@ -7,9 +7,11 @@ import bingo.eventhandler.CheckInventory; import core.core.CoreMain; import core.Utils; +import core.timer.Timer; import core.core.CoreSendStringPacket; import core.settings.SettingCycle; import core.settings.SettingSwitch; +import core.timer.TimerType; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -23,19 +25,18 @@ public final class BingoPlugin extends JavaPlugin { private final BingoEventhandler bingoEventhandler = new BingoEventhandler(this); public BingoSettings bingoSettings; - public static int seconds = 0; - public int difficulty = 0; public static boolean paused = true; public static boolean singleplayer = false; public boolean announce = true; public static SideList sideList; - + public static Timer timer; @Override public void onEnable() { CoreMain.setPlugin(this); + timer = new Timer(this, TimerType.Increasing); bingoEventhandler.initialize(); bingoSettings = new BingoSettings(this); BingoCommandExecutor bingoCommandExecutor = new BingoCommandExecutor(this); @@ -48,47 +49,6 @@ public void onEnable() { Objects.requireNonNull(getCommand("reset")).setExecutor(resetCommandExecutor); BukkitScheduler scheduler1 = getServer().getScheduler(); - scheduler1.scheduleSyncRepeatingTask(this, new Runnable() { - - @Override - public void run() { - if (singleplayer) { - if (!paused) { - seconds--; - } - if (seconds <= 0) { - paused = true; - } - for (Player player : Bukkit.getOnlinePlayers()) { - String msg; - if (!paused) { - msg = Utils.colorize("Du hast noch &b" + Utils.formatTimerTime(seconds) + "&f Zeit"); - } else { - msg = Utils.colorize("&cDas Bingo ist pausiert!"); - } - CoreSendStringPacket.sendPacketToHotbar(player, msg); - - } - } else { - - if (!paused) { - seconds++; - } - - for (Player player : Bukkit.getOnlinePlayers()) { - String msg; - if (!paused) { - msg = Utils.colorize("Das Bingo läuft seit &b" + Utils.formatTimerTime(seconds)); - } else { - msg = Utils.colorize("&cDas Bingo ist pausiert!"); - } - CoreSendStringPacket.sendPacketToHotbar(player, msg); - - } - - } - } - }, 0L, 20); scheduler1.scheduleSyncRepeatingTask(this, new Runnable() { @@ -100,7 +60,8 @@ public void run() { CheckInventory.checkInventory(player, announce, singleplayer, getDifficulty()); BingoInventory.updateInventory(player); } else { - Utils.sendMessageToEveryone(Utils.getPrefix("Bingo") + Utils.colorize("&e" + Utils.getDisplayName(player) + " &fhat das Bingo in &a" + Utils.formatTimerTime(seconds) + "&f beendet!")); + timer.pause(); + Utils.sendMessageToEveryone(Utils.getPrefix("Bingo") + Utils.colorize("&e" + Utils.getDisplayName(player) + " &fhat das Bingo in &a" + Utils.formatTimerTimeTicksThreeDecimal(timer.getTicks()) + "&f beendet!")); Utils.playSoundForAll(Sound.UI_TOAST_CHALLENGE_COMPLETE, 1f, 1f); paused = true; } @@ -132,13 +93,16 @@ public void startBingo() { Utils.changeGamerule(GameRule.KEEP_INVENTORY, true); } if (singleplayer) { - seconds = singlePlayerStartTime.getValue(); + timer.setTimerType(TimerType.Decreasing); + timer.setSeconds(singlePlayerStartTime.getValue()); + timer.setSingle(true); } BingoList.populatePlayerBingoList(difficulty.getValue(), items.getValue()); bingo.Utils.preparePlayers(); sideList.init(); paused = false; + timer.resume(); } public void onDisable() { diff --git a/src/main/java/bingo/commandExecutor/BingoCommandExecutor.java b/src/main/java/bingo/commandExecutor/BingoCommandExecutor.java index 3e12c15..d072bf4 100644 --- a/src/main/java/bingo/commandExecutor/BingoCommandExecutor.java +++ b/src/main/java/bingo/commandExecutor/BingoCommandExecutor.java @@ -47,7 +47,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } else if (args[0].equalsIgnoreCase("start")) { main.startBingo(); }else if(args[0].equalsIgnoreCase("clear")){ - BingoPlugin.seconds = 0; + BingoPlugin.timer.pause(); BingoPlugin.paused = true; BingoList.getBingoList().clear(); BingoList.playerBingoLists.clear(); diff --git a/src/main/java/bingo/eventhandler/CheckInventory.java b/src/main/java/bingo/eventhandler/CheckInventory.java index a922dee..7a730d8 100644 --- a/src/main/java/bingo/eventhandler/CheckInventory.java +++ b/src/main/java/bingo/eventhandler/CheckInventory.java @@ -23,7 +23,7 @@ public static void checkInventory(Player player, boolean announcement, boolean s if (player.getInventory().contains(material)) { if(singleplayer){ double random = min + Math.random() * (max - min) * multiplier; - BingoPlugin.seconds += random; + BingoPlugin.timer.addSeconds((int)random); player.sendMessage(Utils.colorize("&f+&a" + Utils.formatTimerTime((int) random))); } BingoPlugin.sideList.removeScore(player, material);