From 5c715e35f88ee41df186028611f45e6e151b0d4e Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 4 Jan 2016 13:44:18 +0200 Subject: [PATCH] prevent water breaking blocks / small fixes --- .../maven/com.gamingmesh/jobs/pom.properties | 2 +- META-INF/maven/com.gamingmesh/jobs/pom.xml | 2 +- com/gamingmesh/jobs/JobsPlugin.java | 4 +- .../jobs/commands/JobsCommands.java | 25 +++++- .../jobs/config/JobsConfiguration.java | 38 +++++++++- com/gamingmesh/jobs/dao/.gitignore | 1 + com/gamingmesh/jobs/dao/JobsDAO.java | 47 ++++++++++++ com/gamingmesh/jobs/listeners/.gitignore | 1 + .../jobs/listeners/JobsListener.java | 32 +++++++- .../jobs/listeners/JobsPaymentListener.java | 27 ++++--- .../jobs/listeners/McMMOlistener.java | 2 +- .../jobs/listeners/MythicMobsListener.java | 2 +- com/gamingmesh/jobs/tasks/.gitignore | 2 + .../jobs/tasks/BufferedPaymentTask.java | 2 +- .../jobs/tasks/BufferedPaymentThread.java | 76 +++++++++---------- .../jobs/tasks/DatabaseSaveThread.java | 66 ++++++++-------- plugin.yml | 2 +- 17 files changed, 235 insertions(+), 96 deletions(-) diff --git a/META-INF/maven/com.gamingmesh/jobs/pom.properties b/META-INF/maven/com.gamingmesh/jobs/pom.properties index 2f42ff28..087e8883 100644 --- a/META-INF/maven/com.gamingmesh/jobs/pom.properties +++ b/META-INF/maven/com.gamingmesh/jobs/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven #Wed Aug 20 21:00:44 EDT 2014 -version=2.13-SNAPSHOT +version=2.55-SNAPSHOT groupId=com.gamingmesh artifactId=jobs diff --git a/META-INF/maven/com.gamingmesh/jobs/pom.xml b/META-INF/maven/com.gamingmesh/jobs/pom.xml index 5565f481..90381e11 100644 --- a/META-INF/maven/com.gamingmesh/jobs/pom.xml +++ b/META-INF/maven/com.gamingmesh/jobs/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gamingmesh jobs - 2.13-SNAPSHOT + 2.55-SNAPSHOT jar Jobs Jobs Plugin for the BukkitAPI diff --git a/com/gamingmesh/jobs/JobsPlugin.java b/com/gamingmesh/jobs/JobsPlugin.java index 249f8b72..5f092a85 100644 --- a/com/gamingmesh/jobs/JobsPlugin.java +++ b/com/gamingmesh/jobs/JobsPlugin.java @@ -157,7 +157,7 @@ public class JobsPlugin extends JavaPlugin { ScheduleUtil.scheduler(); ScheduleUtil.DateUpdater(); - String message = ChatColor.translateAlternateColorCodes('&', "&2Plugin has been enabled succesfully."); + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6Plugin has been enabled succesfully."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); } @@ -166,7 +166,7 @@ public class JobsPlugin extends JavaPlugin { public void onDisable() { GuiTools.CloseInventories(); Jobs.shutdown(); - String message = ChatColor.translateAlternateColorCodes('&', "&2Plugin has been disabled succesfully."); + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); } diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index e1e75b8b..1f715cab 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -173,9 +173,22 @@ public class JobsCommands implements CommandExecutor { return true; } + sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting name fix proccess, this can take up to minute depending on your data base size."); Jobs.getJobsDAO().fixName(sender); - sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting name fix proccess, this can take up to minute depending on your data base size."); + return true; + } + + @JobCommand + public boolean fixuuid(CommandSender sender, String[] args) throws IOException { + + if (args.length > 0) { + sendUsage(sender, "fixuuid"); + return true; + } + + sender.sendMessage(ChatColor.GOLD + "[Jobs] Starting uuid fix proccess, this can take up to minute depending on your data base size."); + Jobs.getJobsDAO().fixUuid(sender); return true; } @@ -1417,8 +1430,12 @@ public class JobsCommands implements CommandExecutor { List logList = JPlayer.getLog(); - if (logList.size() == 0) + if (logList.size() == 0) { + sender.sendMessage(Language.getMessage("command.log.output.bottomline")); + sender.sendMessage(Language.getMessage("command.log.output.nodata")); + sender.sendMessage(Language.getMessage("command.log.output.bottomline")); return true; + } Map unsortMap = new HashMap(); @@ -1442,7 +1459,7 @@ public class JobsCommands implements CommandExecutor { String msg = Language.getMessage("command.log.output.list") .replace("%number%", String.valueOf(count)) .replace("%action%", one.getActionType()) - .replace("%item%", oneMap.getValue().getItemName().replace(":0", "").toLowerCase()) + .replace("%item%", oneMap.getValue().getItemName().replace(":0", "").replace("_", " ").toLowerCase()) .replace("%qty%", String.valueOf(oneMap.getValue().getCount())) .replace("%money%", String.valueOf(oneMap.getValue().getMoney())) .replace("%exp%", String.valueOf(oneMap.getValue().getExp())); @@ -1523,7 +1540,7 @@ public class JobsCommands implements CommandExecutor { break; } if (unsortMap.size() == 0) { - sender.sendMessage("No data found"); + sender.sendMessage(Language.getMessage("command.glog.output.nodata")); } sender.sendMessage(Language.getMessage("command.glog.output.bottomline")); diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java index 8764454d..7db6234f 100644 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ b/com/gamingmesh/jobs/config/JobsConfiguration.java @@ -74,7 +74,7 @@ public class JobsConfiguration { public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop, - EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit; + EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, WaterBlockBreake; public int EconomyLimitTimeLimit, EconomyExpTimeLimit; public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; @@ -611,6 +611,11 @@ public class JobsConfiguration { writer.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner"); PreventMagmaCubeSplit = getBoolean("ExploitProtections.Spawner.PreventMagmaCubeSplit", true, config, writer); + writer.addComment("ExploitProtections.WaterBlockBreake", + "Prevent water braking placed blocks. Protection resets with server restart or after plants grows to next stage with bone powder or naturally", + "For strange reason works only 5 of 10 times, but this is completely enough to prevent exploiting"); + WaterBlockBreake = getBoolean("ExploitProtections.WaterBlockBreake", true, config, writer); + writer.addComment("use-breeder-finder", "Breeder finder.", "If you are not using breeding payment, you can disable this to save little resources. Really little."); useBreederFinder = getBoolean("use-breeder-finder", true, config, writer); @@ -946,6 +951,35 @@ public class JobsConfiguration { restrictedPlaceBlocksTimer = (ArrayList) config.getIntegerList("PlacedBlockTimer"); copySetting(config, writer, "PlacedBlockTimer"); + writer.addComment("PlacedBlockTimer", "Block place protected by timer in sec", "For this to work CoreProtect plugin should be installed"); + restrictedPlaceBlocksTimer.add(2); + restrictedPlaceBlocksTimer.add(3); + restrictedPlaceBlocksTimer.add(6); + restrictedPlaceBlocksTimer.add(12); + restrictedPlaceBlocksTimer.add(18); + restrictedPlaceBlocksTimer.add(31); + restrictedPlaceBlocksTimer.add(32); + restrictedPlaceBlocksTimer.add(37); + restrictedPlaceBlocksTimer.add(38); + restrictedPlaceBlocksTimer.add(39); + restrictedPlaceBlocksTimer.add(40); + restrictedPlaceBlocksTimer.add(55); + restrictedPlaceBlocksTimer.add(59); + restrictedPlaceBlocksTimer.add(80); + restrictedPlaceBlocksTimer.add(81); + restrictedPlaceBlocksTimer.add(83); + restrictedPlaceBlocksTimer.add(103); + restrictedPlaceBlocksTimer.add(106); + restrictedPlaceBlocksTimer.add(111); + restrictedPlaceBlocksTimer.add(141); + restrictedPlaceBlocksTimer.add(142); + restrictedPlaceBlocksTimer.add(161); + restrictedPlaceBlocksTimer.add(171); + restrictedPlaceBlocksTimer.add(175); + config.addDefault("PlacedBlockTimer", restrictedPlaceBlocksTimer); + restrictedPlaceBlocksTimer = (ArrayList) config.getIntegerList("PlacedBlockTimer"); + copySetting(config, writer, "PlacedBlockTimer"); + try { writer.save(f); } catch (IOException e) { @@ -1378,6 +1412,7 @@ public class JobsConfiguration { GetConfigString("command.log.output.bottomline", "&7***********************************************************", writer, conf, true); GetConfigString("command.log.output.prev", "&e<<<<< Prev page &2|", writer, conf, true); GetConfigString("command.log.output.next", "&2|&e Next Page >>>>", writer, conf, true); + GetConfigString("command.log.output.nodata", "&cData not found", writer, conf, true); GetConfigString("command.glog.help.info", "Shows global statistics.", writer, conf, true); GetConfigString("command.glog.help.args", "", writer, conf, true); @@ -1385,6 +1420,7 @@ public class JobsConfiguration { GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf, true); GetConfigString("command.glog.output.bottomline", "&7**************************************************************", writer, conf, true); + GetConfigString("command.glog.output.nodata", "&cData not found", writer, conf, true); GetConfigString("command.transfer.help.info", "Transfer a player's job from an old job to a new job.", writer, conf, true); GetConfigString("command.transfer.help.args", "[playername] [oldjob] [newjob]", writer, conf, true); diff --git a/com/gamingmesh/jobs/dao/.gitignore b/com/gamingmesh/jobs/dao/.gitignore index ea18264e..a340c2f8 100644 --- a/com/gamingmesh/jobs/dao/.gitignore +++ b/com/gamingmesh/jobs/dao/.gitignore @@ -9,3 +9,4 @@ /JobsDriver.class /JobsDrivers.class /JobsDAO$1.class +/JobsDAO$2.class diff --git a/com/gamingmesh/jobs/dao/JobsDAO.java b/com/gamingmesh/jobs/dao/JobsDAO.java index 72a6aff4..bf8e0749 100644 --- a/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/com/gamingmesh/jobs/dao/JobsDAO.java @@ -491,6 +491,53 @@ public abstract class JobsDAO { return null; } + public void fixUuid(final CommandSender sender) { + Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { + @Override + public void run() { + JobsConnection conn = getConnection(); + if (conn == null) + return; + try { + PreparedStatement prest = conn.prepareStatement("SELECT `player_uuid`, `username` FROM `" + prefix + "jobs`;"); + ResultSet res = prest.executeQuery(); + HashMap convert = new HashMap(); + int failed = 0; + while (res.next()) { + + UUID uuid = OfflinePlayerList.getPlayer(res.getString("username")).getUniqueId(); + if (uuid == null) + continue; + + convert.put(uuid.toString(), res.getString("username")); + } + res.close(); + prest.close(); + + prest = conn.prepareStatement("UPDATE `" + prefix + "jobs` SET `player_uuid` = ? WHERE `username` = ?;"); + + for (Entry oneEntry : convert.entrySet()) { + prest.setString(1, oneEntry.getKey()); + prest.setString(2, oneEntry.getValue()); + prest.execute(); + } + if (prest != null) + prest.close(); + + sender.sendMessage(ChatColor.GOLD + "[Jobs] Converted " + ChatColor.YELLOW + convert.size() + ChatColor.GOLD + " user uuids and failed " + + ChatColor.YELLOW + failed + ChatColor.GOLD + " to do so, most likely user data no longer exists in your player data folder"); + + return; + } catch (SQLException e) { + e.printStackTrace(); + } + + return; + } + }); + return; + } + public void fixName(final CommandSender sender) { Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { @Override diff --git a/com/gamingmesh/jobs/listeners/.gitignore b/com/gamingmesh/jobs/listeners/.gitignore index 7f04e40a..45b2f50a 100644 --- a/com/gamingmesh/jobs/listeners/.gitignore +++ b/com/gamingmesh/jobs/listeners/.gitignore @@ -7,3 +7,4 @@ /JobsListener$1.class /JobsPaymentListener$2.class /MythicMobsListener.class +/JobsListener$2.class diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index 1091b7a6..35f2f266 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -23,6 +23,7 @@ import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -32,6 +33,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; @@ -115,7 +118,7 @@ public class JobsListener implements Listener { GuiTools.GuiList.remove(player.getName()); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { // make sure plugin is enabled if (!plugin.isEnabled()) @@ -439,11 +442,36 @@ public class JobsListener implements Listener { event.setFormat(format); } - @EventHandler(priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onWorldLoad(WorldLoadEvent event) { World world = event.getWorld(); PluginManager pm = plugin.getServer().getPluginManager(); if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null) pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE)); } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onWaterBlockBreak(BlockFromToEvent event) { + if (!ConfigManager.getJobsConfiguration().WaterBlockBreake) + return; + if (event.getBlock().getType() == Material.STATIONARY_WATER && event.getToBlock().getType() != Material.AIR && event.getToBlock() + .getType() != Material.STATIONARY_WATER && event.getToBlock().getState().hasMetadata( + JobsPaymentListener.PlacedBlockMetadata)) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onCropGrown(final BlockGrowEvent event) { + if (!ConfigManager.getJobsConfiguration().WaterBlockBreake) + return; + if (event.getBlock().getState().hasMetadata(JobsPaymentListener.PlacedBlockMetadata)) { + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() { + public void run() { + event.getBlock().getState().removeMetadata(JobsPaymentListener.PlacedBlockMetadata, plugin); + return; + } + }, 1L); + } + } } diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 0951d909..49624f35 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -89,6 +89,7 @@ public class JobsPaymentListener implements Listener { public final static String brewingOwnerMetadata = "jobsBrewingOwner"; private final String mobSpawnerMetadata = "jobsMobSpawner"; public static final String BlockMetadata = "BlockOwner"; + public static final String PlacedBlockMetadata = "JobsBlockOwner"; public static final String VegyMetadata = "VegyTimer"; public static final String GlobalMetadata = "GlobalTimer"; public static final String CowMetadata = "CowTimer"; @@ -296,11 +297,14 @@ public class JobsPaymentListener implements Listener { if (ConfigManager.getJobsConfiguration().useGlobalTimer) { if (block.getState().hasMetadata(GlobalMetadata)) { long currentTime = System.currentTimeMillis(); - long BlockTime = block.getState().getMetadata(GlobalMetadata).get(0).asLong(); - if (currentTime < BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) { - int sec = Math.round((((BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) - currentTime)) / 1000); - ActionBar.send(player, Language.getMessage("message.blocktimer").replace("[time]", String.valueOf(sec))); - return; + List meta = block.getState().getMetadata(GlobalMetadata); + if (meta.size() > 0) { + long BlockTime = meta.get(0).asLong(); + if (currentTime < BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) { + int sec = Math.round((((BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) - currentTime)) / 1000); + ActionBar.send(player, Language.getMessage("message.blocktimer").replace("[time]", String.valueOf(sec))); + return; + } } } } @@ -377,11 +381,6 @@ public class JobsPaymentListener implements Listener { } } - // Block place/break protection - if (ConfigManager.getJobsConfiguration().useBlockProtection) - if (PistonProtectionListener.CheckBlock(block)) - block.getState().setMetadata(BlockMetadata, new FixedMetadataValue(plugin, true)); - // check if in creative if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) return; @@ -389,6 +388,14 @@ public class JobsPaymentListener implements Listener { if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; + // Block place/break protection + if (ConfigManager.getJobsConfiguration().useBlockProtection) + if (PistonProtectionListener.CheckBlock(block)) + block.getState().setMetadata(BlockMetadata, new FixedMetadataValue(plugin, true)); + + if (ConfigManager.getJobsConfiguration().WaterBlockBreake) + block.getState().setMetadata(PlacedBlockMetadata, new FixedMetadataValue(plugin, true)); + if (ConfigManager.getJobsConfiguration().useBlockTimer) if (PistonProtectionListener.CheckVegy(block)) { long time = System.currentTimeMillis(); diff --git a/com/gamingmesh/jobs/listeners/McMMOlistener.java b/com/gamingmesh/jobs/listeners/McMMOlistener.java index a1a7773c..156e7a20 100644 --- a/com/gamingmesh/jobs/listeners/McMMOlistener.java +++ b/com/gamingmesh/jobs/listeners/McMMOlistener.java @@ -61,7 +61,7 @@ public class McMMOlistener implements Listener { Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO"); if (McMMO != null) { mcMMOPresent = true; - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "mcMMO was found - Enabling capabilities."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6mcMMO was found - Enabling capabilities.")); return true; } return false; diff --git a/com/gamingmesh/jobs/listeners/MythicMobsListener.java b/com/gamingmesh/jobs/listeners/MythicMobsListener.java index 8ab69883..bb0298da 100644 --- a/com/gamingmesh/jobs/listeners/MythicMobsListener.java +++ b/com/gamingmesh/jobs/listeners/MythicMobsListener.java @@ -98,7 +98,7 @@ public class MythicMobsListener implements Listener { Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs"); if (mm != null) { Present = true; - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "MythicMobs was found - Enabling capabilities."); + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities.")); return true; } return false; diff --git a/com/gamingmesh/jobs/tasks/.gitignore b/com/gamingmesh/jobs/tasks/.gitignore index 33a552d6..2152ae68 100644 --- a/com/gamingmesh/jobs/tasks/.gitignore +++ b/com/gamingmesh/jobs/tasks/.gitignore @@ -1,3 +1,5 @@ /BufferedPaymentTask.class /BufferedPaymentThread.class /DatabaseSaveThread.class +/DatabaseSaveThread$1.class +/BufferedPaymentThread$1.class diff --git a/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java b/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java index 3a858eb7..8224718f 100644 --- a/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java +++ b/com/gamingmesh/jobs/tasks/BufferedPaymentTask.java @@ -41,4 +41,4 @@ public class BufferedPaymentTask implements Runnable { } } } -} +} \ No newline at end of file diff --git a/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java b/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java index 5289939f..ae613cab 100644 --- a/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java +++ b/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java @@ -26,48 +26,48 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.economy.BufferedEconomy; public class BufferedPaymentThread extends Thread { - private volatile boolean running = true; - private int sleep; + private volatile boolean running = true; + private int sleep; - public BufferedPaymentThread(int duration) { - super("Jobs-BufferedPaymentThread"); - this.sleep = duration * 1000; - } + public BufferedPaymentThread(int duration) { + super("Jobs-BufferedPaymentThread"); + this.sleep = duration * 1000; + } - @Override - public void run() { + @Override + public void run() { - String message = ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread."); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - console.sendMessage(message); + String message = ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread."); + ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); + console.sendMessage(message); - //Jobs.getPluginLogger().info("Started buffered payment thread"); - while (running) { - try { - sleep(sleep); - } catch (InterruptedException e) { - this.running = false; - continue; - } - try { - BufferedEconomy economy = Jobs.getEconomy(); - if (economy != null) - economy.payAll(); - } catch (Throwable t) { - t.printStackTrace(); - message = ChatColor.translateAlternateColorCodes('&', "&cException in BufferedPaymentThread, stopping economy payments!"); - console.sendMessage(message); - //Jobs.getPluginLogger().severe("Exception in BufferedPaymentThread, stopping economy payments!"); - running = false; - } - } - message = ChatColor.translateAlternateColorCodes('&', "&6Buffered payment thread shutdown."); - console.sendMessage(message); - //Jobs.getPluginLogger().info("Buffered payment thread shutdown"); - } - - public void shutdown() { + //Jobs.getPluginLogger().info("Started buffered payment thread"); + while (running) { + try { + sleep(sleep); + } catch (InterruptedException e) { this.running = false; - interrupt(); + continue; + } + try { + BufferedEconomy economy = Jobs.getEconomy(); + if (economy != null) + economy.payAll(); + } catch (Throwable t) { + t.printStackTrace(); + message = ChatColor.translateAlternateColorCodes('&', "&cException in BufferedPaymentThread, stopping economy payments!"); + console.sendMessage(message); + //Jobs.getPluginLogger().severe("Exception in BufferedPaymentThread, stopping economy payments!"); + running = false; + } } + message = ChatColor.translateAlternateColorCodes('&', "&6Buffered payment thread shutdown."); + console.sendMessage(message); + //Jobs.getPluginLogger().info("Buffered payment thread shutdown"); + } + + public void shutdown() { + this.running = false; + interrupt(); + } } diff --git a/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java b/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java index 2a5930e9..25d507cb 100644 --- a/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java +++ b/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java @@ -25,50 +25,50 @@ import org.bukkit.command.ConsoleCommandSender; import com.gamingmesh.jobs.Jobs; public class DatabaseSaveThread extends Thread { - + private volatile boolean running = true; private int sleep; - + public DatabaseSaveThread(int duration) { - super("Jobs-DatabaseSaveTask"); - this.sleep = duration * 60000; + super("Jobs-DatabaseSaveTask"); + this.sleep = duration * 60000; } @Override public void run() { - //Jobs.getPluginLogger().info("Started database save task"); + //Jobs.getPluginLogger().info("Started database save task"); - String message = ChatColor.translateAlternateColorCodes('&', "&2Started database save task."); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - console.sendMessage(message); - - while (running) { - try { - sleep(sleep); - } catch (InterruptedException e) { - this.running = false; - continue; - } - try { - Jobs.getPlayerManager().saveAll(); - } catch (Throwable t) { - t.printStackTrace(); - //Jobs.getPluginLogger().severe("Exception in DatabaseSaveTask, stopping auto save!"); - message = ChatColor.translateAlternateColorCodes('&', "&cException in DatabaseSaveTask, stopping auto save!"); - console.sendMessage(message); - running = false; - } - } + String message = ChatColor.translateAlternateColorCodes('&', "&2Started database save task."); + ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); + console.sendMessage(message); - message = ChatColor.translateAlternateColorCodes('&', "&6Database save task shutdown!"); + while (running) { + try { + sleep(sleep); + } catch (InterruptedException e) { + this.running = false; + continue; + } + try { + Jobs.getPlayerManager().saveAll(); + } catch (Throwable t) { + t.printStackTrace(); + //Jobs.getPluginLogger().severe("Exception in DatabaseSaveTask, stopping auto save!"); + message = ChatColor.translateAlternateColorCodes('&', "&cException in DatabaseSaveTask, stopping auto save!"); console.sendMessage(message); - - //Jobs.getPluginLogger().info("Database save task shutdown"); - + running = false; + } + } + + message = ChatColor.translateAlternateColorCodes('&', "&6Database save task shutdown!"); + console.sendMessage(message); + + //Jobs.getPluginLogger().info("Database save task shutdown"); + } - + public void shutdown() { - this.running = false; - interrupt(); + this.running = false; + interrupt(); } } diff --git a/plugin.yml b/plugin.yml index 548d43ef..ccbf23f6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.54.5 +version: 2.55.1 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: