diff --git a/src/main/java/me/lrxh/practice/Locale.java b/src/main/java/me/lrxh/practice/Locale.java index eefb432..07d5e75 100644 --- a/src/main/java/me/lrxh/practice/Locale.java +++ b/src/main/java/me/lrxh/practice/Locale.java @@ -36,6 +36,7 @@ public enum Locale { QUEUE_LEAVE_UNRANKED("QUEUE.LEAVE_UNRANKED"), QUEUE_JOIN_RANKED("QUEUE.JOIN_RANKED"), RANKED_ERROR("RANKED.ERROR-MESSAGE"), + LEADERBOARD_REFRESH("LEADERBOARD.MESSAGE"), PING_YOUR("PING.YOUR"), PING_OTHERS("PING.OTHERS"), QUEUE_LEAVE_RANKED("QUEUE.LEAVE_RANKED"), diff --git a/src/main/java/me/lrxh/practice/Practice.java b/src/main/java/me/lrxh/practice/Practice.java index 24cbe84..c549c65 100644 --- a/src/main/java/me/lrxh/practice/Practice.java +++ b/src/main/java/me/lrxh/practice/Practice.java @@ -43,7 +43,6 @@ import me.lrxh.practice.profile.Profile; import me.lrxh.practice.profile.ProfileListener; import me.lrxh.practice.profile.hotbar.Hotbar; -import me.lrxh.practice.profile.hotbar.Hotbar; import me.lrxh.practice.queue.QueueListener; import me.lrxh.practice.queue.QueueThread; import me.lrxh.practice.scoreboard.ScoreboardAdapter; @@ -87,6 +86,7 @@ public class Practice extends JavaPlugin { private boolean placeholder = false; private SpigotHandler spigotHandler; private Hotbar hotbar; + public static Practice getInstance() { if (practice == null) { practice = new Practice(); @@ -113,7 +113,7 @@ public void onEnable() { loadConfigs(); loadMongo(); spigotHandler = new SpigotHandler(practice); - if(Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].equals("v1_8_R3")){ + if (Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].equals("v1_8_R3")) { spigotHandler.init(false); } diff --git a/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java b/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java index 6be6bd6..5e21169 100644 --- a/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java +++ b/src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java @@ -21,7 +21,6 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -121,9 +120,9 @@ public void remove(Player player, String arenaName) { return; } Arena arena = Arena.getByName(arenaName); - arena.delete(); + arena.delete(); - player.sendMessage(CC.GREEN + "Deleted arena " + arena.getName()); + player.sendMessage(CC.GREEN + "Deleted arena " + arena.getName()); } @Subcommand("wand") @@ -155,30 +154,30 @@ public void status(Player player, String arenaName) { return; } Arena arena = Arena.getByName(arenaName); - player.sendMessage(CC.GREEN + CC.BOLD + "Arena Status " + CC.GRAY + "(" + - (arena.isSetup() ? CC.GREEN : CC.RED) + arena.getName() + CC.GRAY + ")"); - - player.sendMessage(CC.GREEN + "Cuboid Lower Location: " + CC.YELLOW + - (arena.getLowerCorner() == null ? - StringEscapeUtils.unescapeJava("✗") : - StringEscapeUtils.unescapeJava("✓"))); - - player.sendMessage(CC.GREEN + "Cuboid Upper Location: " + CC.YELLOW + - (arena.getUpperCorner() == null ? - StringEscapeUtils.unescapeJava("✗") : - StringEscapeUtils.unescapeJava("✓"))); - - player.sendMessage(CC.GREEN + "Spawn A Location: " + CC.YELLOW + - (arena.getSpawnA() == null ? - StringEscapeUtils.unescapeJava("✗") : - StringEscapeUtils.unescapeJava("✓"))); - - player.sendMessage(CC.GREEN + "Spawn B Location: " + CC.YELLOW + - (arena.getSpawnB() == null ? - StringEscapeUtils.unescapeJava("✗") : - StringEscapeUtils.unescapeJava("✓"))); - - player.sendMessage(CC.GREEN + "Kits: " + CC.YELLOW + StringUtils.join(arena.getKits(), ", ")); + player.sendMessage(CC.GREEN + CC.BOLD + "Arena Status " + CC.GRAY + "(" + + (arena.isSetup() ? CC.GREEN : CC.RED) + arena.getName() + CC.GRAY + ")"); + + player.sendMessage(CC.GREEN + "Cuboid Lower Location: " + CC.YELLOW + + (arena.getLowerCorner() == null ? + StringEscapeUtils.unescapeJava("✗") : + StringEscapeUtils.unescapeJava("✓"))); + + player.sendMessage(CC.GREEN + "Cuboid Upper Location: " + CC.YELLOW + + (arena.getUpperCorner() == null ? + StringEscapeUtils.unescapeJava("✗") : + StringEscapeUtils.unescapeJava("✓"))); + + player.sendMessage(CC.GREEN + "Spawn A Location: " + CC.YELLOW + + (arena.getSpawnA() == null ? + StringEscapeUtils.unescapeJava("✗") : + StringEscapeUtils.unescapeJava("✓"))); + + player.sendMessage(CC.GREEN + "Spawn B Location: " + CC.YELLOW + + (arena.getSpawnB() == null ? + StringEscapeUtils.unescapeJava("✗") : + StringEscapeUtils.unescapeJava("✓"))); + + player.sendMessage(CC.GREEN + "Kits: " + CC.YELLOW + StringUtils.join(arena.getKits(), ", ")); } @Subcommand("genhelper") @@ -350,15 +349,15 @@ public void setspawn(Player player, String arenaName, SpawnType pos) { return; } Arena arena = Arena.getByName(arenaName); - if (pos.equals(SpawnType.A)) { - arena.setSpawnA(player.getLocation()); - } else { - arena.setSpawnB(player.getLocation()); - } + if (pos.equals(SpawnType.A)) { + arena.setSpawnA(player.getLocation()); + } else { + arena.setSpawnB(player.getLocation()); + } - arena.save(); + arena.save(); - player.sendMessage(CC.GREEN + "Updated spawn point " + pos + " for arena " + arena.getName() + ""); + player.sendMessage(CC.GREEN + "Updated spawn point " + pos + " for arena " + arena.getName()); } @Subcommand("setBedSpawn") @@ -374,14 +373,14 @@ public void setBedSpawn(Player player, String arenaName, SpawnType pos) { return; } Arena arena = Arena.getByName(arenaName); - if (pos.equals(SpawnType.A)) { - arena.setBedA(PlayerUtil.getTargetBlock(player, 6).getLocation()); - } else { - arena.setBedB(PlayerUtil.getTargetBlock(player, 6).getLocation()); - } + if (pos.equals(SpawnType.A)) { + arena.setBedA(PlayerUtil.getTargetBlock(player, 6).getLocation()); + } else { + arena.setBedB(PlayerUtil.getTargetBlock(player, 6).getLocation()); + } - arena.save(); - player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getName()); + arena.save(); + player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getName()); } private boolean checkArena(String arena) { diff --git a/src/main/java/me/lrxh/practice/kit/KitEditorListener.java b/src/main/java/me/lrxh/practice/kit/KitEditorListener.java index 4f388fa..c343621 100644 --- a/src/main/java/me/lrxh/practice/kit/KitEditorListener.java +++ b/src/main/java/me/lrxh/practice/kit/KitEditorListener.java @@ -7,7 +7,6 @@ import me.lrxh.practice.profile.Profile; import me.lrxh.practice.profile.ProfileState; import me.lrxh.practice.profile.hotbar.HotbarItem; -import me.lrxh.practice.profile.hotbar.HotbarItem; import me.lrxh.practice.util.CC; import org.bukkit.GameMode; import org.bukkit.Material; diff --git a/src/main/java/me/lrxh/practice/leaderboards/LeaderboardThread.java b/src/main/java/me/lrxh/practice/leaderboards/LeaderboardThread.java index be43f4c..d061c50 100644 --- a/src/main/java/me/lrxh/practice/leaderboards/LeaderboardThread.java +++ b/src/main/java/me/lrxh/practice/leaderboards/LeaderboardThread.java @@ -1,5 +1,6 @@ package me.lrxh.practice.leaderboards; +import me.lrxh.practice.Locale; import me.lrxh.practice.Practice; import me.lrxh.practice.profile.Profile; import me.lrxh.practice.util.CC; @@ -44,8 +45,10 @@ public void run() { Console.sendMessage(CC.translate("&aSaved Player Data!")); Leaderboard.getEloLeaderboards().clear(); Leaderboard.setEloLeaderboards(Leaderboard.init()); - for (Player player : Bukkit.getOnlinePlayers()) { - player.sendMessage(CC.translate("&aLeaderboards Refreshed!")); + if (Practice.getInstance().getMainConfig().getBoolean("LEADERBOARD.ENABLE-MESSAGE")) { + for (Player player : Bukkit.getOnlinePlayers()) { + player.sendMessage(Locale.LEADERBOARD_REFRESH.format(player)); + } } } sleep(SECOND_IN_MILLIS); diff --git a/src/main/java/me/lrxh/practice/match/Match.java b/src/main/java/me/lrxh/practice/match/Match.java index f62d57a..9f6f10a 100644 --- a/src/main/java/me/lrxh/practice/match/Match.java +++ b/src/main/java/me/lrxh/practice/match/Match.java @@ -29,7 +29,6 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/me/lrxh/practice/match/MatchListener.java b/src/main/java/me/lrxh/practice/match/MatchListener.java index 7e05902..a4f39cc 100644 --- a/src/main/java/me/lrxh/practice/match/MatchListener.java +++ b/src/main/java/me/lrxh/practice/match/MatchListener.java @@ -106,8 +106,8 @@ public void onBlockBreakEvent(BlockBreakEvent event) { if (profile.getState() == ProfileState.FIGHTING) { Match match = profile.getMatch(); - if(match.kit.getGameRules().isBedwars()){ - if(event.getBlock().getLocation().equals(event.getPlayer().getBedSpawnLocation())){ + if (match.kit.getGameRules().isBedwars()) { + if (event.getBlock().getLocation().equals(event.getPlayer().getBedSpawnLocation())) { event.getPlayer().sendMessage(CC.translate("&cYou can't break your own bed!")); event.setCancelled(true); } @@ -130,7 +130,7 @@ public void onBlockBreakEvent(BlockBreakEvent event) { } else { event.setCancelled(true); } - if(match.kit.getGameRules().isBedwars() && (event.getBlock().getType().equals(Material.BED_BLOCK) || event.getBlock().getType().equals(Material.BED))){ + if (match.kit.getGameRules().isBedwars() && (event.getBlock().getType().equals(Material.BED_BLOCK) || event.getBlock().getType().equals(Material.BED))) { event.setCancelled(false); } } else { @@ -239,7 +239,7 @@ public void onPlayerDeathEvent(PlayerDeathEvent event) { Profile profile = Profile.getByUuid(event.getEntity().getUniqueId()); if (profile.getState() == ProfileState.FIGHTING) { - if(profile.getMatch().kit.getGameRules().isBedwars()){ + if (profile.getMatch().kit.getGameRules().isBedwars()) { PlayerUtil.animateDeath(event.getEntity()); return; } diff --git a/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java b/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java index f81a04a..584728f 100644 --- a/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java +++ b/src/main/java/me/lrxh/practice/match/impl/BasicTeamMatch.java @@ -52,14 +52,14 @@ public void setupPlayer(Player player) { // Teleport the player to their spawn point Location spawn = participantA.containsPlayer(player.getUniqueId()) ? getArena().getSpawnA() : getArena().getSpawnB(); - if(kit.getGameRules().isBedwars()){ - if(participantA.containsPlayer(player.getUniqueId())){ + if (kit.getGameRules().isBedwars()) { + if (participantA.containsPlayer(player.getUniqueId())) { player.setBedSpawnLocation(arena.getBedA()); - }else{ + } else { player.setBedSpawnLocation(arena.getBedB()); } } - + if (spawn.getBlock().getType() == Material.AIR) { player.teleport(spawn); } else { diff --git a/src/main/java/me/lrxh/practice/profile/hotbar/Hotbar.java b/src/main/java/me/lrxh/practice/profile/hotbar/Hotbar.java index 78ed1e0..6db65c3 100644 --- a/src/main/java/me/lrxh/practice/profile/hotbar/Hotbar.java +++ b/src/main/java/me/lrxh/practice/profile/hotbar/Hotbar.java @@ -19,9 +19,9 @@ @Getter public class Hotbar { - private final Map items = new HashMap<>(); + private final Map items = new HashMap<>(); - public void init() { + public void init() { FileConfiguration config = Practice.getInstance().getMainConfig().getConfiguration(); ConfigurationSection itemsSection = config.getConfigurationSection("HOTBAR_ITEMS"); @@ -64,7 +64,7 @@ public void init() { } } - public void giveHotbarItems(Player player) { + public void giveHotbarItems(Player player) { Profile profile = Profile.getByUuid(player.getUniqueId()); PlayerUtil.reset(player); @@ -98,7 +98,7 @@ public void giveHotbarItems(Player player) { player.updateInventory(); } - public HotbarItem fromItemStack(ItemStack itemStack) { + public HotbarItem fromItemStack(ItemStack itemStack) { for (Map.Entry entry : getItems().entrySet()) { if (entry.getValue() != null && entry.getValue().equals(itemStack)) { return entry.getKey(); diff --git a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java index f187d92..2d4313d 100644 --- a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java +++ b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java @@ -80,7 +80,7 @@ public void clicked(Player player, ClickType clickType) { Queue randomQueue = queues.get(rand.nextInt(queues.size())); player.closeInventory(); - randomQueue.addPlayer(player, randomQueue.isRanked() ? profile.getKitData().get(randomQueue.getKit()).getElo() : 0, ranked); + randomQueue.addPlayer(player, randomQueue.isRanked() ? profile.getKitData().get(randomQueue.getKit()).getElo() : 0, !ranked); randomQueue.addQueue(); } } diff --git a/src/main/java/me/lrxh/practice/setting/Settings.java b/src/main/java/me/lrxh/practice/setting/Settings.java index 1344fe5..2860982 100644 --- a/src/main/java/me/lrxh/practice/setting/Settings.java +++ b/src/main/java/me/lrxh/practice/setting/Settings.java @@ -14,8 +14,7 @@ public enum Settings { SHOW_LINES("Scoreboard Lines", Material.STRING, "Toggle Scoreboard lines."), THEME("Select Theme", Material.BOOK, "Select Color Theme."), PING_RANGE("Ping Range", Material.STICK, "Change Ping Range."), - MENU_SOUNDS("Menu Sounds", Material.REDSTONE_COMPARATOR, "Toggle Menu Sounds."), - TIME_CHANGER("Change Time", Material.LEVER, "Change world time."); + MENU_SOUNDS("Menu Sounds", Material.REDSTONE_COMPARATOR, "Toggle Menu Sounds."); private final String name; private final Material material; diff --git a/src/main/java/me/lrxh/practice/setting/SettingsMenu.java b/src/main/java/me/lrxh/practice/setting/SettingsMenu.java index 3e55711..2c8c867 100644 --- a/src/main/java/me/lrxh/practice/setting/SettingsMenu.java +++ b/src/main/java/me/lrxh/practice/setting/SettingsMenu.java @@ -5,7 +5,6 @@ import me.lrxh.practice.profile.KillEffects; import me.lrxh.practice.profile.Profile; import me.lrxh.practice.profile.Themes; -import me.lrxh.practice.profile.Times; import me.lrxh.practice.profile.visibility.VisibilityLogic; import me.lrxh.practice.util.CC; import me.lrxh.practice.util.ItemBuilder; @@ -51,9 +50,9 @@ public boolean resetCursor() { @Override public Map getButtons(Player player) { HashMap buttons = new HashMap<>(); - int i = 10; + int i = 9; for (Settings settings : Settings.values()) { - buttons.put(i+=1, new SettingsButton(settings)); + buttons.put(i += 1, new SettingsButton(settings)); } return buttons; } @@ -138,15 +137,6 @@ public ItemStack getButtonItem(Player player) { lore.add("&aClick to select"); break; } - case TIME_CHANGER: { - lore.add(profile.getOptions().time().equals(Times.DAY) ? " &7&l▶ &aDay" : " &7&l▶ &7Day"); - lore.add(profile.getOptions().time().equals(Times.NIGHT) ? " &7&l▶ &aNight" : " &7&l▶ &7Night"); - lore.add(profile.getOptions().time().equals(Times.SUNRISE) ? " &7&l▶ &aSunrise" : " &7&l▶ &7Sunrise"); - lore.add(profile.getOptions().time().equals(Times.SUNSET) ? " &7&l▶ &aSunset" : " &7&l▶ &7Sunset"); - lore.add(""); - lore.add("&aClick to select"); - break; - } } return new ItemBuilder(this.settings.getMaterial()).name(Practice.getInstance().getMenusConfig().getString("SETTINGS.SETTING-NAME").replace("", settings.getName())).lore(lore).clearEnchantments().clearFlags().clearFlags().build(); } @@ -164,25 +154,6 @@ public void clicked(Player player, ClickType clickType) { } break; } - case TIME_CHANGER: { - switch (profile.getOptions().time()) { - case DAY: - profile.getOptions().time(Times.NIGHT); - break; - case NIGHT: - profile.getOptions().time(Times.SUNRISE); - break; - case SUNRISE: - profile.getOptions().time(Times.SUNSET); - break; - case SUNSET: - profile.getOptions().time(Times.DAY); - break; - } - player.setPlayerTime(profile.getOptions().time().getTime(), false); - player.sendMessage(Locale.OPTIONS_KILLEFFECT_SELECT.format(player, profile.getOptions().killEffect().getDisplayName())); - break; - } case MENU_SOUNDS: { profile.getOptions().menuSounds(!profile.getOptions().menuSounds()); if (profile.getOptions().menuSounds()) { diff --git a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java index cb76340..627e1b7 100644 --- a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java +++ b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java @@ -60,9 +60,9 @@ public static List format(List lines, Player player) { } - if(Practice.getInstance().isPlaceholder()){ + if (Practice.getInstance().isPlaceholder()) { formattedLines.add(PlaceholderAPI.setPlaceholders(player, line)); - }else { + } else { formattedLines.add(line); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 95c8f1d..18e7858 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,6 +7,8 @@ RANKED: You need {0} more wins!' DEFAULT-THEME-COLOR: AQUA LEADERBOARD: + ENABLE-MESSAGE: True + MESSAGE: '&aLeaderboards Refreshed!' UPDATE-TIME: 1 JOIN_MESSAGE: - '&7&m--------------------------------'