Merge branch 'master' into RegionFix
# Conflicts: # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandRegion.java # BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
Dieser Commit ist enthalten in:
Commit
fb92b3526e
@ -40,7 +40,7 @@ class Region_12 {
|
||||
private Region_12() {
|
||||
}
|
||||
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate) {
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
@ -49,10 +49,10 @@ class Region_12 {
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
|
||||
return paste(clipboard, x, y, z, rotate);
|
||||
return paste(clipboard, x, y, z, rotate, ignoreAir);
|
||||
}
|
||||
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
|
||||
Vector dimensions = clipboard.getDimensions();
|
||||
@ -69,7 +69,7 @@ class Region_12 {
|
||||
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
|
||||
ch.setTransform(aT);
|
||||
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
|
||||
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(ignoreAir).build());
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class Region_15 {
|
||||
private Region_15() {
|
||||
}
|
||||
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate) {
|
||||
static EditSession paste(File file, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
Clipboard clipboard;
|
||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
@ -50,10 +50,10 @@ class Region_15 {
|
||||
throw new SecurityException("Bausystem schematic not found", e);
|
||||
}
|
||||
|
||||
return paste(clipboard, x, y, z, rotate);
|
||||
return paste(clipboard, x, y, z, rotate, ignoreAir);
|
||||
}
|
||||
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
|
||||
static EditSession paste(Clipboard clipboard, int x, int y, int z, boolean rotate, boolean ignoreAir) {
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
ClipboardHolder ch = new ClipboardHolder(clipboard);
|
||||
BlockVector3 dimensions = clipboard.getDimensions();
|
||||
@ -66,7 +66,7 @@ class Region_15 {
|
||||
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
|
||||
}
|
||||
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).build());
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(ignoreAir).build());
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,12 @@ import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||
import de.steamwar.bausystem.world.regions.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandRegion extends SWCommand {
|
||||
|
||||
@ -28,15 +32,11 @@ public class CommandRegion extends SWCommand {
|
||||
player.sendMessage(BauSystem.PREFIX + "§8/§7region redo §8- §7Wiederhohle die letzten 10 §8/§7rg undo");
|
||||
}
|
||||
|
||||
@Register("undo")
|
||||
public void undoCommand(Player p) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
@Register
|
||||
public void undoCommand(Player p, Action action) {
|
||||
if(!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region.undo()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
||||
@ -72,6 +72,43 @@ public class CommandRegion extends SWCommand {
|
||||
CommandSelect.getInstance().baurahmenCommand(p, regionType, regionExtensionType);
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void genericRestoreCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(null, true);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void schematicRestoreCommand(Player p, String s) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region == null) return;
|
||||
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
|
||||
if (schem == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
region.reset(schem, true);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean checkGlobalRegion(Region region, Player p) {
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
|
||||
@ -87,9 +124,4 @@ public class CommandRegion extends SWCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
enum Action {
|
||||
UNDO,
|
||||
REDO
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren