diff --git a/libs/Vault-1.6.7.jar b/libs/Vault-1.6.7.jar new file mode 100644 index 00000000..4829cfff Binary files /dev/null and b/libs/Vault-1.6.7.jar differ diff --git a/libs/Vault-1.7.1.jar b/libs/Vault-1.7.1.jar deleted file mode 100644 index 60aef0c6..00000000 Binary files a/libs/Vault-1.7.1.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index be57bbdd..e53f59c4 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ net.milkbowl.vault Vault - 1.7.1 + 1.6.7 provided diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index e0f98095..84a2ef65 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -30,7 +30,7 @@ public class ItemManager { static HashMap byBukkitName = new HashMap<>(); static HashMap byMojangName = new HashMap<>(); static HashMap byMaterial = new HashMap<>(); - static final Version version = Jobs.getVersionCheckManager().getVersion(); + private final static Version version = Jobs.getVersionCheckManager().getVersion(); @SuppressWarnings("deprecation") public static void load() { @@ -1560,7 +1560,7 @@ public class ItemManager { } public int getId() { - if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) { + if (version.isEqualOrHigher(Version.v1_13_R1)) { return this.id; } return getLegacyId(); @@ -1616,7 +1616,7 @@ public class ItemManager { break; } } - if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) { + if (version.isEqualOrHigher(Version.v1_13_R1)) { return new ItemStack(mat == null ? Material.STONE : mat); } return new ItemStack(mat == null ? Material.STONE : mat, 1, (short) this.getLegacyData()); @@ -1625,7 +1625,7 @@ public class ItemManager { @Deprecated public short getData() { - if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) { + if (version.isEqualOrHigher(Version.v1_13_R1)) { return 0; } return (short) legacyData; diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 25a418d0..f276bced 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -34,7 +34,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -148,9 +147,9 @@ public class Jobs extends JavaPlugin { public static WeakHashMap actionbartoggle = new WeakHashMap<>(); public static WeakHashMap BossBartoggle = new WeakHashMap<>(); // public static WeakHashMap GlobalBoost = new WeakHashMap(); - private static BufferedEconomy economy; - private static PermissionHandler permissionHandler; - private static PermissionManager permissionManager; + private static BufferedEconomy economy = null; + private static PermissionHandler permissionHandler = null; + private static PermissionManager permissionManager = null; // private static ItemManager itemManager; @@ -243,7 +242,7 @@ public class Jobs extends JavaPlugin { public static Reflections getReflections() { if (reflections == null) - reflections = new Reflections(instance); + reflections = new Reflections(); return reflections; } @@ -543,14 +542,14 @@ public class Jobs extends JavaPlugin { loadAllPlayersData(); // add all online players for (Player online : Bukkit.getServer().getOnlinePlayers()) { - Jobs.getPlayerManager().playerJoin(online); + pManager.playerJoin(online); } } public static void loadAllPlayersData() { long time = System.currentTimeMillis(); // Cloning to avoid issues - HashMap temp = new HashMap<>(Jobs.getPlayerManager().getPlayersInfoUUIDMap()); + HashMap temp = new HashMap<>(pManager.getPlayersInfoUUIDMap()); HashMap> playersJobs = dao.getAllJobs(); HashMap playersPoints = dao.getAllPoints(); HashMap> playersLogs = dao.getAllLogs(); @@ -561,7 +560,7 @@ public class Jobs extends JavaPlugin { Entry one = it.next(); try { int id = one.getValue().getID(); - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline( + JobsPlayer jPlayer = pManager.getJobsPlayerOffline( one.getValue(), playersJobs.get(id), playersPoints.get(id), @@ -570,15 +569,15 @@ public class Jobs extends JavaPlugin { playersLimits.get(id)); if (jPlayer == null) continue; - Jobs.getPlayerManager().addPlayerToCache(jPlayer); + pManager.addPlayerToCache(jPlayer); } catch (Exception e) { e.printStackTrace(); } } dao.getMap().clear(); - if (Jobs.getPlayerManager().getPlayersCache().size() != 0) - consoleMsg("&e[Jobs] Preloaded " + Jobs.getPlayerManager().getPlayersCache().size() + " players data in " + ((int) (((System.currentTimeMillis() - time) + if (pManager.getPlayersCache().size() != 0) + consoleMsg("&e[Jobs] Preloaded " + pManager.getPlayersCache().size() + " players data in " + ((int) (((System.currentTimeMillis() - time) / 1000d) * 100) / 100D)); } @@ -604,7 +603,7 @@ public class Jobs extends JavaPlugin { GconfigManager.reload(); lManager.reload(); - Jobs.getConfigManager().reload(); + configManager.reload(); usedSlots.clear(); for (Job job : jobs) { usedSlots.put(job, getJobsDAO().getSlotsTaken(job)); @@ -625,8 +624,8 @@ public class Jobs extends JavaPlugin { dao.loadPlayerData(); // Schedule - Jobs.getScheduleManager().load(); - Jobs.getScheduleManager().start(); + scheduleManager.load(); + scheduleManager.start(); permissionManager = new PermissionManager(); } @@ -652,7 +651,7 @@ public class Jobs extends JavaPlugin { * Executes close connections */ public static void ChangeDatabase() { - getDBManager().switchDataBase(); + DBManager.switchDataBase(); pManager.reload(); } @@ -701,8 +700,8 @@ public class Jobs extends JavaPlugin { * Sets the permission handler * @param h - the permission handler */ - public void setPermissionHandler(PermissionHandler h) { - permissionHandler = h; + public void setPermissionHandler(PermissionHandler permissionHandler) { + Jobs.permissionHandler = permissionHandler; } /** @@ -839,7 +838,7 @@ public class Jobs extends JavaPlugin { // all loaded properly. dao.loadBlockProtection(); - getExplore().load(); + exploreManager.load(); FurnaceBrewingHandling.load(); @@ -866,7 +865,7 @@ public class Jobs extends JavaPlugin { FurnaceBrewingHandling.save(); - Jobs.shutdown(); + shutdown(); consoleMsg("&e[Jobs] &2Plugin has been disabled succesfully."); running = false; this.setEnabled(false); @@ -982,12 +981,12 @@ public class Jobs extends JavaPlugin { return; if (info.getType() == ActionType.BREAK && block != null) - Jobs.getBpManager().remove(block); + BpManager.remove(block); if (pointAmount != 0D) jPlayer.setSaved(false); - Jobs.getEconomy().pay(jPlayer, income, pointAmount, 0.0); + economy.pay(jPlayer, income, pointAmount, 0.0); if (GconfigManager.LoggingUse) { HashMap amounts = new HashMap<>(); @@ -1039,7 +1038,7 @@ public class Jobs extends JavaPlugin { player.giveExp(expInt); } } - Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim); + Boost boost = pManager.getFinalBonus(jPlayer, prog.getJob(), ent, victim); // Calculate income if (income != 0D) { @@ -1100,11 +1099,11 @@ public class Jobs extends JavaPlugin { try { if (expAmount != 0D && GconfigManager.BossBarEnabled) if (GconfigManager.BossBarShowOnEachAction) - Jobs.getBBManager().ShowJobProgression(jPlayer, prog); + BBManager.ShowJobProgression(jPlayer, prog); else jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); } catch (Exception e) { - Bukkit.getConsoleSender().sendMessage("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it."); + consoleMsg("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it."); } // JobsPayment event @@ -1153,17 +1152,17 @@ public class Jobs extends JavaPlugin { //player.sendMessage("This block is protected using Rukes' system!"); return false; } - BlockProtection bp = getBpManager().getBp(block.getLocation()); + BlockProtection bp = BpManager.getBp(block.getLocation()); if (bp != null) { Long time = bp.getTime(); - Integer cd = getBpManager().getBlockDelayTime(block); + Integer cd = BpManager.getBlockDelayTime(block); if (time == -1L) { - getBpManager().add(block, cd); + BpManager.add(block, cd); return false; } if ((time < System.currentTimeMillis()) && (bp.getAction() != DBAction.DELETE)) { - getBpManager().remove(block); + BpManager.remove(block); return true; } if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) { @@ -1174,22 +1173,22 @@ public class Jobs extends JavaPlugin { } return false; } - getBpManager().add(block, cd); + BpManager.add(block, cd); if ((cd == null || cd == 0) && getGCManager().useGlobalTimer) { - getBpManager().add(block, getGCManager().globalblocktimer); + BpManager.add(block, getGCManager().globalblocktimer); } } else if (getGCManager().useGlobalTimer) { - getBpManager().add(block, getGCManager().globalblocktimer); + BpManager.add(block, getGCManager().globalblocktimer); } } else if (info.getType() == ActionType.PLACE) { - BlockProtection bp = getBpManager().getBp(block.getLocation()); + BlockProtection bp = BpManager.getBp(block.getLocation()); if (bp != null) { Long time = bp.getTime(); - Integer cd = getBpManager().getBlockDelayTime(block); + Integer cd = BpManager.getBlockDelayTime(block); if (time != -1L) { if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) { - getBpManager().add(block, cd); + BpManager.add(block, cd); return true; } if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) { @@ -1198,16 +1197,16 @@ public class Jobs extends JavaPlugin { if (player.canGetPaid(info)) getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec)); } - getBpManager().add(block, cd); + BpManager.add(block, cd); return false; } } else if (bp.isPaid().booleanValue() && bp.getTime() == -1L && cd != null && cd == -1) { - getBpManager().add(block, cd); + BpManager.add(block, cd); return false; } else - getBpManager().add(block, cd); + BpManager.add(block, cd); } else - getBpManager().add(block, getBpManager().getBlockDelayTime(block)); + BpManager.add(block, BpManager.getBlockDelayTime(block)); } return true; @@ -1304,8 +1303,7 @@ public class Jobs extends JavaPlugin { RawMessage rm = new RawMessage(); rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + perm); rm.show((Player) sender); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission")); + sendMessage(Bukkit.getServer().getConsoleSender(), Jobs.getLanguage().getMessage("general.error.permission")); return false; } return true; diff --git a/src/main/java/com/gamingmesh/jobs/Reflections.java b/src/main/java/com/gamingmesh/jobs/Reflections.java index 0a69d72e..ab0f14bf 100644 --- a/src/main/java/com/gamingmesh/jobs/Reflections.java +++ b/src/main/java/com/gamingmesh/jobs/Reflections.java @@ -20,11 +20,8 @@ public class Reflections { private Class CraftItemStack; private Class Item; private Class IStack; - @SuppressWarnings("unused") - private Jobs plugin; - public Reflections(Jobs plugin) { - this.plugin = plugin; + public Reflections() { initialize(); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 00dcc9b8..2274666a 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -25,7 +25,6 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; @@ -43,7 +42,7 @@ public class JobsCommands implements CommandExecutor { private static final String label = "jobs"; private static final String packagePath = "com.gamingmesh.jobs.commands.list"; private static final List hidenCommands = new ArrayList<>(); - Map CommandList = new HashMap<>(); + private Map CommandList = new HashMap<>(); protected Jobs plugin; @@ -94,8 +93,7 @@ public class JobsCommands implements CommandExecutor { RawMessage rm = new RawMessage(); rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + label + ".command." + cmd); rm.show(sender); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission")); + Jobs.sendMessage(Bukkit.getServer().getConsoleSender(), Jobs.getLanguage().getMessage("general.error.permission")); } else Jobs.sendMessage(sender, Jobs.getLanguage().getMessage("general.error.permission")); return true; diff --git a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java index 001207c1..de6034b2 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java @@ -21,7 +21,7 @@ public class ExploreManager { private int playerAmount = 1; public int getPlayerAmount() { - return this.playerAmount; + return playerAmount; } public void setPlayerAmount(int amount) { @@ -30,12 +30,12 @@ public class ExploreManager { } public boolean isExploreEnabled() { - return this.exploreEnabled; + return exploreEnabled; } public void setExploreEnabled() { if (!exploreEnabled) { - this.exploreEnabled = true; + exploreEnabled = true; } } diff --git a/src/main/java/com/gamingmesh/jobs/container/RestrictedArea.java b/src/main/java/com/gamingmesh/jobs/container/RestrictedArea.java index 72fb0ccd..360afc92 100644 --- a/src/main/java/com/gamingmesh/jobs/container/RestrictedArea.java +++ b/src/main/java/com/gamingmesh/jobs/container/RestrictedArea.java @@ -25,7 +25,7 @@ public class RestrictedArea { private CuboidArea area; private double multiplier; private String name; - private String wgName; + private String wgName; public RestrictedArea(String name, CuboidArea area, double multiplier) { this.name = name; diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 7bb1e78d..b0255847 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -11,11 +11,9 @@ import java.util.Map.Entry; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.World; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; @@ -1601,7 +1599,6 @@ public abstract class JobsDAO { int deleted = 0; Long current = System.currentTimeMillis(); Long mark = System.currentTimeMillis() - (Jobs.getGCManager().BlockProtectionDays * 24L * 60L * 60L * 1000L); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); for (Entry>>> worlds : Jobs.getBpManager().getMap().entrySet()) { for (Entry>> regions : worlds.getValue().entrySet()) { @@ -1617,8 +1614,7 @@ public abstract class JobsDAO { deleted++; if (deleted % 10000 == 0) { delete.executeBatch(); - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Removed " + deleted + " old block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Removed " + deleted + " old block protection entries."); } break; case INSERT: @@ -1635,8 +1631,7 @@ public abstract class JobsDAO { inserted++; if (inserted % 10000 == 0) { insert.executeBatch(); - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Added " + inserted + " new block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Added " + inserted + " new block protection entries."); } break; case UPDATE: @@ -1650,8 +1645,7 @@ public abstract class JobsDAO { updated++; if (updated % 10000 == 0) { update.executeBatch(); - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Upadated " + updated + " old block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Upadated " + updated + " old block protection entries."); } break; case NONE: @@ -1683,16 +1677,13 @@ public abstract class JobsDAO { conn.commit(); conn.setAutoCommit(true); if (inserted > 0) { - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Added " + inserted + " new block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Added " + inserted + " new block protection entries."); } if (updated > 0) { - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Updated " + updated + " with new block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Updated " + updated + " with new block protection entries."); } if (deleted > 0) { - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Deleted " + deleted + " old block protection entries."); - console.sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Deleted " + deleted + " old block protection entries."); } } catch (SQLException e) { e.printStackTrace(); @@ -1747,15 +1738,13 @@ public abstract class JobsDAO { ii++; if (ii >= 100000) { - String message = ChatColor.translateAlternateColorCodes('&', "&6[Jobs] Loading (" + i + ") BP"); - Bukkit.getServer().getConsoleSender().sendMessage(message); + Jobs.consoleMsg("&6[Jobs] Loading (" + i + ") BP"); ii = 0; } Jobs.getBpManager().timer += System.currentTimeMillis() - t; } if (i > 0) { - String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Loaded " + i + " block protection entries. " + Jobs.getBpManager().timer); - Bukkit.getServer().getConsoleSender().sendMessage(message); + Jobs.consoleMsg("&e[Jobs] Loaded " + i + " block protection entries. " + Jobs.getBpManager().timer); } } catch (SQLException e) { e.printStackTrace(); @@ -1808,7 +1797,7 @@ public abstract class JobsDAO { conn.setAutoCommit(true); if (i > 0) - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Saved " + i + " new explorer entries.")); + Jobs.consoleMsg("&e[Jobs] Saved " + i + " new explorer entries."); } catch (SQLException e) { e.printStackTrace(); @@ -1855,7 +1844,7 @@ public abstract class JobsDAO { conn.setAutoCommit(true); if (i > 0) - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Updated " + i + " explorer entries.")); + Jobs.consoleMsg("&e[Jobs] Updated " + i + " explorer entries."); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 1569fd89..5619883e 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1532,6 +1532,8 @@ public class JobsPaymentListener implements Listener { //disabling plugin in world if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) return; + if (event.isCancelled()) + return; if (!Jobs.getExplore().isExploreEnabled()) return; @@ -1540,7 +1542,7 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getGCManager().payExploringWhenFlying() && player.isFlying()) return; - ExploreRespond respond = Jobs.getExplore().ChunkRespond(event.getPlayer(), event.getNewChunk()); + ExploreRespond respond = Jobs.getExplore().ChunkRespond(player, event.getNewChunk()); if (!respond.isNewChunk()) return; @@ -1553,7 +1555,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) + if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))