Add ColorCommand
Dieser Commit ist enthalten in:
Ursprung
ce0fb037d7
Commit
cf6947a081
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -53,6 +53,12 @@ public class Region {
|
|||||||
return GlobalRegion.instance;
|
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 YAPIONObject regionData;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren