From ceb2ace0b230deee384d301aa8e255424fcdff14 Mon Sep 17 00:00:00 2001 From: Jeqo <105175461+jeqostudios@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:17:21 -0700 Subject: [PATCH] Removed whitespace that was unneeded (#1) Added some comments to the events Removed redundant casts and unused imports Co-authored-by: Ian Tapply --- pom.xml | 2 +- src/main/java/net/jeqo/bloons/Bloons.java | 49 ++++--------------- .../net/jeqo/bloons/data/BalloonCommand.java | 35 ++++--------- .../net/jeqo/bloons/data/BalloonMenu.java | 32 +++++------- .../net/jeqo/bloons/data/BalloonOwner.java | 28 ++++------- .../jeqo/bloons/listeners/LeashHandlers.java | 20 ++------ .../jeqo/bloons/listeners/MenuHandlers.java | 18 +++---- .../jeqo/bloons/listeners/PlayerHandlers.java | 32 +++++++----- 8 files changed, 69 insertions(+), 147 deletions(-) diff --git a/pom.xml b/pom.xml index 97d21249..b8b23004 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ https://jeqo.net/bloons - 1.8 + 1.17 UTF-8 diff --git a/src/main/java/net/jeqo/bloons/Bloons.java b/src/main/java/net/jeqo/bloons/Bloons.java index 34089240..ae9ada99 100644 --- a/src/main/java/net/jeqo/bloons/Bloons.java +++ b/src/main/java/net/jeqo/bloons/Bloons.java @@ -1,18 +1,17 @@ package net.jeqo.bloons; -import net.jeqo.bloons.data.*; +import net.jeqo.bloons.data.BalloonCommand; +import net.jeqo.bloons.data.BalloonOwner; +import net.jeqo.bloons.data.BalloonTab; +import net.jeqo.bloons.data.UpdateChecker; import net.jeqo.bloons.listeners.LeashHandlers; import net.jeqo.bloons.listeners.MenuHandlers; import net.jeqo.bloons.listeners.PlayerHandlers; import net.jeqo.bloons.utils.Metrics; import net.jeqo.bloons.utils.Utils; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.command.TabCompleter; import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap; import java.util.Objects; @@ -34,14 +33,10 @@ public void onEnable() { loadCommands(); loadListeners(); Metrics metrics = new Metrics(this, pluginId); updateChecker(); getConfig().options().copyDefaults(); saveDefaultConfig(); - - } - @Override public void onDisable() { - Utils.log("|---[ BLOONS ]-------------------------------------------------------|"); Utils.log("| Shutting down... |"); Utils.log("|-------------------------------------------------[ MADE BY JEQO ]---|"); @@ -50,28 +45,8 @@ public void onDisable() { owner.cancel(); } - HandlerList.unregisterAll((Plugin)this); + HandlerList.unregisterAll(this); } - - - - - - - - - - - - - - - - - - - - int pluginId = 16872; public void updateChecker() { @@ -86,9 +61,9 @@ public void updateChecker() { } private void loadListeners() { - getServer().getPluginManager().registerEvents((Listener)new LeashHandlers(), (Plugin)this); - getServer().getPluginManager().registerEvents((Listener)new PlayerHandlers(), (Plugin)this); - getServer().getPluginManager().registerEvents((Listener)new MenuHandlers(), (Plugin)this); + getServer().getPluginManager().registerEvents(new LeashHandlers(), this); + getServer().getPluginManager().registerEvents(new PlayerHandlers(), this); + getServer().getPluginManager().registerEvents(new MenuHandlers(), this); } private void loadCommands() { @@ -113,13 +88,7 @@ public static String getString(String path) { return getInstance().getConfig().getString(path); } - public static Integer getInt(String path) { return getInstance().getConfig().getInt(path); } - - - public static ConfigurationSection getConfigSec(String s) { - return instance.getConfig().getConfigurationSection(s); - } } \ No newline at end of file diff --git a/src/main/java/net/jeqo/bloons/data/BalloonCommand.java b/src/main/java/net/jeqo/bloons/data/BalloonCommand.java index 7535cf3c..63191e0d 100644 --- a/src/main/java/net/jeqo/bloons/data/BalloonCommand.java +++ b/src/main/java/net/jeqo/bloons/data/BalloonCommand.java @@ -27,6 +27,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command String balloonId; BalloonOwner owner; Bloons plugin = Bloons.getInstance(); + if (args.length < 1) { if (sender instanceof Player) { player = (Player) sender; @@ -38,13 +39,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command sender.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("no-permission")); return true; } - ArrayList items = new ArrayList(); + ArrayList items = new ArrayList<>(); for (String key : Objects.requireNonNull(Bloons.getInstance().getConfig().getConfigurationSection("balloons")).getKeys(false)) { ConfigurationSection keySection = Objects.requireNonNull(Bloons.getInstance().getConfig().getConfigurationSection("balloons")).getConfigurationSection(key); - - if (Bloons.getString("hide-balloons-without-permission").equalsIgnoreCase("true")) { if (player.hasPermission(Bloons.getString("balloons." + key + ".permission"))) { assert keySection != null; @@ -54,9 +53,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command meta.setLocalizedName(Bloons.getString("balloons." + key + ".id")); if (Bloons.getString("balloons." + key + ".lore") != null) { List lore = keySection.getStringList("lore"); - for (int i = 0; i < lore.size(); i++) { - lore.set(i, Utils.hex(lore.get(i))); - } + lore.replaceAll(Utils::hex); meta.setLore(lore); } meta.setDisplayName(Utils.hex(keySection.getString("name"))); @@ -73,11 +70,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command items.add(item); } - } - - - - else { + } else { assert keySection != null; ItemStack item = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(keySection.getString("material"))))); ItemMeta meta = item.getItemMeta(); @@ -85,9 +78,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command meta.setLocalizedName(Bloons.getString("balloons." + key + ".id")); if (Bloons.getString("balloons." + key + ".lore") != null) { List lore = keySection.getStringList("lore"); - for (int i = 0; i < lore.size(); i++) { - lore.set(i, Utils.hex(lore.get(i))); - } + lore.replaceAll(Utils::hex); meta.setLore(lore); } meta.setDisplayName(Utils.hex(keySection.getString("name"))); @@ -104,18 +95,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command items.add(item); } - - - } new BalloonMenu(items, Bloons.getString("menu-title"), player); return true; } - - - - switch (args[0]) { case "equip": if (args.length < 2) { @@ -144,7 +128,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return true; } - Utils.removeBalloon(player, (BalloonOwner) Bloons.playerBalloons.get(player.getUniqueId())); + Utils.removeBalloon(player, Bloons.playerBalloons.get(player.getUniqueId())); BalloonOwner.checkBalloonRemovalOrAdd(player, str1); player.playSound(player.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1, 1); String balloonName = Bloons.getString("balloons." + str1 + ".name"); @@ -163,7 +147,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command sender.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("no-permission")); return true; } - balloonOwner1 = (BalloonOwner) Bloons.playerBalloons.get(player.getUniqueId()); + balloonOwner1 = Bloons.playerBalloons.get(player.getUniqueId()); if (balloonOwner1 == null) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO, 1, 1); player.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("not-equipped")); @@ -211,7 +195,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command sender.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("player-not-found")); return true; } - owner = (BalloonOwner) Bloons.playerBalloons.get(player.getUniqueId()); + owner = Bloons.playerBalloons.get(player.getUniqueId()); if (owner == null) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO, 1, 1); sender.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("not-equipped")); @@ -235,6 +219,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command usage(sender); return true; } + void usage(CommandSender sender) { sender.sendMessage(""); if (sender.hasPermission("bloons.menu")) { @@ -257,6 +242,4 @@ void usage(CommandSender sender) { sender.sendMessage(Utils.hex(" #ff00ccB#f406cfl#e80bd3o#dd11d6o#d217dan#c61cdds #bb22e01#b028e4.#a42de70#9933eb.#8e39ee1#823ef5-#7744f5B#6c4af8E#604ffcT#5555ffA &7- &fMade by Jeqo")); sender.sendMessage(""); } - - String bloonsPrefix = Utils.hex("#ff00cc[#e207c5B#c50fbdl#a816b6o#8a1dafo#6d24a8n#502ca0s#333399] &r"); } \ No newline at end of file diff --git a/src/main/java/net/jeqo/bloons/data/BalloonMenu.java b/src/main/java/net/jeqo/bloons/data/BalloonMenu.java index 2466854e..c906dd6c 100644 --- a/src/main/java/net/jeqo/bloons/data/BalloonMenu.java +++ b/src/main/java/net/jeqo/bloons/data/BalloonMenu.java @@ -16,10 +16,10 @@ public class BalloonMenu { - public ArrayList pages = new ArrayList(); + public ArrayList pages = new ArrayList<>(); public UUID id; public int currpage = 0; - public static HashMap users = new HashMap(); + public static HashMap users = new HashMap<>(); private Inventory getBlankPage(String name){ int pageSize = Bloons.getInt("menu-size"); Inventory page = Bukkit.createInventory(null, pageSize, Utils.hex(name)); @@ -45,32 +45,28 @@ private Inventory getBlankPage(String name){ removeMeta.setCustomModelData(Bloons.getInt("buttons.unequip.custom-model-data")); removeBalloon.setItemMeta(removeMeta); - - - - List previousPageSlots = Bloons.getInstance().getConfig().getStringList("buttons.previous-page.slots"); - for (int i = 0; i < previousPageSlots.size(); i++) { - if (Integer.parseInt(previousPageSlots.get(i)) < pageSize) { - page.setItem(Integer.parseInt(previousPageSlots.get(i)), prevPage); + for (String previousPageSlot : previousPageSlots) { + if (Integer.parseInt(previousPageSlot) < pageSize) { + page.setItem(Integer.parseInt(previousPageSlot), prevPage); } else { Utils.warn("Previous page button slot(s) out of bounds!"); } } List unequipSlots = Bloons.getInstance().getConfig().getStringList("buttons.unequip.slots"); - for (int i = 0; i < unequipSlots.size(); i++) { - if (Integer.parseInt(unequipSlots.get(i)) < pageSize){ - page.setItem(Integer.parseInt(unequipSlots.get(i)), removeBalloon); + for (String unequipSlot : unequipSlots) { + if (Integer.parseInt(unequipSlot) < pageSize) { + page.setItem(Integer.parseInt(unequipSlot), removeBalloon); } else { Utils.warn("Unequip button slot(s) out of bounds!"); } } List nextPageSlots = Bloons.getInstance().getConfig().getStringList("buttons.next-page.slots"); - for (int i = 0; i < nextPageSlots.size(); i++) { - if (Integer.parseInt(nextPageSlots.get(i)) < pageSize) { - page.setItem(Integer.parseInt(nextPageSlots.get(i)), nextPage); + for (String nextPageSlot : nextPageSlots) { + if (Integer.parseInt(nextPageSlot) < pageSize) { + page.setItem(Integer.parseInt(nextPageSlot), nextPage); } else { Utils.warn("Next page button slot(s) out of bounds!"); } @@ -78,12 +74,6 @@ private Inventory getBlankPage(String name){ return page; } - - - - - - public BalloonMenu(ArrayList items, String name, Player p){ this.id = UUID.randomUUID(); Inventory page = getBlankPage(name); diff --git a/src/main/java/net/jeqo/bloons/data/BalloonOwner.java b/src/main/java/net/jeqo/bloons/data/BalloonOwner.java index 4ebb9bb8..621f7ed8 100644 --- a/src/main/java/net/jeqo/bloons/data/BalloonOwner.java +++ b/src/main/java/net/jeqo/bloons/data/BalloonOwner.java @@ -1,10 +1,6 @@ package net.jeqo.bloons.data; import net.jeqo.bloons.Bloons; - -import java.util.Objects; -import java.util.concurrent.ThreadLocalRandom; - import net.jeqo.bloons.utils.Utils; import org.bukkit.Location; import org.bukkit.Material; @@ -17,15 +13,16 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; +import java.util.Objects; +import java.util.concurrent.ThreadLocalRandom; + public class BalloonOwner extends BukkitRunnable { private final Player player; private final ItemStack balloon; - private final String balloonId; private ArmorStand armorStand; public Chicken chicken; private Location playerLocation; @@ -35,7 +32,6 @@ public class BalloonOwner extends BukkitRunnable { public BalloonOwner(Player player, String balloonId) { this.player = player; - this.balloonId = balloonId; ConfigurationSection configuration = Bloons.getInstance().getConfig().getConfigurationSection("balloons." + balloonId); assert configuration != null; ItemStack item = new ItemStack(Material.valueOf(configuration.getString("material"))); @@ -54,7 +50,6 @@ public BalloonOwner(Player player, String balloonId) { this.balloon = item; } - public void run() { if (this.armorStand == null) { initBalloon(); @@ -83,7 +78,6 @@ public void run() { this.ticks++; } - public synchronized void cancel() throws IllegalStateException { this.armorStand.remove(); this.chicken.remove(); @@ -93,9 +87,6 @@ public synchronized void cancel() throws IllegalStateException { public void spawnRemoveParticle() { this.moveLocation.getWorld().spawnParticle(Particle.CLOUD, this.moveLocation, 5, 0.0D, 0.0D, 0.0D, 0.1D); } - public String getBalloonId() { - return this.balloonId; - } private void teleport(Location location) { this.armorStand.teleport(location.add(0.0D, 2.0D, 0.0D)); @@ -107,10 +98,11 @@ private void initBalloon() { this.playerLocation.setYaw(0.0F); ItemMeta meta = this.balloon.getItemMeta(); - meta.addItemFlags(new ItemFlag[] {ItemFlag.HIDE_UNBREAKABLE }); + assert meta != null; + meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); this.balloon.setItemMeta(meta); - this.armorStand = (ArmorStand) Objects.requireNonNull(this.playerLocation.getWorld()).spawn(this.playerLocation, ArmorStand.class); + this.armorStand = Objects.requireNonNull(this.playerLocation.getWorld()).spawn(this.playerLocation, ArmorStand.class); this.armorStand.setBasePlate(false); this.armorStand.setVisible(false); this.armorStand.setInvulnerable(true); @@ -122,7 +114,7 @@ private void initBalloon() { this.armorStand.getEquipment().setHelmet(this.balloon); this.armorStand.setCustomName("4001147"); - this.chicken = (Chicken)this.playerLocation.getWorld().spawn(this.playerLocation, Chicken.class); + this.chicken = this.playerLocation.getWorld().spawn(this.playerLocation, Chicken.class); this.chicken.setInvulnerable(true); this.chicken.setInvisible(true); this.chicken.setSilent(true); @@ -138,17 +130,17 @@ private void initBalloon() { public static void checkBalloonRemovalOrAdd(final Player player, final String balloonId) { (new BukkitRunnable() { public void run() { - BalloonOwner owner = (BalloonOwner) Bloons.playerBalloons.get(player.getUniqueId()); + BalloonOwner owner = Bloons.playerBalloons.get(player.getUniqueId()); if (owner != null) { return; } Utils.removeBalloon(player, owner); BalloonOwner balloonOwner = new BalloonOwner(player, balloonId); - balloonOwner.runTaskTimer((Plugin) Bloons.getInstance(), 0L, 1L); + balloonOwner.runTaskTimer(Bloons.getInstance(), 0L, 1L); Bloons.playerBalloons.put(player.getUniqueId(), balloonOwner); Bloons.playerBalloonID.put(player.getUniqueId(), balloonId); } - }).runTaskLater((Plugin) Bloons.getInstance(), 1L); + }).runTaskLater(Bloons.getInstance(), 1L); } } \ No newline at end of file diff --git a/src/main/java/net/jeqo/bloons/listeners/LeashHandlers.java b/src/main/java/net/jeqo/bloons/listeners/LeashHandlers.java index 02f8621e..e3eabced 100644 --- a/src/main/java/net/jeqo/bloons/listeners/LeashHandlers.java +++ b/src/main/java/net/jeqo/bloons/listeners/LeashHandlers.java @@ -1,18 +1,16 @@ package net.jeqo.bloons.listeners; -import net.jeqo.bloons.data.BalloonOwner; -import org.bukkit.Bukkit; -import org.bukkit.entity.Chicken; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityUnleashEvent; import org.bukkit.event.player.PlayerUnleashEntityEvent; -import java.util.Objects; - public class LeashHandlers implements Listener { @EventHandler + /** + * Used to check if player tries to unleash from their balloon, if they do then cancel it + */ public void onUnleash(PlayerUnleashEntityEvent e) { if (e.getReason() == EntityUnleashEvent.UnleashReason.PLAYER_UNLEASH) { if (e.getEntity().getCustomName() != null && e.getEntity().getCustomName().contains("4001148")) { @@ -20,16 +18,4 @@ public void onUnleash(PlayerUnleashEntityEvent e) { } } } - - public void deadBalloonChecker() { - Objects.requireNonNull(Bukkit.getWorld("world")).getEntities().forEach(entity -> { - if (entity.getCustomName() != null && entity.getCustomName().contains("4001148")) { - entity.remove(); - } - if (entity.getCustomName() != null && entity.getCustomName().contains("4001147")) { - entity.remove(); - } - }); - } - } diff --git a/src/main/java/net/jeqo/bloons/listeners/MenuHandlers.java b/src/main/java/net/jeqo/bloons/listeners/MenuHandlers.java index be9f19f5..0cf97503 100644 --- a/src/main/java/net/jeqo/bloons/listeners/MenuHandlers.java +++ b/src/main/java/net/jeqo/bloons/listeners/MenuHandlers.java @@ -1,27 +1,21 @@ package net.jeqo.bloons.listeners; import net.jeqo.bloons.Bloons; -import net.jeqo.bloons.data.BalloonOwner; import net.jeqo.bloons.data.BalloonMenu; +import net.jeqo.bloons.data.BalloonOwner; import net.jeqo.bloons.utils.Utils; -import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; - -import java.util.Objects; public class MenuHandlers implements Listener { @EventHandler + /** + * When a player interacts with the GUI menu, do the action required accordingly + */ public void onClick(InventoryClickEvent e){ if (!e.getView().getTitle().equals(Utils.hex(Bloons.getString("menu-title")))) return; if(!(e.getWhoClicked() instanceof Player)) return; @@ -40,7 +34,7 @@ public void onClick(InventoryClickEvent e){ if (e.isShiftClick()) { e.setCancelled(true); } else { - Utils.removeBalloon(p, (BalloonOwner) Bloons.playerBalloons.get(p.getUniqueId())); + Utils.removeBalloon(p, Bloons.playerBalloons.get(p.getUniqueId())); Player player = (Player) e.getWhoClicked(); String balloon = e.getCurrentItem().getItemMeta().getLocalizedName(); BalloonOwner.checkBalloonRemovalOrAdd(player, balloon); @@ -88,7 +82,7 @@ public void onClick(InventoryClickEvent e){ if (e.isShiftClick()) { e.setCancelled(true); } else { - BalloonOwner balloonOwner1 = (BalloonOwner) Bloons.playerBalloons.get(player.getUniqueId()); + BalloonOwner balloonOwner1 = Bloons.playerBalloons.get(player.getUniqueId()); if (balloonOwner1 == null) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO, 1, 1); player.sendMessage(Bloons.getMessage("prefix") + Bloons.getMessage("not-equipped")); diff --git a/src/main/java/net/jeqo/bloons/listeners/PlayerHandlers.java b/src/main/java/net/jeqo/bloons/listeners/PlayerHandlers.java index 85583ce6..6307eb7d 100644 --- a/src/main/java/net/jeqo/bloons/listeners/PlayerHandlers.java +++ b/src/main/java/net/jeqo/bloons/listeners/PlayerHandlers.java @@ -1,8 +1,7 @@ package net.jeqo.bloons.listeners; -import jdk.jshell.execution.Util; -import net.jeqo.bloons.data.BalloonOwner; import net.jeqo.bloons.Bloons; +import net.jeqo.bloons.data.BalloonOwner; import net.jeqo.bloons.data.UpdateChecker; import net.jeqo.bloons.utils.Utils; import org.bukkit.entity.Player; @@ -13,20 +12,24 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.plugin.Plugin; import java.util.Objects; public class PlayerHandlers implements Listener { @EventHandler + /** + * When a player quits, make sure to despawn and store their balloon in storage + */ public void onQuit(PlayerQuitEvent e) { - BalloonOwner owner = (BalloonOwner) Bloons.playerBalloons.get(e.getPlayer().getUniqueId()); + BalloonOwner owner = Bloons.playerBalloons.get(e.getPlayer().getUniqueId()); Utils.storeBalloon(e.getPlayer(), owner); } - @EventHandler + /** + * When a player joins, add the balloon back if they left with one, or just don't add anything + */ public void onJoin(PlayerJoinEvent e) { String id = Bloons.playerBalloonID.get(e.getPlayer().getUniqueId()); if (id != null) { @@ -34,7 +37,6 @@ public void onJoin(PlayerJoinEvent e) { BalloonOwner.checkBalloonRemovalOrAdd(e.getPlayer(), id); } - if (e.getPlayer().isOp()) { Player p = e.getPlayer(); new UpdateChecker(Bloons.getInstance(), 106243).getVersion(version -> { @@ -48,14 +50,19 @@ public void onJoin(PlayerJoinEvent e) { } } - @EventHandler + /** + * When they die, remove their balloon + */ public void onDeath(PlayerDeathEvent e) { - BalloonOwner owner = (BalloonOwner) Bloons.playerBalloons.get(Objects.requireNonNull(e.getEntity().getPlayer()).getUniqueId()); + BalloonOwner owner = Bloons.playerBalloons.get(Objects.requireNonNull(e.getEntity().getPlayer()).getUniqueId()); Utils.removeBalloon(e.getEntity().getPlayer(), owner); } @EventHandler + /** + * When they respawn, add the balloon they back that they died with + */ public void onRespawn(PlayerRespawnEvent e) { String id = Bloons.playerBalloonID.get(e.getPlayer().getUniqueId()); if (id != null) { @@ -63,16 +70,17 @@ public void onRespawn(PlayerRespawnEvent e) { } } - @EventHandler + /** + * When they change worlds, store their balloon and move the balloon armor stand over + */ public void onWorldChange(PlayerChangedWorldEvent e) { - BalloonOwner owner = (BalloonOwner) Bloons.playerBalloons.get(e.getPlayer().getUniqueId()); + BalloonOwner owner = Bloons.playerBalloons.get(e.getPlayer().getUniqueId()); Utils.storeBalloon(e.getPlayer(), owner); - String id = Bloons.playerBalloonID.get(e.getPlayer().getUniqueId()); if (id != null) { - Utils.removeBalloon(e.getPlayer(), (BalloonOwner) Bloons.playerBalloons.get(e.getPlayer().getUniqueId())); + Utils.removeBalloon(e.getPlayer(), Bloons.playerBalloons.get(e.getPlayer().getUniqueId())); BalloonOwner.checkBalloonRemovalOrAdd(e.getPlayer(), id); } }