Fix Region
Dieser Commit ist enthalten in:
Ursprung
7ef027c921
Commit
06d3393c44
@ -42,7 +42,7 @@ public class Region {
|
||||
private static boolean buildArea = false;
|
||||
private static boolean extensionArea = false;
|
||||
|
||||
static{
|
||||
static {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
|
||||
@ -52,13 +52,13 @@ public class Region {
|
||||
|
||||
ConfigurationSection prototypes = config.getConfigurationSection("prototypes");
|
||||
assert prototypes != null;
|
||||
for(String prototype : prototypes.getKeys(false)){
|
||||
for (String prototype : prototypes.getKeys(false)) {
|
||||
new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype)));
|
||||
}
|
||||
|
||||
ConfigurationSection regions = config.getConfigurationSection("regions");
|
||||
assert regions != null;
|
||||
for(String region : regions.getKeys(false)){
|
||||
for (String region : regions.getKeys(false)) {
|
||||
new Region(Objects.requireNonNull(regions.getConfigurationSection(region)));
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class Region {
|
||||
private boolean freeze = false;
|
||||
private boolean fire = false;
|
||||
|
||||
private Region(ConfigurationSection config){
|
||||
private Region(ConfigurationSection config) {
|
||||
name = config.getName();
|
||||
minX = config.getInt("minX");
|
||||
minY = config.getInt("minY");
|
||||
@ -155,7 +155,7 @@ public class Region {
|
||||
setLinkedRegion(region -> region.fire = fire);
|
||||
}
|
||||
|
||||
public boolean inRegion(Location l){
|
||||
public boolean inRegion(Location l) {
|
||||
return prototype.inRegion(this, l);
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ public class Region {
|
||||
return prototype.buildArea.inRegionExtension(this, l);
|
||||
}
|
||||
|
||||
public void fastreset(){
|
||||
public void fastreset() {
|
||||
prototype.fastreset(this);
|
||||
}
|
||||
|
||||
@ -183,11 +183,11 @@ public class Region {
|
||||
return prototype.hasTestblock();
|
||||
}
|
||||
|
||||
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException{
|
||||
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
|
||||
prototype.resetTestblock(this, schem);
|
||||
}
|
||||
|
||||
public boolean hasProtection(){
|
||||
public boolean hasProtection() {
|
||||
return prototype.hasProtection();
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Prototype{
|
||||
public static class Prototype {
|
||||
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
||||
|
||||
private final int sizeX;
|
||||
@ -275,7 +275,7 @@ public class Region {
|
||||
|
||||
private final String protectSchematic; //nullable
|
||||
|
||||
private Prototype(ConfigurationSection config){
|
||||
private Prototype(ConfigurationSection config) {
|
||||
sizeX = config.getInt("sizeX");
|
||||
sizeY = config.getInt("sizeY");
|
||||
sizeZ = config.getInt("sizeZ");
|
||||
@ -304,27 +304,27 @@ public class Region {
|
||||
|
||||
protectSchematic = config.getString("protection", null);
|
||||
|
||||
if(!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
|
||||
if (!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
|
||||
prototypes.put(config.getName(), this);
|
||||
}
|
||||
|
||||
public boolean inRegion(Region region, Location l){
|
||||
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
|
||||
public boolean inRegion(Region region, Location l) {
|
||||
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
|
||||
inRange(l.getY(), region.minY + offsetY, sizeY) &&
|
||||
inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
|
||||
}
|
||||
|
||||
public boolean inRegionExtension(Region region, Location l) {
|
||||
return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
|
||||
return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
|
||||
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY) &&
|
||||
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
|
||||
}
|
||||
|
||||
public void fastreset(Region region){
|
||||
public void fastreset(Region region) {
|
||||
File file = new File(schematic);
|
||||
int x = region.minX + offsetX + sizeX/2;
|
||||
int x = region.minX + offsetX + sizeX / 2;
|
||||
int y = region.minY + offsetY;
|
||||
int z = region.minZ + offsetZ + sizeZ/2;
|
||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
|
||||
new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15));
|
||||
}
|
||||
@ -333,7 +333,7 @@ public class Region {
|
||||
int x = region.minX + offsetX + sizeX / 2;
|
||||
int y = region.minY + offsetY;
|
||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||
if(schem == null)
|
||||
if (schem == null)
|
||||
paste(new File(schematic), x, y, z, rotate);
|
||||
else
|
||||
paste(schem.load(), x, y, z, rotate);
|
||||
@ -347,7 +347,7 @@ public class Region {
|
||||
int x = region.minX + offsetX + sizeX / 2;
|
||||
int y = region.minY + testblock.offsetY - 1;
|
||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||
if(schem == null)
|
||||
if (schem == null)
|
||||
paste(new File(protectSchematic), x, y, z, rotate);
|
||||
else
|
||||
paste(schem.load(), x, y, z, rotate);
|
||||
@ -361,16 +361,16 @@ public class Region {
|
||||
testblock.reset(region, schem);
|
||||
}
|
||||
|
||||
private static boolean inRange(double l, int min, int size){
|
||||
private static boolean inRange(double l, int min, int size) {
|
||||
return min <= l && l < min + size;
|
||||
}
|
||||
|
||||
private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect
|
||||
private static void paste(File file, int x, int y, int z, boolean rotate) { //Type of protect
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
|
||||
new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15));
|
||||
}
|
||||
|
||||
private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
||||
private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
|
||||
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8),
|
||||
new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15));
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren