Update BauSystem to new CommandFramework #217
@ -78,7 +78,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new CommandTrace();
|
new CommandTrace();
|
||||||
new CommandTPSLimiter();
|
new CommandTPSLimiter();
|
||||||
getCommand("nightvision").setExecutor(new CommandNV());
|
getCommand("nightvision").setExecutor(new CommandNV());
|
||||||
getCommand("reset").setExecutor(new CommandReset());
|
new CommandReset();
|
||||||
new CommandSpeed();
|
new CommandSpeed();
|
||||||
new CommandTNT();
|
new CommandTNT();
|
||||||
new CommandBau();
|
new CommandBau();
|
||||||
|
@ -23,6 +23,7 @@ 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 de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -30,42 +31,62 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CommandReset implements CommandExecutor {
|
public class CommandReset extends SWCommand {
|
||||||
|
|
||||||
@Override
|
public CommandReset() {
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
super("reset");
|
||||||
if (!(sender instanceof Player))
|
}
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
|
@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)) {
|
if (Welt.noPermission(player, Permission.world)) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == Region.GlobalRegion.getInstance()) {
|
if (region == Region.GlobalRegion.getInstance()) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
return region;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ public class CommandTestblock extends SWCommand {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.hasTestblock()) {
|
if (!region.hasTestblock()) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
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:
|
commands:
|
||||||
fire:
|
fire:
|
||||||
reset:
|
|
||||||
protect:
|
protect:
|
||||||
bauinfo:
|
bauinfo:
|
||||||
freeze:
|
freeze:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren