Add Regional Reset History #211
@ -21,7 +21,6 @@ package de.steamwar.bausystem.world;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
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.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
@ -29,14 +28,7 @@ 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.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -91,6 +91,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new CommandRedstoneTester();
|
new CommandRedstoneTester();
|
||||||
new CommandGUI();
|
new CommandGUI();
|
||||||
new CommandWorldSpawn();
|
new CommandWorldSpawn();
|
||||||
|
new CommandRegion();
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
||||||
|
@ -4,57 +4,52 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Region;
|
import de.steamwar.bausystem.world.Region;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandRegion implements CommandExecutor {
|
public class CommandRegion extends SWCommand {
|
||||||
|
|
||||||
@Override
|
public CommandRegion() {
|
||||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
super("region", "rg");
|
||||||
if (!(sender instanceof Player))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (Welt.noPermission(p, Permission.world)) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length == 0) {
|
|
||||||
sendHelp(p);
|
|
||||||
} else {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
switch (args[0].toLowerCase()) {
|
|
||||||
case "undo":
|
|
||||||
if(checkGlobalRegion(region, p)) return false;
|
|
||||||
if(region.undo()) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "redo":
|
|
||||||
if(checkGlobalRegion(region, p)) return false;
|
|
||||||
if(region.redo()) {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sendHelp(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendHelp(Player player) {
|
@Register
|
||||||
|
public void genericCommand(Player player) {
|
||||||
|
genericHelp(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(help = true)
|
||||||
|
public void genericHelp(Player player, String... args) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§8/§7region undo §8- §7Mache die letzten 10 /testblock oder /reset rückgängig");
|
player.sendMessage(BauSystem.PREFIX + "§8/§7region undo §8- §7Mache die letzten 10 /testblock oder /reset rückgängig");
|
||||||
player.sendMessage(BauSystem.PREFIX + "§8/§7region redo §8- §7Wiederhohle die letzten 10 §8/§7rg undo");
|
player.sendMessage(BauSystem.PREFIX + "§8/§7region redo §8- §7Wiederhohle die letzten 10 §8/§7rg undo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void undoCommand(Player p, Action action) {
|
||||||
|
if(!permissionCheck(p)) return;
|
||||||
|
Region region = Region.getRegion(p.getLocation());
|
||||||
|
if(checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case UNDO:
|
||||||
|
if(region.undo()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REDO:
|
||||||
|
if(region.redo()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
genericHelp(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if(Region.GlobalRegion.isGlobalRegion(region)) {
|
if(Region.GlobalRegion.isGlobalRegion(region)) {
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
|
||||||
@ -62,4 +57,17 @@ public class CommandRegion implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean permissionCheck(Player player) {
|
||||||
|
if (Welt.noPermission(player, Permission.worldedit)) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Action {
|
||||||
|
UNDO,
|
||||||
|
REDO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class CommandReset extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
region.reset(null);
|
region.reset(schem);
|
||||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren