diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index be61d612..de260c1f 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -79,6 +79,7 @@ import com.gamingmesh.jobs.listeners.McMMOlistener; import com.gamingmesh.jobs.listeners.MythicMobsListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.stuff.ActionBar; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.JobsClassLoader; import com.gamingmesh.jobs.stuff.Loging; import com.gamingmesh.jobs.stuff.TabComplete; @@ -807,6 +808,9 @@ public class Jobs extends JavaPlugin { if (jobinfo == null) return; + if (!isBpOk(jPlayer.getPlayer(), info.getType(), block, true)) + return; + Double income = jobinfo.getIncome(1, numjobs); Double pointAmount = jobinfo.getPoints(1, numjobs); @@ -851,9 +855,6 @@ public class Jobs extends JavaPlugin { income = 0D; } - if (!isBpOk(jPlayer, info, block)) - return; - if (income == 0D && pointAmount == 0D) return; @@ -876,7 +877,8 @@ public class Jobs extends JavaPlugin { if (jobinfo == null) continue; - + if (!isBpOk(jPlayer.getPlayer(), info.getType(), block, true)) + return; Double income = jobinfo.getIncome(level, numjobs); Double pointAmount = jobinfo.getPoints(level, numjobs); Double expAmount = jobinfo.getExperience(level, numjobs); @@ -972,9 +974,6 @@ public class Jobs extends JavaPlugin { expAmount = 0D; } - if (!isBpOk(jPlayer, info, block)) - return; - if (income == 0D && pointAmount == 0D && expAmount == 0D) continue; @@ -1009,14 +1008,14 @@ public class Jobs extends JavaPlugin { if (prog.addExperience(expAmount)) pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel); - + break; } } } - private static boolean isBpOk(JobsPlayer jPlayer, ActionInfo info, Block block) { + private static boolean isBpOk(Player player, ActionType type, Block block, boolean inform) { if (block != null && Jobs.getGCManager().useBlockProtection) { - if (info.getType() == ActionType.BREAK) { + if (type == ActionType.BREAK) { BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation()); if (bp != null) { @@ -1025,9 +1024,15 @@ public class Jobs extends JavaPlugin { return false; Integer cd = Jobs.getBpManager().getBlockDelayTime(block); - if (time > System.currentTimeMillis() && bp.isPaid() && bp.getAction() != DBAction.DELETE) { + if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) { + Jobs.getBpManager().remove(block); + return true; + } + + if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) { int sec = Math.round((time - System.currentTimeMillis()) / 1000); - Jobs.getActionBar().send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); + if (inform) + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); return false; } @@ -1042,14 +1047,27 @@ public class Jobs extends JavaPlugin { Jobs.getBpManager().add(block, System.currentTimeMillis() + (Jobs.getGCManager().globalblocktimer * 1000)); } } - } else if (info.getType() == ActionType.PLACE) { + } else if (type == ActionType.PLACE) { + Debug.D("place"); BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation()); if (bp != null) { + Debug.D("bpp not null here"); Long time = bp.getTime(); if (time != -1) { - if (time > System.currentTimeMillis() && bp.isPaid() && bp.getAction() != DBAction.DELETE) { + + Debug.D("time is " + (time < System.currentTimeMillis())); + if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) { + Jobs.getBpManager().remove(block); + return true; + } + + Debug.D("place " + ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE)); + + if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) { + Debug.D("here mufyn"); int sec = Math.round((time - System.currentTimeMillis()) / 1000); - Jobs.getActionBar().send(jPlayer.getPlayer(), Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); + if (inform) + Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec)); return false; } } else if (bp.isPaid()) { @@ -1261,7 +1279,7 @@ public class Jobs extends JavaPlugin { return true; } - public static void consoleMsg(String msg){ + public static void consoleMsg(String msg) { Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg)); } } diff --git a/com/gamingmesh/jobs/commands/list/bp.java b/com/gamingmesh/jobs/commands/list/bp.java index 538c661e..790c58fd 100644 --- a/com/gamingmesh/jobs/commands/list/bp.java +++ b/com/gamingmesh/jobs/commands/list/bp.java @@ -40,12 +40,12 @@ public class bp implements Cmd { BlockProtection bp = Jobs.getBpManager().getBp(l); if (bp != null) { Long time = bp.getTime(); - if (bp.getAction() == DBAction.DELETE) - continue; - if (time != -1 && time < System.currentTimeMillis()) { - Jobs.getBpManager().remove(l); - continue; - } +// if (bp.getAction() == DBAction.DELETE) +// continue; +// if (time != -1 && time < System.currentTimeMillis()) { +// Jobs.getBpManager().remove(l); +// continue; +// } changedBlocks.add(l.getBlock()); if (time == -1) player.sendBlockChange(l, Material.STAINED_GLASS, (byte) 15); diff --git a/com/gamingmesh/jobs/config/BlockProtectionManager.java b/com/gamingmesh/jobs/config/BlockProtectionManager.java index 73d221f0..b64bf6e6 100644 --- a/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -13,6 +13,7 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.BlockProtection; import com.gamingmesh.jobs.container.DBAction; import com.gamingmesh.jobs.listeners.JobsPaymentListener; +import com.gamingmesh.jobs.stuff.Debug; public class BlockProtectionManager { @@ -54,6 +55,7 @@ public class BlockProtectionManager { } public void add(Block block, Integer cd, boolean paid) { + Debug.D("cd: " +cd); if (cd == null) return; if (cd != -1) @@ -97,6 +99,7 @@ public class BlockProtectionManager { chunks.put(chunk, Bpm); regions.put(region, chunks); map.put(loc.getWorld(), regions); + Debug.D("added new " + Bp.getAction()); return Bp; } diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 45ef0310..2641a403 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -78,11 +78,13 @@ import com.gamingmesh.jobs.actions.ItemActionInfo; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.BlockProtection; +import com.gamingmesh.jobs.container.DBAction; import com.gamingmesh.jobs.container.ExploreRespond; import com.gamingmesh.jobs.container.FastPayment; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.google.common.base.Objects; public class JobsPaymentListener implements Listener { @@ -329,8 +331,11 @@ public class JobsPaymentListener implements Listener { if (Jobs.getGCManager().useBlockProtection) { BlockProtection bp = Jobs.getBpManager().getBp(block.getLocation()); - if (bp == null) + Debug.D("bp is null " + (bp == null)); + if (bp == null || bp.getAction() == DBAction.DELETE) Jobs.getBpManager().add(block, Jobs.getBpManager().getBlockDelayTime(block), false); +// else +// Debug.D("bp is " + bp.getId()); } JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);