mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Added optional WorldEdit processing to reduce likelyhood of server crashes
This commit is contained in:
parent
23b9b408b4
commit
550cf87adf
@ -0,0 +1,105 @@
|
||||
package com.intellectualcrafters.plot.listeners.worldedit;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
private final HashSet<RegionWrapper> mask;
|
||||
int BScount = 0;
|
||||
int Ecount = 0;
|
||||
boolean BSblocked = false;
|
||||
boolean Eblocked = false;
|
||||
|
||||
public ProcessedWEExtent(HashSet<RegionWrapper> mask, Extent extent) {
|
||||
super(extent);
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||
switch (block.getType()) {
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
case 27:
|
||||
case 137:
|
||||
case 52:
|
||||
case 154:
|
||||
case 84:
|
||||
case 25:
|
||||
case 144:
|
||||
case 138:
|
||||
case 176:
|
||||
case 177:
|
||||
case 63:
|
||||
case 68:
|
||||
case 323:
|
||||
case 117:
|
||||
case 116:
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
case 61:
|
||||
case 62:
|
||||
case 140:
|
||||
case 146:
|
||||
case 149:
|
||||
case 150:
|
||||
case 158:
|
||||
case 23:
|
||||
case 123:
|
||||
case 124:
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
if (BSblocked) {
|
||||
return false;
|
||||
}
|
||||
BScount++;
|
||||
if (BScount > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) {
|
||||
BSblocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
if (Eblocked) {
|
||||
return null;
|
||||
}
|
||||
Ecount++;
|
||||
if (Ecount > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
|
||||
Eblocked = true;
|
||||
}
|
||||
if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
|
||||
return super.createEntity(location, entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
if (WEListener.maskContains(mask, position.getBlockX(), position.getBlockZ())) {
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -72,7 +72,12 @@ public class WEListener implements Listener {
|
||||
return;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {}
|
||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
event.setExtent(new ProcessedWEExtent(mask, event.getExtent()));
|
||||
}
|
||||
else {
|
||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user