Decreased the impact Lava Plumes had on server performance.

This commit is contained in:
sigonasr2 2016-12-19 22:31:32 -06:00
parent 03876eec32
commit f3fdcdfc38
6 changed files with 85 additions and 7 deletions

Binary file not shown.

View File

@ -1245,6 +1245,9 @@ public class CustomDamage {
* @return Returns true if the target cannot be hit. False otherwise. * @return Returns true if the target cannot be hit. False otherwise.
*/ */
static public boolean InvulnerableCheck(Entity damager, LivingEntity target, String reason, int flags) { 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.setLastDamage(0);
target.setNoDamageTicks(0); target.setNoDamageTicks(0);
target.setMaximumNoDamageTicks(0); target.setMaximumNoDamageTicks(0);

View File

@ -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<BlockModifyQueue> queue) {
for (BlockModifyQueue bmq: queue) {
bmq.run();
}
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue;
public class TemporaryLava { public class TemporaryLava {
Block b; Block b;
@ -18,7 +19,8 @@ public class TemporaryLava {
public TemporaryLava(Block b, int timer, boolean convert) { public TemporaryLava(Block b, int timer, boolean convert) {
if (convert) { if (convert) {
if (b.getType()==Material.AIR) { 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); //b.setData((byte)8);
} }
} }
@ -36,12 +38,7 @@ public class TemporaryLava {
} }
private void ResetBlock() { private void ResetBlock() {
if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) {
b.setType(Material.AIR); TwosideKeeper.blockqueue.add(new BlockModifyQueue(b,b.getType(),Material.AIR));
}
}
private void ClearLavaBlock(Block b2) {
if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) {
b.setType(Material.AIR);
} }
} }
public void Cleanup() { public void Cleanup() {

View File

@ -191,6 +191,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession; import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession;
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver; 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.GenericFunctions;
import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation; import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation;
import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory;
@ -411,6 +412,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static List<String> log_messages=new ArrayList<String>(); public static List<String> log_messages=new ArrayList<String>();
public static List<TemporaryLava> temporary_lava_list = new ArrayList<TemporaryLava>(); public static List<TemporaryLava> temporary_lava_list = new ArrayList<TemporaryLava>();
public static List<Chunk> temporary_chunks = new ArrayList<Chunk>(); public static List<Chunk> temporary_chunks = new ArrayList<Chunk>();
public static List<BlockModifyQueue> blockqueue = new ArrayList<BlockModifyQueue>();
long LastClearStructureTime = 0; long LastClearStructureTime = 0;
public int TeamCounter = 0; public int TeamCounter = 0;
@ -842,6 +844,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//This is the constant timing method. //This is the constant timing method.
getServer().getScheduler().scheduleSyncRepeatingTask(this, new runServerHeartbeat(this), 20l, 20l); 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); //log(Calendar.getInstance().get(Calendar.DAY_OF_WEEK)+"",0);
} }
@ -886,6 +889,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
temporary_chunks.clear(); temporary_chunks.clear();
log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG); log(ChatColor.YELLOW+" "+(System.currentTimeMillis()-betweentime)+"ms",CLEANUP_DEBUG);
betweentime = System.currentTimeMillis(); 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(); long endtime = System.currentTimeMillis();
log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG); log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG);
} }

View File

@ -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();
}
}
}