Update CommandProtect to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
8500fc136c
Commit
853b475b74
@ -86,7 +86,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||
new CommandTestblock();
|
||||
getCommand("bauinfo").setExecutor(new CommandInfo());
|
||||
getCommand("protect").setExecutor(new CommandProtect());
|
||||
new CommandProtect();
|
||||
new CommandSkull();
|
||||
getCommand("loader").setExecutor(new CommandLoader());
|
||||
getCommand("lockschem").setExecutor(new CommandLockschem());
|
||||
|
@ -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 CommandProtect implements CommandExecutor {
|
||||
public class CommandProtect 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 CommandProtect() {
|
||||
super("protect");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericTestblockCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.protect(null);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed protect", 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.protect(null);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.worldedit)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == null || !region.hasProtection()) {
|
||||
if (!region.hasProtection()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
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.protect(schem);
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
|
||||
}
|
||||
return false;
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||
|
||||
commands:
|
||||
fire:
|
||||
protect:
|
||||
bauinfo:
|
||||
freeze:
|
||||
aliases: stoplag
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren