1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-17 05:31:19 +01:00

prevent water breaking blocks / small fixes

This commit is contained in:
Zrips 2016-01-04 13:44:18 +02:00
parent 73ed579dcb
commit 5c715e35f8
17 changed files with 235 additions and 96 deletions

View File

@ -1,5 +1,5 @@
#Generated by Maven #Generated by Maven
#Wed Aug 20 21:00:44 EDT 2014 #Wed Aug 20 21:00:44 EDT 2014
version=2.13-SNAPSHOT version=2.55-SNAPSHOT
groupId=com.gamingmesh groupId=com.gamingmesh
artifactId=jobs artifactId=jobs

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gamingmesh</groupId> <groupId>com.gamingmesh</groupId>
<artifactId>jobs</artifactId> <artifactId>jobs</artifactId>
<version>2.13-SNAPSHOT</version> <version>2.55-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Jobs</name> <name>Jobs</name>
<description>Jobs Plugin for the BukkitAPI</description> <description>Jobs Plugin for the BukkitAPI</description>

View File

@ -157,7 +157,7 @@ public class JobsPlugin extends JavaPlugin {
ScheduleUtil.scheduler(); ScheduleUtil.scheduler();
ScheduleUtil.DateUpdater(); 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(); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message); console.sendMessage(message);
} }
@ -166,7 +166,7 @@ public class JobsPlugin extends JavaPlugin {
public void onDisable() { public void onDisable() {
GuiTools.CloseInventories(); GuiTools.CloseInventories();
Jobs.shutdown(); 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(); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message); console.sendMessage(message);
} }

View File

@ -173,9 +173,22 @@ public class JobsCommands implements CommandExecutor {
return true; 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); 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; return true;
} }
@ -1417,8 +1430,12 @@ public class JobsCommands implements CommandExecutor {
List<Log> logList = JPlayer.getLog(); List<Log> 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; return true;
}
Map<String, Double> unsortMap = new HashMap<String, Double>(); Map<String, Double> unsortMap = new HashMap<String, Double>();
@ -1442,7 +1459,7 @@ public class JobsCommands implements CommandExecutor {
String msg = Language.getMessage("command.log.output.list") String msg = Language.getMessage("command.log.output.list")
.replace("%number%", String.valueOf(count)) .replace("%number%", String.valueOf(count))
.replace("%action%", one.getActionType()) .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("%qty%", String.valueOf(oneMap.getValue().getCount()))
.replace("%money%", String.valueOf(oneMap.getValue().getMoney())) .replace("%money%", String.valueOf(oneMap.getValue().getMoney()))
.replace("%exp%", String.valueOf(oneMap.getValue().getExp())); .replace("%exp%", String.valueOf(oneMap.getValue().getExp()));
@ -1523,7 +1540,7 @@ public class JobsCommands implements CommandExecutor {
break; break;
} }
if (unsortMap.size() == 0) { 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")); sender.sendMessage(Language.getMessage("command.glog.output.bottomline"));

View File

@ -74,7 +74,7 @@ public class JobsConfiguration {
public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled, public boolean EconomyLimitUse, EconomyExpLimitUse, PayForRenaming, PayForEachCraft, SignsEnabled,
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse,
EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop, EnableAnounceMessage, useBlockPiston, useSilkTouchProtection, UseCustomNames, EconomyMoneyStop,
EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit; EconomyExpStop, UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, WaterBlockBreake;
public int EconomyLimitTimeLimit, EconomyExpTimeLimit; public int EconomyLimitTimeLimit, EconomyExpTimeLimit;
public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer, public int EconomyLimitAnnouncmentDelay, EconomyLimitAnnouncmentExpDelay, globalblocktimer, CowMilkingTimer,
CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval;
@ -611,6 +611,11 @@ public class JobsConfiguration {
writer.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner"); writer.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner");
PreventMagmaCubeSplit = getBoolean("ExploitProtections.Spawner.PreventMagmaCubeSplit", true, config, writer); 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.", writer.addComment("use-breeder-finder", "Breeder finder.",
"If you are not using breeding payment, you can disable this to save little resources. Really little."); "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); useBreederFinder = getBoolean("use-breeder-finder", true, config, writer);
@ -946,6 +951,35 @@ public class JobsConfiguration {
restrictedPlaceBlocksTimer = (ArrayList<Integer>) config.getIntegerList("PlacedBlockTimer"); restrictedPlaceBlocksTimer = (ArrayList<Integer>) config.getIntegerList("PlacedBlockTimer");
copySetting(config, writer, "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<Integer>) config.getIntegerList("PlacedBlockTimer");
copySetting(config, writer, "PlacedBlockTimer");
try { try {
writer.save(f); writer.save(f);
} catch (IOException e) { } catch (IOException e) {
@ -1378,6 +1412,7 @@ public class JobsConfiguration {
GetConfigString("command.log.output.bottomline", "&7***********************************************************", writer, conf, true); 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.prev", "&e<<<<< Prev page &2|", writer, conf, true);
GetConfigString("command.log.output.next", "&2|&e Next Page >>>>", 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.info", "Shows global statistics.", writer, conf, true);
GetConfigString("command.glog.help.args", "", 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, GetConfigString("command.glog.output.list", "&7* &6%number%. &3%username% &e%action%: &6%item% &eqty: %qty% &6money: %money% &eexp: %exp%", writer, conf,
true); true);
GetConfigString("command.glog.output.bottomline", "&7**************************************************************", 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.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); GetConfigString("command.transfer.help.args", "[playername] [oldjob] [newjob]", writer, conf, true);

View File

@ -9,3 +9,4 @@
/JobsDriver.class /JobsDriver.class
/JobsDrivers.class /JobsDrivers.class
/JobsDAO$1.class /JobsDAO$1.class
/JobsDAO$2.class

View File

@ -491,6 +491,53 @@ public abstract class JobsDAO {
return null; 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<String, String> convert = new HashMap<String, String>();
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<String, String> 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) { public void fixName(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
@Override @Override

View File

@ -7,3 +7,4 @@
/JobsListener$1.class /JobsListener$1.class
/JobsPaymentListener$2.class /JobsPaymentListener$2.class
/MythicMobsListener.class /MythicMobsListener.class
/JobsListener$2.class

View File

@ -23,6 +23,7 @@ import java.util.regex.Pattern;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -32,6 +33,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; 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.block.SignChangeEvent;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -115,7 +118,7 @@ public class JobsListener implements Listener {
GuiTools.GuiList.remove(player.getName()); GuiTools.GuiList.remove(player.getName());
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
// make sure plugin is enabled // make sure plugin is enabled
if (!plugin.isEnabled()) if (!plugin.isEnabled())
@ -439,11 +442,36 @@ public class JobsListener implements Listener {
event.setFormat(format); event.setFormat(format);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent event) { public void onWorldLoad(WorldLoadEvent event) {
World world = event.getWorld(); World world = event.getWorld();
PluginManager pm = plugin.getServer().getPluginManager(); PluginManager pm = plugin.getServer().getPluginManager();
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null) if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE)); 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);
}
}
} }

View File

@ -89,6 +89,7 @@ public class JobsPaymentListener implements Listener {
public final static String brewingOwnerMetadata = "jobsBrewingOwner"; public final static String brewingOwnerMetadata = "jobsBrewingOwner";
private final String mobSpawnerMetadata = "jobsMobSpawner"; private final String mobSpawnerMetadata = "jobsMobSpawner";
public static final String BlockMetadata = "BlockOwner"; public static final String BlockMetadata = "BlockOwner";
public static final String PlacedBlockMetadata = "JobsBlockOwner";
public static final String VegyMetadata = "VegyTimer"; public static final String VegyMetadata = "VegyTimer";
public static final String GlobalMetadata = "GlobalTimer"; public static final String GlobalMetadata = "GlobalTimer";
public static final String CowMetadata = "CowTimer"; public static final String CowMetadata = "CowTimer";
@ -296,11 +297,14 @@ public class JobsPaymentListener implements Listener {
if (ConfigManager.getJobsConfiguration().useGlobalTimer) { if (ConfigManager.getJobsConfiguration().useGlobalTimer) {
if (block.getState().hasMetadata(GlobalMetadata)) { if (block.getState().hasMetadata(GlobalMetadata)) {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long BlockTime = block.getState().getMetadata(GlobalMetadata).get(0).asLong(); List<MetadataValue> meta = block.getState().getMetadata(GlobalMetadata);
if (currentTime < BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) { if (meta.size() > 0) {
int sec = Math.round((((BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) - currentTime)) / 1000); long BlockTime = meta.get(0).asLong();
ActionBar.send(player, Language.getMessage("message.blocktimer").replace("[time]", String.valueOf(sec))); if (currentTime < BlockTime + ConfigManager.getJobsConfiguration().globalblocktimer * 1000) {
return; 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 // check if in creative
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative()) if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
return; return;
@ -389,6 +388,14 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
return; 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 (ConfigManager.getJobsConfiguration().useBlockTimer)
if (PistonProtectionListener.CheckVegy(block)) { if (PistonProtectionListener.CheckVegy(block)) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

View File

@ -61,7 +61,7 @@ public class McMMOlistener implements Listener {
Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO"); Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
if (McMMO != null) { if (McMMO != null) {
mcMMOPresent = true; 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 true;
} }
return false; return false;

View File

@ -98,7 +98,7 @@ public class MythicMobsListener implements Listener {
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs"); Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
if (mm != null) { if (mm != null) {
Present = true; 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 true;
} }
return false; return false;

View File

@ -1,3 +1,5 @@
/BufferedPaymentTask.class /BufferedPaymentTask.class
/BufferedPaymentThread.class /BufferedPaymentThread.class
/DatabaseSaveThread.class /DatabaseSaveThread.class
/DatabaseSaveThread$1.class
/BufferedPaymentThread$1.class

View File

@ -26,48 +26,48 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.economy.BufferedEconomy; import com.gamingmesh.jobs.economy.BufferedEconomy;
public class BufferedPaymentThread extends Thread { public class BufferedPaymentThread extends Thread {
private volatile boolean running = true; private volatile boolean running = true;
private int sleep; private int sleep;
public BufferedPaymentThread(int duration) { public BufferedPaymentThread(int duration) {
super("Jobs-BufferedPaymentThread"); super("Jobs-BufferedPaymentThread");
this.sleep = duration * 1000; this.sleep = duration * 1000;
} }
@Override @Override
public void run() { public void run() {
String message = ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread."); String message = ChatColor.translateAlternateColorCodes('&', "&2Started buffered payment thread.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message); console.sendMessage(message);
//Jobs.getPluginLogger().info("Started buffered payment thread"); //Jobs.getPluginLogger().info("Started buffered payment thread");
while (running) { while (running) {
try { try {
sleep(sleep); sleep(sleep);
} catch (InterruptedException e) { } 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() {
this.running = false; 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();
}
} }

View File

@ -30,45 +30,45 @@ public class DatabaseSaveThread extends Thread {
private int sleep; private int sleep;
public DatabaseSaveThread(int duration) { public DatabaseSaveThread(int duration) {
super("Jobs-DatabaseSaveTask"); super("Jobs-DatabaseSaveTask");
this.sleep = duration * 60000; this.sleep = duration * 60000;
} }
@Override @Override
public void run() { 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."); String message = ChatColor.translateAlternateColorCodes('&', "&2Started database save task.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); 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); console.sendMessage(message);
running = false;
}
}
while (running) { message = ChatColor.translateAlternateColorCodes('&', "&6Database save task shutdown!");
try { console.sendMessage(message);
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;
}
}
message = ChatColor.translateAlternateColorCodes('&', "&6Database save task shutdown!"); //Jobs.getPluginLogger().info("Database save task shutdown");
console.sendMessage(message);
//Jobs.getPluginLogger().info("Database save task shutdown");
} }
public void shutdown() { public void shutdown() {
this.running = false; this.running = false;
interrupt(); interrupt();
} }
} }

View File

@ -1,7 +1,7 @@
name: Jobs name: Jobs
description: Jobs Plugin for the BukkitAPI description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin main: com.gamingmesh.jobs.JobsPlugin
version: 2.54.5 version: 2.55.1
author: phrstbrn author: phrstbrn
softdepend: [Vault, CoreProtect, MythicMobs, McMMO] softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
commands: commands: