Make block 36 removsl configurable
This commit is contained in:
parent
f1661b3918
commit
c4b22575f9
|
@ -19,17 +19,15 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import tc.oc.api.docs.SemanticVersion;
|
||||
import tc.oc.api.util.Permissions;
|
||||
import tc.oc.commons.bukkit.util.BlockVectorSet;
|
||||
import tc.oc.commons.bukkit.util.ChunkPosition;
|
||||
import tc.oc.commons.bukkit.util.NMSHacks;
|
||||
import tc.oc.pgm.events.ListenerScope;
|
||||
import tc.oc.pgm.map.MapProto;
|
||||
import tc.oc.pgm.map.ProtoVersions;
|
||||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchModule;
|
||||
import tc.oc.pgm.match.MatchScope;
|
||||
import tc.oc.pgm.terrain.TerrainOptions;
|
||||
|
||||
@ListenerScope(MatchScope.LOADED)
|
||||
public class WorldProblemMatchModule extends MatchModule implements Listener {
|
||||
|
@ -39,7 +37,7 @@ public class WorldProblemMatchModule extends MatchModule implements Listener {
|
|||
private final Set<ChunkPosition> repairedChunks = new HashSet<>();
|
||||
private final BlockVectorSet block36Locations = new BlockVectorSet();
|
||||
|
||||
@Inject private @MapProto SemanticVersion proto;
|
||||
@Inject private TerrainOptions options;
|
||||
@Inject private World world;
|
||||
|
||||
@Inject WorldProblemMatchModule(Match match) {
|
||||
|
@ -68,6 +66,8 @@ public class WorldProblemMatchModule extends MatchModule implements Listener {
|
|||
for(Chunk chunk : world.getLoadedChunks()) {
|
||||
checkChunk(chunk);
|
||||
}
|
||||
if (!options.remove36())
|
||||
broadcastDeveloperWarning("Block 36 will NOT be removed! This can cause lag.");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
@ -103,7 +103,7 @@ public class WorldProblemMatchModule extends MatchModule implements Listener {
|
|||
ironDoor.setType(Material.BARRIER, false);
|
||||
}
|
||||
}
|
||||
if (proto.isOlderThan(ProtoVersions.ENABLE_BLOCK_36)) {
|
||||
if (options.remove36()) {
|
||||
// Remove all block 36 and remember the ones at y=0 so VoidFilter can check them
|
||||
for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) {
|
||||
if(block36.getY() == 0) {
|
||||
|
|
|
@ -11,12 +11,14 @@ public class TerrainOptions implements WorldConfigurator {
|
|||
private final boolean vanilla;
|
||||
private final long seed;
|
||||
private final boolean initialPhysics;
|
||||
private final boolean remove36;
|
||||
|
||||
public TerrainOptions(Path worldFolder, boolean vanilla, Long seed, boolean initialPhysics) {
|
||||
public TerrainOptions(Path worldFolder, boolean vanilla, Long seed, boolean initialPhysics, boolean remove36) {
|
||||
this.worldFolder = worldFolder;
|
||||
this.vanilla = vanilla;
|
||||
this.seed = seed != null ? seed : new Random().nextLong();
|
||||
this.initialPhysics = initialPhysics;
|
||||
this.remove36 = remove36;
|
||||
}
|
||||
|
||||
public Path worldFolder() {
|
||||
|
@ -27,6 +29,10 @@ public class TerrainOptions implements WorldConfigurator {
|
|||
return initialPhysics;
|
||||
}
|
||||
|
||||
public boolean remove36() {
|
||||
return remove36;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureWorld(WorldCreator worldCreator) {
|
||||
worldCreator.generator(vanilla ? null : new NullChunkGenerator());
|
||||
|
|
|
@ -6,7 +6,10 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
import tc.oc.api.docs.SemanticVersion;
|
||||
import tc.oc.pgm.map.MapFolder;
|
||||
import tc.oc.pgm.map.MapProto;
|
||||
import tc.oc.pgm.map.ProtoVersions;
|
||||
import tc.oc.pgm.utils.XMLUtils;
|
||||
import tc.oc.pgm.xml.InvalidXMLException;
|
||||
import tc.oc.pgm.xml.Node;
|
||||
|
@ -16,10 +19,12 @@ public class TerrainParser implements ElementParser<TerrainOptions> {
|
|||
|
||||
private final MapFolder mapFolder;
|
||||
private final Document doc;
|
||||
private final SemanticVersion proto;
|
||||
|
||||
@Inject private TerrainParser(MapFolder mapFolder, Document doc) {
|
||||
@Inject private TerrainParser(MapFolder mapFolder, Document doc, @MapProto SemanticVersion proto) {
|
||||
this.mapFolder = mapFolder;
|
||||
this.doc = doc;
|
||||
this.proto = proto;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,11 +39,13 @@ public class TerrainParser implements ElementParser<TerrainOptions> {
|
|||
boolean vanilla = false;
|
||||
Long seed = null;
|
||||
boolean initialPhysics = false;
|
||||
boolean remove36 = proto.isOlderThan(ProtoVersions.ENABLE_BLOCK_36);
|
||||
|
||||
for(Element elTerrain : doc.getRootElement().getChildren("terrain")) {
|
||||
vanilla = XMLUtils.parseBoolean(elTerrain.getAttribute("vanilla"), vanilla);
|
||||
worldFolder = XMLUtils.parseRelativeFolder(worldFolder, Node.fromAttr(elTerrain, "world"), worldFolder);
|
||||
initialPhysics = XMLUtils.parseBoolean(elTerrain.getAttribute("pre-match-physics"), initialPhysics);
|
||||
remove36 = XMLUtils.parseBoolean(elTerrain.getAttribute("remove-36"), remove36);
|
||||
|
||||
String seedText = elTerrain.getAttributeValue("seed");
|
||||
if(seedText != null) {
|
||||
|
@ -50,6 +57,6 @@ public class TerrainParser implements ElementParser<TerrainOptions> {
|
|||
}
|
||||
}
|
||||
|
||||
return new TerrainOptions(worldFolder, vanilla, seed, initialPhysics);
|
||||
return new TerrainOptions(worldFolder, vanilla, seed, initialPhysics, remove36);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue