Fix Region.Area.reset
This commit is contained in:
@@ -29,12 +29,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class DesignEndStone {
|
||||
|
||||
@@ -44,8 +42,8 @@ public class DesignEndStone {
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
private List<REntity> entities = new ArrayList<>();
|
||||
private Set<Location> locations = new HashSet<>();
|
||||
private boolean wsOrAs;
|
||||
private double maxBlastResistance;
|
||||
private Set<Material> limited = new HashSet<>();
|
||||
private boolean calculateFromBottom;
|
||||
|
||||
public DesignEndStone(Region region) {
|
||||
this.minX = region.getBuildArea().getMinPoint(false).getX();
|
||||
@@ -54,8 +52,18 @@ public class DesignEndStone {
|
||||
this.maxX = region.getBuildArea().getMaxPoint(false).getX();
|
||||
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
||||
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
||||
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
|
||||
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
|
||||
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(region.getGameModeConfig().get());
|
||||
for(Map<?, ?> entry : config.getMapList("Schematic.Limited")) {
|
||||
int amount = (Integer) entry.get("Amount");
|
||||
Set<String> materials = new HashSet<>((List<String>) entry.get("Materials"));
|
||||
if(amount == 0) {
|
||||
materials.forEach(s -> {
|
||||
limited.add(Material.getMaterial(s));
|
||||
});
|
||||
}
|
||||
}
|
||||
calculateFromBottom = config.getBoolean("Arena.NoFloor", false);
|
||||
|
||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||
@@ -76,7 +84,7 @@ public class DesignEndStone {
|
||||
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
||||
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
||||
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
||||
if (wsOrAs) {
|
||||
if (calculateFromBottom) {
|
||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||
} else {
|
||||
int airBlocks = 0;
|
||||
@@ -106,7 +114,7 @@ public class DesignEndStone {
|
||||
int cz = z + step * dirZ;
|
||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||
|
||||
if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) {
|
||||
if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) {
|
||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||
if (!locations.add(location)) break;
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||
|
||||
@@ -52,6 +52,10 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||
return;
|
||||
}
|
||||
if (region.getGameModeConfig().isEmpty()) {
|
||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||
return;
|
||||
}
|
||||
designEndStoneMap.computeIfAbsent(region, DesignEndStone::new).toggle(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -96,7 +95,7 @@ public interface Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(@Nullable SchematicNode schematicNode, boolean extension) {
|
||||
public void reset(PasteBuilder pasteBuilder, boolean extension) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +122,7 @@ public interface Region {
|
||||
|
||||
EditSession copy(boolean extension);
|
||||
|
||||
void reset(@Nullable SchematicNode schematicNode, boolean extension);
|
||||
void reset(PasteBuilder pasteBuilder, boolean extension);
|
||||
|
||||
void forEachChunk(BiConsumer<Integer, Integer> executor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user