|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|