Decreased the impact Lava Plumes had on server performance.

testdev
sigonasr2 8 years ago
parent 03876eec32
commit f3fdcdfc38
  1. BIN
      TwosideKeeper.jar
  2. 3
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 56
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/BlockModifyQueue.java
  4. 11
      src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java
  5. 7
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  6. 15
      src/sig/plugin/TwosideKeeper/runServerTick.java

Binary file not shown.

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

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

@ -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);
}
}
@ -36,12 +38,7 @@ 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() {

@ -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<String> log_messages=new ArrayList<String>();
public static List<TemporaryLava> temporary_lava_list = new ArrayList<TemporaryLava>();
public static List<Chunk> temporary_chunks = new ArrayList<Chunk>();
public static List<BlockModifyQueue> blockqueue = new ArrayList<BlockModifyQueue>();
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);
}

@ -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();
}
}
}
Loading…
Cancel
Save