diff --git a/.gitignore b/.gitignore index 145efd6..2f7896d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -# Eclipse -.classpath -.project -.settings/ - -# Intellij -.idea/ -*.iml -*.iws - -# Maven -log/ target/ - -*.gitignore \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9e83735..040ccd6 100644 --- a/pom.xml +++ b/pom.xml @@ -2,11 +2,34 @@ 4.0.0 nl.Steffion BlockHunt - 0.2.1-b${env.BUILD_NUMBER} + 0.2.1-SNAPSHOT BlockHunt - + + ${project.version}-${buildnumber} + + + UTF-8 + + + scm:git:git@github.com:AddstarMC/Blockhunt.git + scm:git:git@github.com:AddstarMC/Blockhunt.git + https://github.com/AddstarMC/Blockhunt + master + + + + maven.addstar.com.au + maven.addstar.com.au-releases + http://maven.addstar.com.au/artifactory/ext-release-local + + + maven.addstar.com.au + maven.addstar.com.au-snapshots + http://maven.addstar.com.au/artifactory/ext-snapshot-local + + - + addstar-repo http://maven.addstar.com.au/artifactory/ext-release-local @@ -25,12 +48,9 @@ - - md5-repo - http://repo.md-5.net/content/groups/public/ - true - true + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public @@ -38,21 +58,25 @@ maven-central http://repo1.maven.org/maven2/ + + + md_5-releases + http://repo.md-5.net/content/repositories/releases/ + - - - org.bukkit - bukkit - 1.9-R0.1-SNAPSHOT + org.spigotmc + spigot + 1.10-R0.1-SNAPSHOT + provided - - me.libraryaddict.disguise + LibsDisguises LibsDisguises - 9.0.2 + 9.0.7 + provided @@ -75,11 +99,16 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 - ISO-8859-1 + 1.8 + 1.8 + UTF-8 + + org.apache.maven.plugins + maven-release-plugin + 2.5.1 + diff --git a/src/nl/Steffion/BlockHunt/Arena.java b/src/nl/Steffion/BlockHunt/Arena.java index 6ce6a83..3491106 100644 --- a/src/nl/Steffion/BlockHunt/Arena.java +++ b/src/nl/Steffion/BlockHunt/Arena.java @@ -98,7 +98,7 @@ public class Arena implements ConfigurationSerializable { hidersTokenWin, seekersTokenWin, killTokens, - blockAnnouncerTime; + blockAnnouncerTime } public enum ArenaState { @@ -106,12 +106,12 @@ public class Arena implements ConfigurationSerializable { STARTING, INGAME, RESTARTING, - DISABLED; + DISABLED } @Override public Map serialize() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("arenaName", arenaName); map.put("pos1", pos1); map.put("pos2", pos2); @@ -147,7 +147,7 @@ public class Arena implements ConfigurationSerializable { (ArrayList) M.g(map, "disguiseBlocks", new ArrayList()),(LocationSerializable) M.g(map, "lobbyWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc), (LocationSerializable) M.g(map, "spawnWarp", loc), (ArrayList) M.g(map, "seekersWinCommands", new ArrayList()), (ArrayList) M.g(map, "hidersWinCommands", new ArrayList()), (ArrayList) M.g(map, "allowedCommands", new ArrayList()), - (Integer) M.g(map, "seekersTokenWin", 10), (Integer) M.g(map, "hidersTokenWin", 50), (Integer) M.g(map, "killTokens", 8), new ArrayList(), - ArenaState.WAITING, 0, new ArrayList(), Bukkit.getScoreboardManager().getNewScoreboard()); + (Integer) M.g(map, "seekersTokenWin", 10), (Integer) M.g(map, "hidersTokenWin", 50), (Integer) M.g(map, "killTokens", 8), new ArrayList<>(), + ArenaState.WAITING, 0, new ArrayList<>(), Bukkit.getScoreboardManager().getNewScoreboard()); } } \ No newline at end of file diff --git a/src/nl/Steffion/BlockHunt/ArenaHandler.java b/src/nl/Steffion/BlockHunt/ArenaHandler.java index 1104451..49f7b26 100644 --- a/src/nl/Steffion/BlockHunt/ArenaHandler.java +++ b/src/nl/Steffion/BlockHunt/ArenaHandler.java @@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; -@SuppressWarnings("deprecation") public class ArenaHandler { public static void loadArenas() { W.arenaList.clear(); @@ -157,7 +156,7 @@ public class ArenaHandler { ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta(); shopBlockChooser_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name))); List lores = W.config.getFile().getStringList(ConfigC.shop_blockChooserv1Description.location); - List lores2 = new ArrayList(); + List lores2 = new ArrayList<>(); for (String lore : lores) { lores2.add(MessageM.replaceAll(lore)); } @@ -175,7 +174,7 @@ public class ArenaHandler { ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta(); shopBlockHuntPass_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name))); List lores = W.config.getFile().getStringList(ConfigC.shop_BlockHuntPassv2Description.location); - List lores2 = new ArrayList(); + List lores2 = new ArrayList<>(); for (String lore : lores) { lores2.add(MessageM.replaceAll(lore)); } @@ -351,8 +350,8 @@ public class ArenaHandler { System.out.println("[BlockHunt] Seekers have won " + arena.arenaName); ArenaHandler.sendFMessage(arena, ConfigC.normal_winSeekers); - List winners = new ArrayList(); - List losers = new ArrayList(); + List winners = new ArrayList<>(); + List losers = new ArrayList<>(); for (Player player : arena.playersInArena) { @@ -401,8 +400,8 @@ public class ArenaHandler { System.out.println("[BlockHunt] Hiders have won " + arena.arenaName); ArenaHandler.sendFMessage(arena, ConfigC.normal_winHiders); - List winners = new ArrayList(); - List losers = new ArrayList(); + List winners = new ArrayList<>(); + List losers = new ArrayList<>(); for (Player player : arena.playersInArena) { diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index 64a663a..b97cb2a 100644 --- a/src/nl/Steffion/BlockHunt/BlockHunt.java +++ b/src/nl/Steffion/BlockHunt/BlockHunt.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import java.util.ArrayList; import java.util.List; @@ -60,17 +70,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class BlockHunt extends JavaPlugin implements Listener { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public static PluginDescriptionFile pdfFile; public static BlockHunt plugin; @@ -186,277 +186,272 @@ public class BlockHunt extends JavaPlugin implements Listener { + BlockHunt.pdfFile.getAuthors().get(0)); // Welcome to the massive game loop!! - getServer().getScheduler().runTaskTimer(this, new Runnable() { - @SuppressWarnings("deprecation") + getServer().getScheduler().runTaskTimer(this, () -> { + for (Arena arena : W.arenaList) { + if (arena.gameState == ArenaState.WAITING) { + if (arena.playersInArena.size() >= arena.minPlayers) { + arena.gameState = ArenaState.STARTING; + arena.timer = arena.timeInLobbyUntilStart; + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-" + arena.timeInLobbyUntilStart); + } + } else if (arena.gameState == ArenaState.STARTING) { + arena.timer = arena.timer - 1; + if (arena.timer > 0) { + if (arena.timer == 60) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-60"); + } else if (arena.timer == 30) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-30"); + } else if (arena.timer == 10) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-10"); + } else if (arena.timer == 5) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-5"); + } else if (arena.timer == 4) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-4"); + } else if (arena.timer == 3) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-3"); + } else if (arena.timer == 2) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-2"); + } else if (arena.timer == 1) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2); + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-1"); + } + } else { + arena.gameState = ArenaState.INGAME; + arena.timer = arena.gameTime; + ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaStarted, "secs-" + arena.waitingTimeSeeker); - @Override - public void run() { - for (Arena arena : W.arenaList) { - if (arena.gameState == ArenaState.WAITING) { - if (arena.playersInArena.size() >= arena.minPlayers) { - arena.gameState = ArenaState.STARTING; - arena.timer = arena.timeInLobbyUntilStart; - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-" + arena.timeInLobbyUntilStart); - } - } else if (arena.gameState == ArenaState.STARTING) { - arena.timer = arena.timer - 1; - if (arena.timer > 0) { - if (arena.timer == 60) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-60"); - } else if (arena.timer == 30) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-30"); - } else if (arena.timer == 10) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-10"); - } else if (arena.timer == 5) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-5"); - } else if (arena.timer == 4) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-4"); - } else if (arena.timer == 3) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-3"); - } else if (arena.timer == 2) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-2"); - } else if (arena.timer == 1) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2); - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaIsStarting, "1-1"); - } - } else { - arena.gameState = ArenaState.INGAME; - arena.timer = arena.gameTime; - ArenaHandler.sendFMessage(arena, ConfigC.normal_lobbyArenaStarted, "secs-" + arena.waitingTimeSeeker); + for (int i = arena.amountSeekersOnStart; i > 0; i = i - 1) { + boolean loop = true; + Player seeker = arena.playersInArena.get(W.random.nextInt(arena.playersInArena.size())); - for (int i = arena.amountSeekersOnStart; i > 0; i = i - 1) { - boolean loop = true; - Player seeker = arena.playersInArena.get(W.random.nextInt(arena.playersInArena.size())); + for (Player playerCheck : arena.playersInArena) { + if (W.choosenSeeker.get(playerCheck) != null) { + if (W.choosenSeeker.get(playerCheck)) { + seeker = playerCheck; + W.choosenSeeker.remove(playerCheck); + } else { + if (seeker.equals(playerCheck)) { + i = i + 1; + loop = false; + } + } + } + } - for (Player playerCheck : arena.playersInArena) { - if (W.choosenSeeker.get(playerCheck) != null) { - if (W.choosenSeeker.get(playerCheck) == true) { - seeker = playerCheck; - W.choosenSeeker.remove(playerCheck); - } else { - if (seeker.equals(playerCheck)) { - i = i + 1; - loop = false; - } - } - } - } + if (loop) { + if (!arena.seekers.contains(seeker)) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName()); + arena.seekers.add(seeker); + seeker.teleport(arena.seekersWarp); + seeker.getInventory().clear(); + seeker.updateInventory(); + W.seekertime.put(seeker, arena.waitingTimeSeeker); + } else { + i = i + 1; + } + } + } - if (loop) { - if (!arena.seekers.contains(seeker)) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName()); - arena.seekers.add(seeker); - seeker.teleport(arena.seekersWarp); - seeker.getInventory().clear(); - seeker.updateInventory(); - W.seekertime.put(seeker, arena.waitingTimeSeeker); - } else { - i = i + 1; - } - } - } + for (Player arenaPlayer : arena.playersInArena) { + if (!arena.seekers.contains(arenaPlayer)) { + arenaPlayer.getInventory().clear(); + arenaPlayer.updateInventory(); + ItemStack block = arena.disguiseBlocks.get(W.random.nextInt(arena.disguiseBlocks.size())); - for (Player arenaPlayer : arena.playersInArena) { - if (!arena.seekers.contains(arenaPlayer)) { - arenaPlayer.getInventory().clear(); - arenaPlayer.updateInventory(); - ItemStack block = arena.disguiseBlocks.get(W.random.nextInt(arena.disguiseBlocks.size())); + if (W.choosenBlock.get(arenaPlayer) != null) { + block = W.choosenBlock.get(arenaPlayer); + W.choosenBlock.remove(arenaPlayer); + } - if (W.choosenBlock.get(arenaPlayer) != null) { - block = W.choosenBlock.get(arenaPlayer); - W.choosenBlock.remove(arenaPlayer); - } + MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getTypeId(), block.getDurability()); + DisguiseAPI.disguiseToAll(arenaPlayer, disguise); - MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getTypeId(), block.getDurability()); - DisguiseAPI.disguiseToAll(arenaPlayer, disguise); + arenaPlayer.teleport(arena.hidersWarp); - arenaPlayer.teleport(arena.hidersWarp); + ItemStack blockCount = new ItemStack(block.getType(), 5); + blockCount.setDurability(block.getDurability()); + arenaPlayer.getInventory().setItem(8, blockCount); + arenaPlayer.getInventory().setHelmet(new ItemStack(block)); + W.pBlock.put(arenaPlayer, block); - ItemStack blockCount = new ItemStack(block.getType(), 5); - blockCount.setDurability(block.getDurability()); - arenaPlayer.getInventory().setItem(8, blockCount); - arenaPlayer.getInventory().setHelmet(new ItemStack(block)); - W.pBlock.put(arenaPlayer, block); + if (block.getDurability() != 0) { + MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock, + "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" + block.getDurability()); + } else { + MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock, + "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase()); + } + } + } + } + } - if (block.getDurability() != 0) { - MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock, - "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" + block.getDurability()); - } else { - MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock, - "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase()); - } - } - } - } - } + for (Player player : arena.seekers) { + if (player.getInventory().getItem(0) == null || player.getInventory().getItem(0).getType() != Material.DIAMOND_SWORD) { + player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD, 1)); + player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1)); + player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1)); + player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1)); + player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1)); + ItemStack infBow = new ItemStack(Material.BOW, 1); + infBow.addEnchantment(Enchantment.ARROW_INFINITE, 1); + player.getInventory().setItem(1, infBow); + player.getInventory().setItem(2, new ItemStack(Material.ARROW, 1)); + player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 1); + } - for (Player player : arena.seekers) { - if (player.getInventory().getItem(0) == null || player.getInventory().getItem(0).getType() != Material.DIAMOND_SWORD) { - player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD, 1)); - player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET, 1)); - player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1)); - player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1)); - player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1)); - ItemStack infBow = new ItemStack(Material.BOW, 1); - infBow.addEnchantment(Enchantment.ARROW_INFINITE, 1); - player.getInventory().setItem(1, infBow); - player.getInventory().setItem(2, new ItemStack(Material.ARROW, 1)); - player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 1); - } + if (W.seekertime.get(player) != null) { + W.seekertime.put(player, W.seekertime.get(player) - 1); + if (W.seekertime.get(player) <= 0) { + player.teleport(arena.hidersWarp); + W.seekertime.remove(player); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerSpawned, "playername-" + player.getName()); + } + } + } - if (W.seekertime.get(player) != null) { - W.seekertime.put(player, W.seekertime.get(player) - 1); - if (W.seekertime.get(player) <= 0) { - player.teleport(arena.hidersWarp); - W.seekertime.remove(player); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerSpawned, "playername-" + player.getName()); - } - } - } + if (arena.gameState == ArenaState.INGAME) { + arena.timer = arena.timer - 1; + if (arena.timer > 0) { + if (arena.timer == arena.gameTime - arena.timeUntilHidersSword) { + ItemStack sword = new ItemStack(Material.WOOD_SWORD, 1); + sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + for (Player arenaPlayer : arena.playersInArena) { + if (!arena.seekers.contains(arenaPlayer)) { + arenaPlayer.getInventory().addItem(sword); + MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameGivenSword); + } + } + } - if (arena.gameState == ArenaState.INGAME) { - arena.timer = arena.timer - 1; - if (arena.timer > 0) { - if (arena.timer == arena.gameTime - arena.timeUntilHidersSword) { - ItemStack sword = new ItemStack(Material.WOOD_SWORD, 1); - sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); - for (Player arenaPlayer : arena.playersInArena) { - if (!arena.seekers.contains(arenaPlayer)) { - arenaPlayer.getInventory().addItem(sword); - MessageM.sendFMessage(arenaPlayer, ConfigC.normal_ingameGivenSword); - } - } - } + // blockAnnouncer code. + if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) { + ArrayList remainingBlocks = new ArrayList(); + for (Player arenaPlayer : arena.playersInArena) { + if (!arena.seekers.contains(arenaPlayer)) { + String block = arenaPlayer.getInventory().getItem(8).getType().name(); + block = WordUtils.capitalizeFully(block.replace("_", " ")); + if (!remainingBlocks.contains(block)) { //Don't print double up block names. + remainingBlocks.add(block); + } + } + } + String blocklist = StringUtils.join(remainingBlocks, ", "); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + blocklist); + } - // blockAnnouncer code. - if ((arena.blockAnnouncerTime > 0) && (arena.timer == arena.blockAnnouncerTime)) { - ArrayList remainingBlocks = new ArrayList(); - for (Player arenaPlayer : arena.playersInArena) { - if (!arena.seekers.contains(arenaPlayer)) { - String block = arenaPlayer.getInventory().getItem(8).getType().name(); - block = WordUtils.capitalizeFully(block.replace("_", " ")); - if (!remainingBlocks.contains(block)) { //Don't print double up block names. - remainingBlocks.add(block); - } - } - } - String blocklist = StringUtils.join(remainingBlocks, ", "); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameBlocksLeft, "1-" + blocklist); - } + if (arena.timer == 190) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-190"); + } else if (arena.timer == 60) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-60"); + } else if (arena.timer == 30) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-30"); + } else if (arena.timer == 10) { + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-10"); + } else if (arena.timer == 5) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-5"); + } else if (arena.timer == 4) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-4"); + } else if (arena.timer == 3) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-3"); + } else if (arena.timer == 2) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-2"); + } else if (arena.timer == 1) { + arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2); + ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-1"); + } + } else { + ArenaHandler.hidersWin(arena); + return; + } - if (arena.timer == 190) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-190"); - } else if (arena.timer == 60) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-60"); - } else if (arena.timer == 30) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-30"); - } else if (arena.timer == 10) { - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-10"); - } else if (arena.timer == 5) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-5"); - } else if (arena.timer == 4) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 0); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-4"); - } else if (arena.timer == 3) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-3"); - } else if (arena.timer == 2) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-2"); - } else if (arena.timer == 1) { - arena.lobbyWarp.getWorld().playSound(arena.lobbyWarp, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2); - ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameArenaEnd, "1-1"); - } - } else { - ArenaHandler.hidersWin(arena); - return; - } + for (Player player : arena.playersInArena) { + if (!arena.seekers.contains(player)) { + Location pLoc = player.getLocation(); + Location moveLoc = W.moveLoc.get(player); + ItemStack block = player.getInventory().getItem(8); - for (Player player : arena.playersInArena) { - if (!arena.seekers.contains(player)) { - Location pLoc = player.getLocation(); - Location moveLoc = W.moveLoc.get(player); - ItemStack block = player.getInventory().getItem(8); + if (block == null) { + if (W.pBlock.get(player) != null) { + block = W.pBlock.get(player); + player.getInventory().setItem(8, block); + player.updateInventory(); + } + } - if (block == null) { - if (W.pBlock.get(player) != null) { - block = W.pBlock.get(player); - player.getInventory().setItem(8, block); - player.updateInventory(); - } - } + if (moveLoc != null) { + if (moveLoc.getX() == pLoc.getX() && moveLoc.getY() == pLoc.getY() && moveLoc.getZ() == pLoc.getZ()) { + if (block.getAmount() > 1) { + block.setAmount(block.getAmount() - 1); + } else { + Block pBlock = player.getLocation().getBlock(); + if (pBlock.getType().equals(Material.AIR) || pBlock.getType().equals(Material.WATER) + || pBlock.getType().equals(Material.STATIONARY_WATER)) { + if (pBlock.getType().equals(Material.WATER) || pBlock.getType().equals(Material.STATIONARY_WATER)) { + W.hiddenLocWater.put(player, true); + } else { + W.hiddenLocWater.put(player, false); + } + if (DisguiseAPI.isDisguised(player)) { + DisguiseAPI.undisguiseToAll(player); + for (Player pl : Bukkit.getOnlinePlayers()) { + if (!pl.equals(player)) { + pl.hidePlayer(player); + pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability()); + } + } - if (moveLoc != null) { - if (moveLoc.getX() == pLoc.getX() && moveLoc.getY() == pLoc.getY() && moveLoc.getZ() == pLoc.getZ()) { - if (block.getAmount() > 1) { - block.setAmount(block.getAmount() - 1); - } else { - Block pBlock = player.getLocation().getBlock(); - if (pBlock.getType().equals(Material.AIR) || pBlock.getType().equals(Material.WATER) - || pBlock.getType().equals(Material.STATIONARY_WATER)) { - if (pBlock.getType().equals(Material.WATER) || pBlock.getType().equals(Material.STATIONARY_WATER)) { - W.hiddenLocWater.put(player, true); - } else { - W.hiddenLocWater.put(player, false); - } - if (DisguiseAPI.isDisguised(player)) { - DisguiseAPI.undisguiseToAll(player); - for (Player pl : Bukkit.getOnlinePlayers()) { - if (!pl.equals(player)) { - pl.hidePlayer(player); - pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability()); - } - } + block.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + player.playSound(pLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + W.hiddenLoc.put(player, moveLoc); + if (block.getDurability() != 0) { + MessageM.sendFMessage( + player, + ConfigC.normal_ingameNowSolid, + "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" + + block.getDurability()); + } else { + MessageM.sendFMessage(player, ConfigC.normal_ingameNowSolid, "block-" + + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase()); + } + } + for (Player pl : Bukkit.getOnlinePlayers()) { + if (!pl.equals(player)) { + pl.hidePlayer(player); + pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability()); + } + } + } else { + MessageM.sendFMessage(player, ConfigC.warning_ingameNoSolidPlace); + } + } + } else { + block.setAmount(5); + if (!DisguiseAPI.isDisguised(player)) { + SolidBlockHandler.makePlayerUnsolid(player); + } + } + } + } + } + ScoreboardHandler.updateScoreboard(arena); // TODO Only do this when needed (player added/removed) + } - block.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - player.playSound(pLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); - W.hiddenLoc.put(player, moveLoc); - if (block.getDurability() != 0) { - MessageM.sendFMessage( - player, - ConfigC.normal_ingameNowSolid, - "block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" - + block.getDurability()); - } else { - MessageM.sendFMessage(player, ConfigC.normal_ingameNowSolid, "block-" - + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase()); - } - } - for (Player pl : Bukkit.getOnlinePlayers()) { - if (!pl.equals(player)) { - pl.hidePlayer(player); - pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability()); - } - } - } else { - MessageM.sendFMessage(player, ConfigC.warning_ingameNoSolidPlace); - } - } - } else { - block.setAmount(5); - if (!DisguiseAPI.isDisguised(player)) { - SolidBlockHandler.makePlayerUnsolid(player); - } - } - } - } - } - ScoreboardHandler.updateScoreboard(arena); // TODO Only do this when needed (player added/removed) - } - - for (Player pl : arena.playersInArena) { - pl.setLevel(arena.timer); - pl.setGameMode(GameMode.SURVIVAL); - } - } - SignsHandler.updateSigns(); //TODO Only do this when needed (gamestate change or player count change) - } - }, 0, 20); + for (Player pl : arena.playersInArena) { + pl.setLevel(arena.timer); + pl.setGameMode(GameMode.SURVIVAL); + } + } + SignsHandler.updateSigns(); //TODO Only do this when needed (gamestate change or player count change) + }, 0, 20); } public void onDisable() { @@ -509,11 +504,7 @@ public class BlockHunt extends JavaPlugin implements Listener { boolean equals = true; if (argsSplit == null) { - if (args.length == 0) { - equals = true; - } else { - equals = false; - } + equals = args.length == 0; } else { if (args.length >= argsSplit.length) { for (int i2 = argsSplit.length - 1; i2 >= 0; i2 = i2 - 1) { diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDcreate.java b/src/nl/Steffion/BlockHunt/Commands/CMDcreate.java index 0393fc6..4fff8c8 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDcreate.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDcreate.java @@ -25,9 +25,9 @@ public class CMDcreate extends DefaultCMD { } else { if (W.pos1.get(player) != null && W.pos2.get(player) != null) { if (W.pos1.get(player).getWorld().equals(W.pos2.get(player).getWorld())) { - Arena arena = new Arena(args[1], W.pos1.get(player), W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, 45, false, false, false, false, false, new ArrayList(), null, null, null, - null, new ArrayList(), new ArrayList(), new ArrayList(), 10, 50, 8, new ArrayList(), ArenaState.WAITING, - 0, new ArrayList(), Bukkit.getScoreboardManager().getNewScoreboard()); + Arena arena = new Arena(args[1], W.pos1.get(player), W.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, 45, false, false, false, false, false, new ArrayList<>(), null, null, null, + null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), 10, 50, 8, new ArrayList<>(), ArenaState.WAITING, + 0, new ArrayList<>(), Bukkit.getScoreboardManager().getNewScoreboard()); W.arenas.getFile().set(args[1], arena); W.arenas.save(); W.signs.load(); diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDhelp.java b/src/nl/Steffion/BlockHunt/Commands/CMDhelp.java index dbfecbe..6a0c2c7 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDhelp.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDhelp.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.ConfigC; import nl.Steffion.BlockHunt.BlockHunt; import nl.Steffion.BlockHunt.W; @@ -11,17 +21,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; public class CMDhelp extends DefaultCMD { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + @Override public boolean exectue(Player player, Command cmd, String label, String[] args) { diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDinfo.java b/src/nl/Steffion/BlockHunt/Commands/CMDinfo.java index 5bcf2e3..a70d765 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDinfo.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDinfo.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.BlockHunt; import nl.Steffion.BlockHunt.ConfigC; import nl.Steffion.BlockHunt.Managers.MessageM; @@ -8,17 +18,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; public class CMDinfo extends DefaultCMD { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + @Override public boolean exectue(Player player, Command cmd, String label, String[] args) { diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDnotfound.java b/src/nl/Steffion/BlockHunt/Commands/CMDnotfound.java index 8d3a0c4..f074389 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDnotfound.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDnotfound.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.ConfigC; import nl.Steffion.BlockHunt.Managers.MessageM; @@ -7,17 +17,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; public class CMDnotfound { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public static boolean exectue(Player player, Command cmd, String label, String[] args) { MessageM.sendFMessage(player, ConfigC.error_commandNotFound); diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDreload.java b/src/nl/Steffion/BlockHunt/Commands/CMDreload.java index c557ff1..b9360c2 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDreload.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDreload.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.Arena; import nl.Steffion.BlockHunt.ArenaHandler; import nl.Steffion.BlockHunt.ConfigC; @@ -11,17 +21,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; public class CMDreload extends DefaultCMD { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + @Override public boolean exectue(Player player, Command cmd, String label, String[] args) { diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDremove.java b/src/nl/Steffion/BlockHunt/Commands/CMDremove.java index 51062f2..973930b 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDremove.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDremove.java @@ -39,7 +39,7 @@ public class CMDremove extends DefaultCMD { W.arenas.save(); W.signs.load(); - W.arenaList.remove((Arena) arena); + W.arenaList.remove(arena); return true; } } diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDtokens.java b/src/nl/Steffion/BlockHunt/Commands/CMDtokens.java index b8a85ca..41b387b 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDtokens.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDtokens.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.BlockHunt; import nl.Steffion.BlockHunt.ConfigC; import nl.Steffion.BlockHunt.W; @@ -10,17 +20,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; public class CMDtokens extends DefaultCMD { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + @Override public boolean exectue(Player player, Command cmd, String label, String[] args) { diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDwand.java b/src/nl/Steffion/BlockHunt/Commands/CMDwand.java index 3610b2e..206385d 100644 --- a/src/nl/Steffion/BlockHunt/Commands/CMDwand.java +++ b/src/nl/Steffion/BlockHunt/Commands/CMDwand.java @@ -24,7 +24,7 @@ public class CMDwand extends DefaultCMD { im.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.wandName))); W.config.load(); List lores = W.config.getFile().getStringList(ConfigC.wandDescription.location); - List lores2 = new ArrayList(); + List lores2 = new ArrayList<>(); for (String lore : lores) { lores2.add(MessageM.replaceAll(lore)); } diff --git a/src/nl/Steffion/BlockHunt/Commands/DefaultCMD.java b/src/nl/Steffion/BlockHunt/Commands/DefaultCMD.java index f82a549..30f7ca0 100644 --- a/src/nl/Steffion/BlockHunt/Commands/DefaultCMD.java +++ b/src/nl/Steffion/BlockHunt/Commands/DefaultCMD.java @@ -1,22 +1,22 @@ package nl.Steffion.BlockHunt.Commands; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.Managers.MessageM; import org.bukkit.command.Command; import org.bukkit.entity.Player; public class DefaultCMD { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public boolean exectue(Player player, Command cmd, String label, String[] args) { MessageM.sendMessage(player, "%TAG%NExample of a Command!"); diff --git a/src/nl/Steffion/BlockHunt/ConfigC.java b/src/nl/Steffion/BlockHunt/ConfigC.java index 470561c..7ae9ea1 100644 --- a/src/nl/Steffion/BlockHunt/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/ConfigC.java @@ -1,19 +1,19 @@ package nl.Steffion.BlockHunt; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import nl.Steffion.BlockHunt.Managers.ConfigM; public enum ConfigC { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + chat_tag("[" + BlockHunt.pdfFile.getName() + "] ", W.config), chat_normal("&b", W.config), chat_warning("&c", W.config), chat_error("&c", W.config), chat_arg("&e", W.config), chat_header("&9", W.config), chat_headerhigh("%H_______.[ %A%header%%H ]._______", W.config), @@ -117,7 +117,7 @@ public enum ConfigC { * @param config * The config file. */ - private ConfigC(Object value, ConfigM config) { + ConfigC(Object value, ConfigM config) { this.value = value; this.config = config; this.location = this.name().replaceAll("_", "."); diff --git a/src/nl/Steffion/BlockHunt/InventoryHandler.java b/src/nl/Steffion/BlockHunt/InventoryHandler.java index 85a1052..f27d87a 100644 --- a/src/nl/Steffion/BlockHunt/InventoryHandler.java +++ b/src/nl/Steffion/BlockHunt/InventoryHandler.java @@ -189,7 +189,7 @@ public class InventoryHandler { ItemStack arenaNameNote = new ItemStack(Material.PAPER, 1); ItemMeta arenaNameNote_IM = arenaNameNote.getItemMeta(); arenaNameNote_IM.setDisplayName(MessageM.replaceAll("%NDisguiseBlocks of arena: %A" + arenaname)); - ArrayList lores = new ArrayList(); + ArrayList lores = new ArrayList<>(); lores.add(MessageM.replaceAll("%NPlace the DisguiseBlocks inside this inventory.")); arenaNameNote_IM.setLore(lores); arenaNameNote.setItemMeta(arenaNameNote_IM); @@ -209,8 +209,8 @@ public class InventoryHandler { W.shop.save(); } int playerTokens = W.shop.getFile().getInt(player.getName() + ".tokens"); - List lores = new ArrayList(); - List lores2 = new ArrayList(); + List lores = new ArrayList<>(); + List lores2 = new ArrayList<>(); ItemStack shopTokens = new ItemStack(Material.EMERALD, 1); ItemMeta shopTokens_IM = shopTokens.getItemMeta(); @@ -221,7 +221,7 @@ public class InventoryHandler { ItemMeta shopBlockChooser_IM = shopBlockChooser.getItemMeta(); shopBlockChooser_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name))); lores = W.config.getFile().getStringList(ConfigC.shop_blockChooserv1Description.location); - lores2 = new ArrayList(); + lores2 = new ArrayList<>(); for (String lore : lores) { lores2.add(MessageM.replaceAll(lore)); } @@ -235,7 +235,7 @@ public class InventoryHandler { ItemMeta shopBlockHuntPass_IM = shopBlockHuntPass.getItemMeta(); shopBlockHuntPass_IM.setDisplayName(MessageM.replaceAll((String) W.config.get(ConfigC.shop_BlockHuntPassv2Name))); lores = W.config.getFile().getStringList(ConfigC.shop_BlockHuntPassv2Description.location); - lores2 = new ArrayList(); + lores2 = new ArrayList<>(); for (String lore : lores) { lores2.add(MessageM.replaceAll(lore)); } @@ -246,11 +246,11 @@ public class InventoryHandler { shopBlockHuntPass.setItemMeta(shopBlockHuntPass_IM); shop.setItem(0, shopTokens); - if ((Boolean) W.config.get(ConfigC.shop_blockChooserv1Enabled) == true - && ((Boolean) W.shop.getFile().get(player.getName() + ".blockchooser") == null && !PermissionsM.hasPerm(player, Permissions.shopblockchooser, false))) { + if ((Boolean) W.config.get(ConfigC.shop_blockChooserv1Enabled) + && (W.shop.getFile().get(player.getName() + ".blockchooser") == null && !PermissionsM.hasPerm(player, Permissions.shopblockchooser, false))) { shop.setItem(1, shopBlockChooser); } - if ((Boolean) W.config.get(ConfigC.shop_BlockHuntPassv2Enabled) == true) { + if ((Boolean) W.config.get(ConfigC.shop_BlockHuntPassv2Enabled)) { shop.setItem(2, shopBlockHuntPass); } player.openInventory(shop); diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageByEntityEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageByEntityEvent.java index f056675..1ec52ee 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageByEntityEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageByEntityEvent.java @@ -125,7 +125,7 @@ public class OnEntityDamageByEntityEvent implements Listener { int hidercount = (arena.playersInArena.size() - arena.seekers.size()); if ((hidercount <= 3) && (hidercount > 0)) { - List hiders = new ArrayList(); + List hiders = new ArrayList<>(); for (Player p : arena.playersInArena) { if (!arena.seekers.contains(p)) { hiders.add(p.getName()); diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java index 7f1a042..4be9ef6 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java @@ -54,7 +54,7 @@ public class OnInventoryClickEvent implements Listener { return; if (inv.getName().startsWith("\u00A7r")) { - if (inv.getName().equals(MessageM.replaceAll((String) "\u00A7r" + W.config.get(ConfigC.shop_title)))) { + if (inv.getName().equals(MessageM.replaceAll("\u00A7r" + W.config.get(ConfigC.shop_title)))) { event.setCancelled(true); ItemStack item = event.getCurrentItem(); if (W.shop.getFile().get(player.getName() + ".tokens") == null) { @@ -114,7 +114,7 @@ public class OnInventoryClickEvent implements Listener { if (arena.playersInArena.contains(player)) { for (Player playerCheck : arena.playersInArena) { if (W.choosenSeeker.get(playerCheck) != null) { - if (W.choosenSeeker.get(playerCheck) == true) { + if (W.choosenSeeker.get(playerCheck)) { i = i + 1; } } @@ -145,7 +145,7 @@ public class OnInventoryClickEvent implements Listener { if (arena.playersInArena.contains(player)) { for (Player playerCheck : arena.playersInArena) { if (W.choosenSeeker.get(playerCheck) != null) { - if (W.choosenSeeker.get(playerCheck) == false) { + if (!W.choosenSeeker.get(playerCheck)) { i = i + 1; } } diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryCloseEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryCloseEvent.java index 38208df..ddb5b29 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryCloseEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryCloseEvent.java @@ -32,7 +32,7 @@ public class OnInventoryCloseEvent implements Listener { } } - ArrayList blocks = new ArrayList(); + ArrayList blocks = new ArrayList<>(); for (ItemStack item : inv.getContents()) { if (item != null) { if (!item.getType().equals(Material.PAPER)) { diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnPlayerInteractEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnPlayerInteractEvent.java index 1615397..85a6bc4 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnPlayerInteractEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnPlayerInteractEvent.java @@ -36,7 +36,7 @@ public class OnPlayerInteractEvent implements Listener { Player player = event.getPlayer(); Block block = event.getClickedBlock(); if (PermissionsM.hasPerm(player, Permissions.create, false)) { - ItemStack item = player.getItemInHand(); + ItemStack item = player.getInventory().getItemInMainHand(); if (item.getType() != Material.AIR) { if (item.getItemMeta().hasDisplayName()) { ItemMeta im = item.getItemMeta(); @@ -132,7 +132,7 @@ public class OnPlayerInteractEvent implements Listener { for (Arena arena : W.arenaList) { if (arena.playersInArena.contains(player) && (arena.gameState.equals(ArenaState.WAITING) || arena.gameState.equals(ArenaState.STARTING))) { event.setCancelled(true); - ItemStack item = player.getInventory().getItemInHand(); + ItemStack item = player.getInventory().getItemInMainHand(); if (item.getType() != Material.AIR) { if (item.getItemMeta().getDisplayName() != null) { if (item.getItemMeta().getDisplayName().equals(MessageM.replaceAll((String) W.config.get(ConfigC.shop_blockChooserv1Name)))) { diff --git a/src/nl/Steffion/BlockHunt/Managers/CommandM.java b/src/nl/Steffion/BlockHunt/Managers/CommandM.java index 7aeefcd..ed6636f 100644 --- a/src/nl/Steffion/BlockHunt/Managers/CommandM.java +++ b/src/nl/Steffion/BlockHunt/Managers/CommandM.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Managers; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import java.util.List; import nl.Steffion.BlockHunt.ConfigC; @@ -8,17 +18,7 @@ import nl.Steffion.BlockHunt.W; import nl.Steffion.BlockHunt.Commands.DefaultCMD; public class CommandM { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public String name; public String label; diff --git a/src/nl/Steffion/BlockHunt/Managers/ConfigM.java b/src/nl/Steffion/BlockHunt/Managers/ConfigM.java index 423355e..9a25a22 100644 --- a/src/nl/Steffion/BlockHunt/Managers/ConfigM.java +++ b/src/nl/Steffion/BlockHunt/Managers/ConfigM.java @@ -1,5 +1,15 @@ package nl.Steffion.BlockHunt.Managers; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ import java.io.File; import nl.Steffion.BlockHunt.BlockHunt; @@ -11,17 +21,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; public class ConfigM { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + String fileName; File file; @@ -145,7 +145,7 @@ public class ConfigM { * * @param location * Config location. - * @return + * @return Object */ public Object get(ConfigC location) { return this.getFile().get(location.location); diff --git a/src/nl/Steffion/BlockHunt/Managers/EngineInfo.java b/src/nl/Steffion/BlockHunt/Managers/EngineInfo.java index a684a61..8f8cb0d 100644 --- a/src/nl/Steffion/BlockHunt/Managers/EngineInfo.java +++ b/src/nl/Steffion/BlockHunt/Managers/EngineInfo.java @@ -1,17 +1,17 @@ package nl.Steffion.BlockHunt.Managers; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ public class EngineInfo { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public static String engineVersion = "3.0.2"; public static String engineAuthors = "Steffion"; diff --git a/src/nl/Steffion/BlockHunt/Managers/FileM.java b/src/nl/Steffion/BlockHunt/Managers/FileM.java index 3ef862a..22244bc 100644 --- a/src/nl/Steffion/BlockHunt/Managers/FileM.java +++ b/src/nl/Steffion/BlockHunt/Managers/FileM.java @@ -9,7 +9,7 @@ import java.io.OutputStream; public class FileM { /* - * Made by @author Steffion, © 2013. + * Made by @author Steffion, 2013. */ public static void copyFolder(File src, File dest) throws IOException { diff --git a/src/nl/Steffion/BlockHunt/Managers/MessageM.java b/src/nl/Steffion/BlockHunt/Managers/MessageM.java index 2645e0f..26060f0 100644 --- a/src/nl/Steffion/BlockHunt/Managers/MessageM.java +++ b/src/nl/Steffion/BlockHunt/Managers/MessageM.java @@ -110,7 +110,7 @@ public class MessageM { * @param vars * Variables. Seperated with a - . Ex: "playerName-" + * player.getName(); - * @return + * @return String with the message with values replaced */ public static String replaceAll(String message, String... vars) { return MessageM.replaceColours(MessageM.replaceColourVars(MessageM.replaceVars(message, vars))); @@ -185,7 +185,7 @@ public class MessageM { } public static String TAG() { - return (String) W.config.get(ConfigC.chat_header) + (String) W.config.get(ConfigC.chat_tag) + (String) W.config.get(ConfigC.chat_normal); + return W.config.get(ConfigC.chat_header) + W.config.get(ConfigC.chat_tag) + W.config.get(ConfigC.chat_normal); } } } diff --git a/src/nl/Steffion/BlockHunt/PermissionsC.java b/src/nl/Steffion/BlockHunt/PermissionsC.java index f51708f..e16b7c3 100644 --- a/src/nl/Steffion/BlockHunt/PermissionsC.java +++ b/src/nl/Steffion/BlockHunt/PermissionsC.java @@ -1,22 +1,22 @@ package nl.Steffion.BlockHunt; - +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ public class PermissionsC { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ + public static String main = BlockHunt.pdfFile.getName().toLowerCase() + "."; public enum PType { - ALL, PLAYER, MODERATOR, ADMIN, OP; + ALL, PLAYER, MODERATOR, ADMIN, OP } public enum Permissions { @@ -28,7 +28,7 @@ public class PermissionsC { public String perm; public PType type; - private Permissions(String perm, PType type) { + Permissions(String perm, PType type) { this.perm = perm; this.type = type; } diff --git a/src/nl/Steffion/BlockHunt/ScoreboardHandler.java b/src/nl/Steffion/BlockHunt/ScoreboardHandler.java index 6fc76f1..20f63b2 100644 --- a/src/nl/Steffion/BlockHunt/ScoreboardHandler.java +++ b/src/nl/Steffion/BlockHunt/ScoreboardHandler.java @@ -12,7 +12,7 @@ import org.bukkit.scoreboard.Scoreboard; public class ScoreboardHandler { public static void createScoreboard(Arena arena) { - if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) { + if ((Boolean) W.config.get(ConfigC.scoreboard_enabled)) { Scoreboard board = arena.scoreboard; if (board.getObjective(arena.arenaName) != null) { updateScoreboard(arena); @@ -49,7 +49,7 @@ public class ScoreboardHandler { } public static void updateScoreboard(Arena arena) { - if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) { + if ((Boolean) W.config.get(ConfigC.scoreboard_enabled)) { Scoreboard board = arena.scoreboard; Objective object = board.getObjective(DisplaySlot.SIDEBAR); object.setDisplayName(BlockHunt.cutString(MessageM.replaceAll((String) W.config.get(ConfigC.scoreboard_title)), 32)); diff --git a/src/nl/Steffion/BlockHunt/Serializables/LocationSerializable.java b/src/nl/Steffion/BlockHunt/Serializables/LocationSerializable.java index ed15d21..d577688 100644 --- a/src/nl/Steffion/BlockHunt/Serializables/LocationSerializable.java +++ b/src/nl/Steffion/BlockHunt/Serializables/LocationSerializable.java @@ -33,7 +33,7 @@ public class LocationSerializable extends Location implements ConfigurationSeria @Override public Map serialize() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("w", getWorld().getName()); map.put("x", getX()); map.put("y", getY()); diff --git a/src/nl/Steffion/BlockHunt/SignsHandler.java b/src/nl/Steffion/BlockHunt/SignsHandler.java index ab65ae1..6ee42aa 100644 --- a/src/nl/Steffion/BlockHunt/SignsHandler.java +++ b/src/nl/Steffion/BlockHunt/SignsHandler.java @@ -88,7 +88,6 @@ public class SignsHandler { return false; } - @SuppressWarnings("unchecked") public static void updateSigns() { W.signs.load(); for (String sign : W.signs.getFile().getKeys(false)) { diff --git a/src/nl/Steffion/BlockHunt/SolidBlockHandler.java b/src/nl/Steffion/BlockHunt/SolidBlockHandler.java index 278a94f..2a0f7b3 100644 --- a/src/nl/Steffion/BlockHunt/SolidBlockHandler.java +++ b/src/nl/Steffion/BlockHunt/SolidBlockHandler.java @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class SolidBlockHandler { - @SuppressWarnings("deprecation") + public static void makePlayerUnsolid(Player player) { ItemStack block = player.getInventory().getItem(8); if (block == null) { diff --git a/src/nl/Steffion/BlockHunt/W.java b/src/nl/Steffion/BlockHunt/W.java index 2b97df3..35d8d41 100644 --- a/src/nl/Steffion/BlockHunt/W.java +++ b/src/nl/Steffion/BlockHunt/W.java @@ -1,5 +1,17 @@ package nl.Steffion.BlockHunt; +/** + * Steffion's Engine - Made by Steffion. + * + * You're allowed to use this engine for own usage, you're not allowed to + * republish the engine. Using this for your own plugin is allowed when a + * credit is placed somewhere in the plugin. + * + * Thanks for your cooperate! + * + * @author Steffion + */ + import java.util.ArrayList; import java.util.HashMap; import java.util.Random; @@ -13,23 +25,12 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class W { - /** - * Steffion's Engine - Made by Steffion. - * - * You're allowed to use this engine for own usage, you're not allowed to - * republish the engine. Using this for your own plugin is allowed when a - * credit is placed somewhere in the plugin. - * - * Thanks for your cooperate! - * - * @author Steffion - */ /* * Standard stuff. */ - public static ArrayList newFiles = new ArrayList(); - public static ArrayList commands = new ArrayList(); + public static ArrayList newFiles = new ArrayList<>(); + public static ArrayList commands = new ArrayList<>(); /* * If you want another file to be created. Copy and paste this line. @@ -44,19 +45,19 @@ public class W { * Add any variable you need in different classes here: */ - public static HashMap pos1 = new HashMap(); - public static HashMap pos2 = new HashMap(); + public static HashMap pos1 = new HashMap<>(); + public static HashMap pos2 = new HashMap<>(); - public static ArrayList arenaList = new ArrayList(); + public static ArrayList arenaList = new ArrayList<>(); public static Random random = new Random(); - public static HashMap seekertime = new HashMap(); + public static HashMap seekertime = new HashMap<>(); - public static HashMap pData = new HashMap(); - public static HashMap choosenBlock = new HashMap(); - public static HashMap choosenSeeker = new HashMap(); + public static HashMap pData = new HashMap<>(); + public static HashMap choosenBlock = new HashMap<>(); + public static HashMap choosenSeeker = new HashMap<>(); - public static HashMap pBlock = new HashMap(); - public static HashMap moveLoc = new HashMap(); - public static HashMap hiddenLoc = new HashMap(); - public static HashMap hiddenLocWater = new HashMap(); + public static HashMap pBlock = new HashMap<>(); + public static HashMap moveLoc = new HashMap<>(); + public static HashMap hiddenLoc = new HashMap<>(); + public static HashMap hiddenLocWater = new HashMap<>(); } diff --git a/src/plugin.yml b/src/plugin.yml index 54eb2cf..49d8103 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: BlockHunt main: nl.Steffion.BlockHunt.BlockHunt -version: ${project.version} +version: ${pluginversion} authors: - Steffion description: An easy to set up, Hide and seek plugin. Hide as blocks from the killer seekers.