diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java new file mode 100644 index 00000000..97004bfe --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -0,0 +1,72 @@ +package de.steamwar.bausystem.features.region; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.config.BauServer; +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.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; +import de.steamwar.command.SWCommand; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class ColorCommand extends SWCommand { + + @LinkedInstance(BauServer.class) + private BauServer bauServer; + + public ColorCommand() { + super("color"); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region"); + p.sendMessage("§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global"); + } + + @Register + public void genericColor(Player p, ColorMode color) { + genericColorSet(p, color, ColorizationType.LOCAL); + } + + @Register + public void genericColorSet(Player p, ColorMode color, ColorizationType colorizationType) { + if (!permissionCheck(p)) { + return; + } + if (colorizationType == ColorizationType.GLOBAL) { + Region.setGlobal(Flag.COLOR, color); + p.sendMessage(BauSystem.PREFIX + "Alle Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt"); + return; + } + Region region = Region.getRegion(p.getLocation()); + if (region.isGlobal()) { + p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region"); + return; + } + region.set(Flag.COLOR, color); + p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt"); + } + + @Register + public void genericColorSet(Player p, ColorizationType colorizationType, ColorMode color) { + genericColorSet(p, color, colorizationType); + } + + private boolean permissionCheck(Player p) { + if (bauServer.getOwner().equals(p.getUniqueId())) { + return true; + } + p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); + return false; + } + + public enum ColorizationType { + LOCAL, + GLOBAL + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 59bf2046..f26916c7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -53,6 +53,12 @@ public class Region { return GlobalRegion.instance; } + public static void setGlobal(Flag flagType, Flag.Value value) { + for (Region region : REGION_LIST) { + region.set(flagType, value); + } + } + private YAPIONObject regionData; private String name;