diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 15753cb0..666867b6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -35,7 +35,7 @@ public class JobsCommands implements CommandExecutor { private static final String packagePath = "com.gamingmesh.jobs.commands.list"; - private Map CommandList = new HashMap<>(); + private final Map CommandList = new HashMap<>(); protected Jobs plugin; @@ -57,7 +57,7 @@ public class JobsCommands implements CommandExecutor { if (args.length == 0) return help(sender, 1); - if ((args.length == 1 || args.length == 2) && (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help"))) { + if ((args.length == 1 || args.length == 2) && (args[0].equals("?") || args[0].equalsIgnoreCase("help"))) { int page = 1; if (args.length == 2) try { @@ -184,13 +184,12 @@ public class JobsCommands implements CommandExecutor { classes.put(one, newclass); } - for (Entry> OneClass : classes.entrySet()) { - for (Method met : OneClass.getValue().getMethods()) { + for (Entry> oneClass : classes.entrySet()) { + for (Method met : oneClass.getValue().getMethods()) { if (!met.isAnnotationPresent(JobCommand.class)) continue; - String cmd = OneClass.getKey(); - CommandList.put(cmd, met.getAnnotation(JobCommand.class).value()); + CommandList.put(oneClass.getKey(), met.getAnnotation(JobCommand.class).value()); break; } } @@ -198,35 +197,29 @@ public class JobsCommands implements CommandExecutor { } private static Class getClass(String cmd) { - Class nmsClass = null; try { - nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); + return Class.forName(packagePath + "." + cmd.toLowerCase()); } catch (ClassNotFoundException e) { } - return nmsClass; + return null; } private static Cmd getCmdClass(String cmd) { - Cmd cmdClass = null; try { - Class nmsClass; - nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); + Class nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); if (Cmd.class.isAssignableFrom(nmsClass)) { - cmdClass = (Cmd) nmsClass.getConstructor().newInstance(); + return (Cmd) nmsClass.getConstructor().newInstance(); } } catch (Exception e) { } - return cmdClass; + return null; } /** * Check Job joining permission */ public boolean hasJobPermission(CommandSender sender, Job job) { - if (!sender.hasPermission("jobs.use")) - return false; - - return sender.hasPermission("jobs.join." + job.getName().toLowerCase()); + return sender.hasPermission("jobs.use") && sender.hasPermission("jobs.join." + job.getName().toLowerCase()); } public void sendValidActions(CommandSender sender) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editpoints.java b/src/main/java/com/gamingmesh/jobs/commands/list/editpoints.java index 8dc654b3..470c17c5 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editpoints.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editpoints.java @@ -10,7 +10,7 @@ import com.gamingmesh.jobs.container.PlayerPoints; public class editpoints implements Cmd { @Override - @JobCommand(475) + @JobCommand(477) public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length != 3) { Jobs.getCommandManager().sendUsage(sender, "editpoints"); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java b/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java index 22d8fedd..a8a4689b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java @@ -16,17 +16,17 @@ import com.gamingmesh.jobs.stuff.PageInfo; public class gtop implements Cmd { @Override - @JobCommand(600) + @JobCommand(601) public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { - int amount = Jobs.getGCManager().JobsTopAmount; - - if (args.length != 1 && args.length != 0) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.help.info")); - return true; + if (!(sender instanceof Player)) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); + return false; } - if (!(sender instanceof Player)) - return false; + if (args.length > 1) { + Jobs.getCommandManager().sendUsage(sender, "gtop"); + return true; + } Player player = (Player) sender; int page = 1; @@ -47,6 +47,7 @@ public class gtop implements Cmd { if (page < 1) page = 1; + int amount = Jobs.getGCManager().JobsTopAmount; PageInfo pi = new PageInfo(amount, Jobs.getPlayerManager().getPlayersCache().size(), page); List FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart() - 1); @@ -60,7 +61,7 @@ public class gtop implements Cmd { int i = 0; for (TopList One : FullList) { - if (i > amount) + if (i >= amount) break; sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list", @@ -74,7 +75,7 @@ public class gtop implements Cmd { List ls = new ArrayList<>(); int i = 0; for (TopList one : FullList) { - if (i > amount) + if (i >= amount) break; ls.add(Jobs.getLanguage().getMessage("scoreboard.line", diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java index 6ee726b6..a1003e47 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -11,7 +11,7 @@ import com.gamingmesh.jobs.container.Job; public class moneyboost implements Cmd { @Override - @JobCommand(2300) + @JobCommand(2320) public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length > 3 || args.length <= 1) { Jobs.getCommandManager().sendUsage(sender, "moneyboost"); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java index f2216208..5ec19fa4 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java @@ -11,7 +11,7 @@ import com.gamingmesh.jobs.container.Job; public class pointboost implements Cmd { @Override - @JobCommand(2300) + @JobCommand(2303) public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length > 3 || args.length <= 1) { Jobs.getCommandManager().sendUsage(sender, "pointboost"); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java index 39b97b4c..d916854a 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java @@ -13,7 +13,7 @@ import com.gamingmesh.jobs.container.JobsPlayer; public class stats implements Cmd { @Override - @JobCommand(400) + @JobCommand(401) public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { JobsPlayer jPlayer = null; if (args.length >= 1) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/top.java b/src/main/java/com/gamingmesh/jobs/commands/list/top.java index b76284c0..3404541e 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/top.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/top.java @@ -17,20 +17,19 @@ import com.gamingmesh.jobs.stuff.PageInfo; public class top implements Cmd { @Override - @JobCommand(500) + @JobCommand(526) public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; } - Player player = (Player) sender; - if (args.length != 1 && args.length != 2) { - player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob")); + Jobs.getCommandManager().sendUsage(sender, "top"); return false; } + Player player = (Player) sender; if (args[0].equalsIgnoreCase("clear")) { player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); plugin.getCMIScoreboardManager().removeScoreBoard(player); diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 5f52c0d0..52873390 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -59,7 +59,7 @@ public class GeneralConfigManager { private final HashMap> commandArgs = new HashMap<>(); protected Locale locale; - private ConfigReader c = null; + private ConfigReader c; protected boolean economyAsync, isBroadcastingSkillups, isBroadcastingLevelups, payInCreative, payExploringWhenFlying, addXpPlayer, hideJobsWithoutPermission, payNearSpawner, modifyChat, saveOnDisconnect, MultiServerCompatability; diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 1e2d3273..d5bbc1b9 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -509,7 +509,7 @@ public class LanguageManager { c.get("command.employ.output.target", "You have been employed as a %jobname%."); c.get("command.top.help.info", "Shows top players by jobs name."); - c.get("command.top.help.args", "[jobname]"); + c.get("command.top.help.args", "[jobname]/clear pageNumber"); Jobs.getGCManager().getCommandArgs().put("top", Arrays.asList("[jobname]")); c.get("command.top.error.nojob", "Can't find any job with this name."); c.get("command.top.output.topline", "&aTop&e %amount% &aplayers by &e%jobname% &ajob"); @@ -519,7 +519,7 @@ public class LanguageManager { c.get("command.top.output.show", "&2Show from &e[from] &2until &e[until] &2top list"); c.get("command.gtop.help.info", "Shows top players by global jobs level."); - c.get("command.gtop.help.args", ""); + c.get("command.gtop.help.args", "clear/pageNumber"); c.get("command.gtop.error.nojob", "Can't find any information."); c.get("command.gtop.output.topline", "&aTop&e %amount% &aplayers by global job level"); c.get("command.gtop.output.list", "&e%number%&a. &e%playername% &alvl &e%level% &awith&e %exp% &aexp"); diff --git a/src/main/java/com/gamingmesh/jobs/economy/VaultEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/VaultEconomy.java index 76a04374..450a7bc3 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/VaultEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/VaultEconomy.java @@ -20,6 +20,7 @@ package com.gamingmesh.jobs.economy; import org.bukkit.OfflinePlayer; +@SuppressWarnings("deprecation") public class VaultEconomy implements Economy { private net.milkbowl.vault.economy.Economy vault; @@ -32,7 +33,6 @@ public class VaultEconomy implements Economy { return vault.depositPlayer(offlinePlayer, money).transactionSuccess(); } - @SuppressWarnings("deprecation") @Override public boolean depositPlayer(String PlayerName, double money) { return vault.depositPlayer(PlayerName, money).transactionSuccess(); @@ -43,7 +43,6 @@ public class VaultEconomy implements Economy { return vault.withdrawPlayer(offlinePlayer, money).transactionSuccess(); } - @SuppressWarnings("deprecation") @Override public boolean withdrawPlayer(String PlayerName, double money) { return vault.withdrawPlayer(PlayerName, money).transactionSuccess(); @@ -51,12 +50,9 @@ public class VaultEconomy implements Economy { @Override public boolean hasMoney(OfflinePlayer offlinePlayer, double money) { - if (offlinePlayer.getName() == null) - return false; - return vault.has(offlinePlayer, money); + return offlinePlayer.getName() != null && vault.has(offlinePlayer, money); } - @SuppressWarnings("deprecation") @Override public boolean hasMoney(String PlayerName, double money) { return vault.has(PlayerName, money); diff --git a/src/main/java/com/gamingmesh/jobs/stuff/PageInfo.java b/src/main/java/com/gamingmesh/jobs/stuff/PageInfo.java index 27551864..6c66568a 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/PageInfo.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/PageInfo.java @@ -42,7 +42,7 @@ public class PageInfo { public boolean isEntryOk() { currentEntry++; - return currentEntry - 1 >= start && currentEntry - 1 <= end; + return isContinueNoAdd(); } public boolean isContinue() { @@ -62,7 +62,7 @@ public class PageInfo { } public boolean isPageOk(int page) { - return totalPages < page || page < 1 ? false : true; + return (totalPages < page || page < 1) ? false : true; } public int getStart() { diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 81ee0d0f..a8e4d039 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -117,7 +117,7 @@ public class Util { } Material material = block.getType(); - if (ignoreNoneSolids && !block.getType().isSolid()) + if (ignoreNoneSolids && !material.isSolid()) continue; if (lookingFor == null) { @@ -228,7 +228,7 @@ public class Util { packageName = packageName.replace('.', '/'); - if (entryName != null && entryName.endsWith("." + fileType) && entryName.startsWith(packageName)) { + if (entryName.endsWith("." + fileType) && entryName.startsWith(packageName)) { String name = entryName.replace(packageName, "").replace("." + fileType, "").replace("/", ""); if (name.contains("$")) name = name.split("\\$")[0];