SteamWar/BauSystem
Archiviert
13
0

Merge branch 'master' into AutostartTimer

Dieser Commit ist enthalten in:
YoyoNow 2021-04-10 19:20:51 +02:00
Commit 4af113eb57
13 geänderte Dateien mit 309 neuen und 67 gelöschten Zeilen

Datei anzeigen

@ -19,12 +19,12 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.world.regions.Point; import de.steamwar.bausystem.world.regions.Point;
import de.steamwar.bausystem.world.regions.RegionUtils_12;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,11 +34,7 @@ class CommandSelect_12 {
static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
static void setSelection(Player p, Point minPoint, Point maxPoint) { static void setSelection(Player p, Point minPoint, Point maxPoint) {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toVector(minPoint), toVector(maxPoint))); WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, RegionUtils_12.toVector(minPoint), RegionUtils_12.toVector(maxPoint)));
}
private static Vector toVector(Point point) {
return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ());
} }
} }

Datei anzeigen

@ -0,0 +1,32 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world.regions;
import com.sk89q.worldedit.Vector;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionUtils_12 {
public Vector toVector(Point point) {
return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ());
}
}

Datei anzeigen

@ -20,13 +20,17 @@
package de.steamwar.bausystem.world.regions; package de.steamwar.bausystem.world.regions;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -40,7 +44,7 @@ class Region_12 {
private Region_12() { private Region_12() {
} }
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) { static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) throws MaxChangedBlocksException {
World w = new BukkitWorld(Bukkit.getWorlds().get(0)); World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Clipboard clipboard; Clipboard clipboard;
try { try {
@ -49,17 +53,17 @@ class Region_12 {
throw new SecurityException("Bausystem schematic not found", e); throw new SecurityException("Bausystem schematic not found", e);
} }
return paste(clipboard, x, y, z, rotate, ignoreAir); return paste(clipboard, x, y, z, pasteOptions);
} }
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) { static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) throws MaxChangedBlocksException {
World w = new BukkitWorld(Bukkit.getWorlds().get(0)); World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions(); Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(x, y, z); Vector v = new Vector(x, y, z);
Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform(); AffineTransform aT = new AffineTransform();
if (rotate) { if (pasteOptions.isRotate()) {
aT = aT.rotateY(180); aT = aT.rotateY(180);
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else { } else {
@ -69,7 +73,11 @@ class Region_12 {
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData()); ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT); ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(ignoreAir).build());
if (pasteOptions.isReset()) {
e.setBlocks(new CuboidRegion(RegionUtils_12.toVector(pasteOptions.getMinPoint()), RegionUtils_12.toVector(pasteOptions.getMaxPoint())), new BaseBlock(BlockID.AIR));
}
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
return e; return e;
} }
} }

Datei anzeigen

@ -21,10 +21,10 @@ package de.steamwar.bausystem.commands;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.world.regions.Point; import de.steamwar.bausystem.world.regions.Point;
import de.steamwar.bausystem.world.regions.RegionUtils_15;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,11 +34,7 @@ class CommandSelect_15 {
static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0)); static final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
static void setSelection(Player p, Point minPoint, Point maxPoint) { static void setSelection(Player p, Point minPoint, Point maxPoint) {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint))); WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, RegionUtils_15.toBlockVector3(minPoint), RegionUtils_15.toBlockVector3(maxPoint)));
}
private static BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
} }
} }

Datei anzeigen

@ -0,0 +1,32 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world.regions;
import com.sk89q.worldedit.math.BlockVector3;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RegionUtils_15 {
public BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
}

Datei anzeigen

@ -29,25 +29,25 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.world.Color;
import org.bukkit.Bukkit;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import de.steamwar.bausystem.world.Color;
import org.bukkit.Bukkit;
class Region_15 { class Region_15 {
private Region_15() { private Region_15() {
} }
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) {
Clipboard clipboard; Clipboard clipboard;
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) { try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
clipboard = reader.read(); clipboard = reader.read();
@ -55,25 +55,28 @@ class Region_15 {
throw new SecurityException("Bausystem schematic not found", e); throw new SecurityException("Bausystem schematic not found", e);
} }
return paste(clipboard, x, y, z, rotate, ignoreAir, color); return paste(clipboard, x, y, z, pasteOptions);
} }
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
changeColor(clipboard, color); changeColor(clipboard, pasteOptions.getColor());
ClipboardHolder ch = new ClipboardHolder(clipboard); ClipboardHolder ch = new ClipboardHolder(clipboard);
BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z); BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
if (rotate) { if (pasteOptions.isRotate()) {
ch.setTransform(new AffineTransform().rotateY(180)); ch.setTransform(new AffineTransform().rotateY(180));
v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); v = v.add(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else { } else {
v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset); v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset);
} }
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build()); if (pasteOptions.isReset()) {
e.setBlocks(new CuboidRegion(RegionUtils_15.toBlockVector3(pasteOptions.getMinPoint()), RegionUtils_15.toBlockVector3(pasteOptions.getMaxPoint())), BlockTypes.AIR.getDefaultState().toBaseBlock());
}
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
return e; return e;
} catch (WorldEditException e) { } catch (WorldEditException e) {
throw new SecurityException(e.getMessage(), e); throw new SecurityException(e.getMessage(), e);

Datei anzeigen

@ -0,0 +1,94 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world.regions;
import de.steamwar.bausystem.world.Color;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class PasteOptions {
/**
* Used in 1.12 and 1.15
*/
private boolean rotate = false;
/**
* Used in 1.12 and 1.15
*/
private boolean ignoreAir = false;
/**
* Used in 1.15
*/
private Color color = Color.YELLOW;
/**
* Used in 1.15
*/
private boolean reset = false;
/**
* Used in 1.15
*/
private Point minPoint = null;
/**
* Used in 1.15
*/
private Point maxPoint = null;
public PasteOptions(boolean rotate) {
this.rotate = rotate;
}
public PasteOptions(boolean rotate, Color color) {
this.rotate = rotate;
this.color = color;
}
public PasteOptions(boolean rotate, boolean ignoreAir) {
this.rotate = rotate;
this.ignoreAir = ignoreAir;
}
public PasteOptions(boolean rotate, boolean ignoreAir, boolean reset) {
this.rotate = rotate;
this.ignoreAir = ignoreAir;
this.reset = reset;
}
public PasteOptions(boolean rotate, Color color, boolean reset) {
this.rotate = rotate;
this.color = color;
this.reset = reset;
}
public PasteOptions(boolean rotate, boolean ignoreAir, Color color) {
this.rotate = rotate;
this.ignoreAir = ignoreAir;
this.color = color;
}
}

Datei anzeigen

@ -20,8 +20,8 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.TPSUtils;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.TPSWatcher; import de.steamwar.core.TPSWatcher;
import de.steamwar.sql.BauweltMember; import de.steamwar.sql.BauweltMember;
@ -52,6 +52,9 @@ public class CommandInfo extends SWCommand {
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName()); p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS")); p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
if (region.hasProtection()) {
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + (region.isProtect() ? "§aAN" : "§cAUS"));
}
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID()); List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");

Datei anzeigen

@ -27,14 +27,20 @@ import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
public class CommandProtect extends SWCommand { public class CommandProtect extends SWCommand implements Listener {
public CommandProtect() { public CommandProtect() {
super("protect"); super("protect");
if (Region.buildAreaEnabled()) {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
} }
@Register(help = true) @Register(help = true)
@ -48,6 +54,15 @@ public class CommandProtect extends SWCommand {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
if (Region.buildAreaEnabled()) {
region.setProtect(!region.isProtect());
if (region.isProtect()) {
RegionUtils.actionBar(region, "§aBoden geschützt");
} else {
RegionUtils.actionBar(region, "§cBoden Schutz aufgehoben");
}
return;
}
try { try {
region.protect(null); region.protect(null);
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt"); p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
@ -60,6 +75,10 @@ public class CommandProtect extends SWCommand {
@Register @Register
public void schematicProtectCommand(Player p, String s) { public void schematicProtectCommand(Player p, String s) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
if (Region.buildAreaEnabled()) {
genericHelp(p);
return;
}
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
@ -92,4 +111,15 @@ public class CommandProtect extends SWCommand {
} }
return region; return region;
} }
@EventHandler
public void onExplode(EntityExplodeEvent event) {
Region region = Region.getRegion(event.getLocation());
if (!region.isProtect() && !region.hasProtection()) {
return;
}
event.blockList().removeIf(block -> {
return block.getY() < region.getProtectYLevel();
});
}
} }

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.regions.Region; import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -45,11 +46,16 @@ public class CommandTestblock extends SWCommand {
@Register @Register
public void genericTestblockCommand(Player p) { public void genericTestblockCommand(Player p) {
genericTestblockCommand(p, RegionExtensionType.NORMAL);
}
@Register
public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
try { try {
region.resetTestblock(null); region.resetTestblock(null, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
@ -57,8 +63,19 @@ public class CommandTestblock extends SWCommand {
} }
} }
@Register @Register
public void schematicTestblockCommand(Player p, String s) { public void schematicTestblockCommand(Player p, String s) {
schematicTestblockCommand(p, s, RegionExtensionType.NORMAL);
}
@Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, String s) {
schematicTestblockCommand(p, s, regionExtensionType);
}
@Register
public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
@ -68,7 +85,7 @@ public class CommandTestblock extends SWCommand {
return; return;
} }
try { try {
region.resetTestblock(schem); region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt"); p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks"); p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");

Datei anzeigen

@ -66,6 +66,9 @@ public class BauScoreboard implements Listener {
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can")); strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName()); strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus")); strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
if (region.hasProtection()) {
strings.add("§eProtect§8: " + (region.isProtect() ? "§aan" : "§caus"));
}
if (RecordStateMachine.getRecordStatus().isTracing()) { if (RecordStateMachine.getRecordStatus().isTracing()) {
strings.add("§3"); strings.add("§3");

Datei anzeigen

@ -145,16 +145,24 @@ public class Prototype {
} }
public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException { public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
return reset(region, schem, ignoreAir, color, false);
}
public EditSession reset(Region region, Schematic schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException {
PasteOptions pasteOptions;
if (reset) {
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION));
} else {
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemType().fightType() || schem.getSchemType().check())), ignoreAir, color);
}
int x = region.minPoint.getX() + offsetX + sizeX / 2; int x = region.minPoint.getX() + offsetX + sizeX / 2;
int y = region.minPoint.getY() + offsetY; int y = region.minPoint.getY() + offsetY;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
if (schem == null) { if (schem == null) {
return paste(new File(schematic), x, y, z, rotate, ignoreAir, color); return paste(new File(schematic), x, y, z, pasteOptions);
} else { } else {
if (schem.getSchemType().fightType() || schem.getSchemType().check()) { return paste(schem.load(), x, y, z, pasteOptions);
return paste(schem.load(), x, y, z, !rotate, ignoreAir, color);
}
return paste(schem.load(), x, y, z, rotate, ignoreAir, color);
} }
} }
@ -167,9 +175,9 @@ public class Prototype {
int y = region.minPoint.getY() + testblock.offsetY - 1; int y = region.minPoint.getY() + testblock.offsetY - 1;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2; int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
if (schem == null) { if (schem == null) {
return paste(new File(protectSchematic), x, y, z, rotate, false, Color.YELLOW); return paste(new File(protectSchematic), x, y, z, new PasteOptions(rotate, false, Color.YELLOW));
} else { } else {
return paste(schem.load(), x, y, z, rotate, false, Color.YELLOW); return paste(schem.load(), x, y, z, new PasteOptions(rotate, false, Color.YELLOW));
} }
} }
@ -177,21 +185,21 @@ public class Prototype {
return testblock != null; return testblock != null;
} }
public EditSession resetTestblock(Region region, Schematic schem, Color color) throws IOException, NoClipboardException { public EditSession resetTestblock(Region region, Schematic schem, Color color, boolean reset) throws IOException, NoClipboardException {
return testblock.reset(region, schem, false, color); return testblock.reset(region, schem, false, color, reset);
} }
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; return min <= l && l < min + size;
} }
private static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { //Type of protect private static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { //Type of protect
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, rotate, ignoreAir), 8), return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(file, x, y, z, pasteOptions), 8),
new VersionedCallable(() -> Region_15.paste(file, x, y, z, rotate, ignoreAir, color), 15)); new VersionedCallable(() -> Region_15.paste(file, x, y, z, pasteOptions), 15));
} }
private static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir, Color color) { private static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, rotate, ignoreAir), 8), return (EditSession) VersionedCallable.call(new VersionedCallable(() -> Region_12.paste(clipboard, x, y, z, pasteOptions), 8),
new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate, ignoreAir, color), 15)); new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, pasteOptions), 15));
} }
} }

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.SizedStack; import de.steamwar.bausystem.world.SizedStack;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -133,10 +134,19 @@ public class Region {
private JsonObject regionOptions = new JsonObject(); private JsonObject regionOptions = new JsonObject();
@Getter
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF; private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
@Getter
private boolean freeze = false; private boolean freeze = false;
@Getter
private boolean fire = false; private boolean fire = false;
@Getter
private boolean protect = false;
@Getter
private Color color = Color.YELLOW; private Color color = Color.YELLOW;
private Region(ConfigurationSection config) { private Region(ConfigurationSection config) {
@ -178,6 +188,10 @@ public class Region {
freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean(); freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean();
} }
if (regionOptions.has("protect")) {
protect = regionOptions.getAsJsonPrimitive("protect").getAsBoolean();
}
if (regionOptions.has("color")) { if (regionOptions.has("color")) {
String colorName = regionOptions.getAsJsonPrimitive("color").getAsString(); String colorName = regionOptions.getAsJsonPrimitive("color").getAsString();
try { try {
@ -191,10 +205,6 @@ public class Region {
} }
} }
public Color getColor() {
return color;
}
public void setColor(Color color) { public void setColor(Color color) {
this.color = color; this.color = color;
regionOptions.add("color", new JsonPrimitive(color.name())); regionOptions.add("color", new JsonPrimitive(color.name()));
@ -217,36 +227,42 @@ public class Region {
} }
} }
public TNTMode getTntMode() {
return tntMode;
}
public void setTntMode(TNTMode tntMode) { public void setTntMode(TNTMode tntMode) {
this.tntMode = tntMode; this.tntMode = tntMode;
setLinkedRegion(region -> region.tntMode = tntMode); setLinkedRegion(region -> {
region.tntMode = tntMode;
region.regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
});
regionOptions.add("tnt", new JsonPrimitive(tntMode.name())); regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
} }
public boolean isFreeze() {
return freeze;
}
public void setFreeze(boolean freeze) { public void setFreeze(boolean freeze) {
this.freeze = freeze; this.freeze = freeze;
setLinkedRegion(region -> region.freeze = freeze); setLinkedRegion(region -> {
region.freeze = freeze;
region.regionOptions.add("freeze", new JsonPrimitive(freeze));
});
regionOptions.add("freeze", new JsonPrimitive(freeze)); regionOptions.add("freeze", new JsonPrimitive(freeze));
} }
public boolean isFire() {
return fire;
}
public void setFire(boolean fire) { public void setFire(boolean fire) {
this.fire = fire; this.fire = fire;
setLinkedRegion(region -> region.fire = fire); setLinkedRegion(region -> {
region.fire = fire;
region.regionOptions.add("fire", new JsonPrimitive(fire));
});
regionOptions.add("fire", new JsonPrimitive(fire)); regionOptions.add("fire", new JsonPrimitive(fire));
} }
public void setProtect(boolean protect) {
this.protect = protect;
setLinkedRegion(region -> {
region.protect = protect;
region.regionOptions.add("protect", new JsonPrimitive(protect));
});
regionOptions.add("protect", new JsonPrimitive(protect));
}
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) { public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
switch (regionType) { switch (regionType) {
case BUILD: case BUILD:
@ -296,9 +312,9 @@ public class Region {
return prototype.hasTestblock(); return prototype.hasTestblock();
} }
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException { public void resetTestblock(Schematic schem, boolean reset) throws IOException, NoClipboardException {
initSessions(); initSessions();
undosessions.push(prototype.resetTestblock(this, schem, color)); undosessions.push(prototype.resetTestblock(this, schem, color, reset));
} }
public boolean hasProtection() { public boolean hasProtection() {
@ -310,6 +326,10 @@ public class Region {
undosessions.push(prototype.protect(this, schem)); undosessions.push(prototype.protect(this, schem));
} }
public int getProtectYLevel() {
return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY();
}
public boolean hasExtensionArea(RegionType regionType) { public boolean hasExtensionArea(RegionType regionType) {
switch (regionType) { switch (regionType) {
case BUILD: case BUILD: