Add RegionCommand
Dieser Commit ist enthalten in:
Ursprung
5dc47c495e
Commit
ddf8182041
@ -0,0 +1,145 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.util.SelectCommand;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.linkage.LinkedInstance;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class RegionCommand extends SWCommand {
|
||||
|
||||
@LinkedInstance(SelectCommand.class)
|
||||
private SelectCommand selectCommand;
|
||||
|
||||
@LinkedInstance(ColorCommand.class)
|
||||
private ColorCommand colorCommand;
|
||||
|
||||
public RegionCommand() {
|
||||
super("region", "rg");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
genericHelp(player);
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player player, String... args) {
|
||||
player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig");
|
||||
player.sendMessage("§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo");
|
||||
player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen");
|
||||
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
|
||||
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
|
||||
player.sendMessage("§8/§eregion color §8[§7Color§8] §8- §7Ändere die Regions Farbe");
|
||||
}
|
||||
|
||||
@Register("undo")
|
||||
public void undoCommand(Player p) {
|
||||
if(!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region.undo()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
||||
} else {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
||||
}
|
||||
}
|
||||
|
||||
@Register("redo")
|
||||
public void redoCommand(Player p) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (region.redo()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
||||
} else {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType) {
|
||||
selectCommand.baurahmenCommand(p, regionType, RegionExtensionType.NORMAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
selectCommand.baurahmenCommand(p, regionType, regionExtensionType);
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void genericRestoreCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
try {
|
||||
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
|
||||
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("restore")
|
||||
public void schematicRestoreCommand(Player p, String s) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
|
||||
if (schem == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
region.reset(schem, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("color")
|
||||
public void colorCommand(Player p, ColorMode color) {
|
||||
colorCommand.genericColor(p, color);
|
||||
}
|
||||
|
||||
static boolean checkGlobalRegion(Region region, Player p) {
|
||||
if (region.isGlobal()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package de.steamwar.bausystem.features.script;
|
||||
|
||||
public interface Command {
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren