Update CommandTestblock to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
bb4fc017fa
Commit
8f60ffdbf5
@ -83,7 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
new CommandTNT();
|
||||
getCommand("fire").setExecutor(new CommandFire());
|
||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||
getCommand("testblock").setExecutor(new CommandTestblock());
|
||||
new CommandTestblock();
|
||||
getCommand("bauinfo").setExecutor(new CommandInfo());
|
||||
getCommand("protect").setExecutor(new CommandProtect());
|
||||
getCommand("skull").setExecutor(new CommandSkull());
|
||||
|
@ -23,48 +23,67 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandTestblock implements CommandExecutor {
|
||||
public class CommandTestblock extends SWCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
public CommandTestblock() {
|
||||
super("testblock", "tb");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericTestblockCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.resetTestblock(null);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicTestblockCommand(Player p, String s) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
|
||||
if (schem == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
region.resetTestblock(null);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.worldedit)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasTestblock()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return false;
|
||||
return region;
|
||||
}
|
||||
try {
|
||||
Schematic schem = null;
|
||||
if (args.length > 0) {
|
||||
schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||
if (schem == null) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
region.resetTestblock(schem);
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||
commands:
|
||||
debugstick:
|
||||
fire:
|
||||
testblock:
|
||||
aliases: tb
|
||||
reset:
|
||||
protect:
|
||||
bauinfo:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren