Add CommandFramework for Region Command
Dieser Commit ist enthalten in:
Ursprung
eb6fbf8f2c
Commit
8b807314cb
@ -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,39 +4,41 @@ 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) {
|
@Register
|
||||||
sendHelp(p);
|
public void genericCommand(Player player) {
|
||||||
} else {
|
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 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());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
switch (args[0].toLowerCase()) {
|
if(checkGlobalRegion(region, p)) return;
|
||||||
case "undo":
|
|
||||||
if(checkGlobalRegion(region, p)) return false;
|
switch (action) {
|
||||||
|
case UNDO:
|
||||||
if(region.undo()) {
|
if(region.undo()) {
|
||||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "redo":
|
case REDO:
|
||||||
if(checkGlobalRegion(region, p)) return false;
|
|
||||||
if(region.redo()) {
|
if(region.redo()) {
|
||||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
||||||
} else {
|
} else {
|
||||||
@ -44,16 +46,9 @@ public class CommandRegion implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sendHelp(p);
|
genericHelp(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sendHelp(Player player) {
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if(Region.GlobalRegion.isGlobalRegion(region)) {
|
if(Region.GlobalRegion.isGlobalRegion(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