Update CommandReset to new SWCommand system
Dieser Commit ist enthalten in:
Ursprung
6744b8e0ed
Commit
738a88ac0a
@ -78,7 +78,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
new CommandTrace();
|
||||
new CommandTPSLimiter();
|
||||
getCommand("nightvision").setExecutor(new CommandNV());
|
||||
getCommand("reset").setExecutor(new CommandReset());
|
||||
new CommandReset();
|
||||
new CommandSpeed();
|
||||
new CommandTNT();
|
||||
new CommandBau();
|
||||
|
@ -23,6 +23,7 @@ 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;
|
||||
@ -30,42 +31,62 @@ 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 CommandReset implements CommandExecutor {
|
||||
public class CommandReset 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 CommandReset() {
|
||||
super("reset");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericResetCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(null);
|
||||
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
|
||||
public void schematicResetCommand(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.reset(null);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == Region.GlobalRegion.getInstance()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (args.length > 0) {
|
||||
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||
if (schem == null) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return false;
|
||||
}
|
||||
region.reset(schem);
|
||||
} else {
|
||||
region.fastreset();
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||
}
|
||||
return false;
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public class CommandTestblock extends SWCommand {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasTestblock()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return region;
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||
|
||||
commands:
|
||||
fire:
|
||||
reset:
|
||||
protect:
|
||||
bauinfo:
|
||||
freeze:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren