diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 4bc9f34..3d1858f 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 6f42b45..ce3deb1 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -1245,6 +1245,9 @@ public class CustomDamage { * @return Returns true if the target cannot be hit. False otherwise. */ static public boolean InvulnerableCheck(Entity damager, LivingEntity target, String reason, int flags) { + if (target.isDead()) { + return true; //Cancel all damage events if they are dead. + } target.setLastDamage(0); target.setNoDamageTicks(0); target.setMaximumNoDamageTicks(0); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BlockModifyQueue.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BlockModifyQueue.java new file mode 100644 index 0000000..820a771 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/BlockModifyQueue.java @@ -0,0 +1,56 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Common; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; + +public class BlockModifyQueue{ + Material checktype; //The material the block should be before converting. + Material finaltype; //The material the block is converting into. + byte checkdata; //Data the block should be before converting. + byte finaldata; //Data the block should be after converting. + boolean usedata=false; + Block b; //The block we are converting. + + public BlockModifyQueue(Block b, Material checktype, Material finaltype) { + this.b=b; + this.checktype=checktype; + this.finaltype=finaltype; + this.checkdata=0; + this.finaldata=0; + this.usedata=false; + } + + public BlockModifyQueue(Block b, Material checktype, byte checkdata, Material finaltype, byte finaldata) { + this.b=b; + this.checktype=checktype; + this.finaltype=finaltype; + this.checkdata=0; + this.finaldata=0; + this.usedata=true; + } + + public void run() { + if ((TypeException(b) || b.getType()==checktype) && (!usedata || b.getData()==checkdata)) { + b.setType(finaltype); + if (usedata) {b.setData(finaldata);} + } + } + + private boolean TypeException(Block b) { + if (b.getType()==Material.STATIONARY_LAVA || b.getType()==Material.LAVA || + b.getType()==Material.STATIONARY_WATER || b.getType()==Material.WATER) { + return true; + } else { + return false; + } + } + + public static void Cleanup(List queue) { + for (BlockModifyQueue bmq: queue) { + bmq.run(); + } + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java index d8659e7..771556b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; public class TemporaryLava { Block b; @@ -18,7 +19,8 @@ public class TemporaryLava { public TemporaryLava(Block b, int timer, boolean convert) { if (convert) { if (b.getType()==Material.AIR) { - b.setType(Material.LAVA); + //b.setType(Material.LAVA); + TwosideKeeper.blockqueue.add(new BlockModifyQueue(b,Material.AIR,Material.LAVA)); //b.setData((byte)8); } } @@ -35,13 +37,8 @@ public class TemporaryLava { } } private void ResetBlock() { - if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { - b.setType(Material.AIR); - } - } - private void ClearLavaBlock(Block b2) { if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { - b.setType(Material.AIR); + TwosideKeeper.blockqueue.add(new BlockModifyQueue(b,b.getType(),Material.AIR)); } } public void Cleanup() { diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index b37aa1c..dfc77ef 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -191,6 +191,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession; import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver; +import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory; @@ -411,6 +412,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static List log_messages=new ArrayList(); public static List temporary_lava_list = new ArrayList(); public static List temporary_chunks = new ArrayList(); + public static List blockqueue = new ArrayList(); long LastClearStructureTime = 0; public int TeamCounter = 0; @@ -842,6 +844,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //This is the constant timing method. getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerTick(), 1l, 1l); //log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0); } @@ -886,6 +889,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { temporary_chunks.clear(); log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG); betweentime = System.currentTimeMillis(); + log("Cleaning up Block Queue ["+blockqueue.size()+"]",CLEANUP_DEBUG); + BlockModifyQueue.Cleanup(blockqueue); + log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG); + betweentime = System.currentTimeMillis(); long endtime = System.currentTimeMillis(); log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG); } diff --git a/src/sig/plugin/TwosideKeeper/runServerTick.java b/src/sig/plugin/TwosideKeeper/runServerTick.java new file mode 100644 index 0000000..5e91869 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/runServerTick.java @@ -0,0 +1,15 @@ +package sig.plugin.TwosideKeeper; + +import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; + +public class runServerTick implements Runnable{ + + @Override + public void run() { + if (TwosideKeeper.blockqueue.size()>0) { + BlockModifyQueue bmq = TwosideKeeper.blockqueue.remove(0); + bmq.run(); + } + } + +}