Simplify InfoCommand
Dieser Commit ist enthalten in:
Ursprung
84d6b57c27
Commit
3a7c494126
@ -41,9 +41,14 @@ public class InfoCommand extends SWCommand {
|
||||
public void sendBauInfo(Player p) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.get(Flag.TNT).getChatValue().toUpperCase() + " §eFire§8: " + region.get(Flag.FIRE).getChatValue().toUpperCase() + " §eFreeze§8: " + region.get(Flag.FREEZE).getChatValue().toUpperCase());
|
||||
if (region.getFloorLevel() != 0) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + region.get(Flag.PROTECT).getChatValue().toUpperCase());
|
||||
for (Flag flag : Flag.getFlags()) {
|
||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
||||
continue;
|
||||
}
|
||||
Flag.Value<?> value = region.get(flag);
|
||||
if (value != null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§e" + flag.getChatValue() + "§8: §7" + value.getChatValue());
|
||||
}
|
||||
}
|
||||
|
||||
List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());
|
||||
|
@ -27,13 +27,13 @@ import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum Flag {
|
||||
public enum Flag implements EnumDisplay {
|
||||
|
||||
COLOR(ColorMode.class, ColorMode.YELLOW),
|
||||
TNT(TNTMode.class, TNTMode.ONLY_TB),
|
||||
FIRE(FireMode.class, FireMode.ALLOW),
|
||||
FREEZE(FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT(ProtectMode.class, ProtectMode.INACTIVE);
|
||||
COLOR("Color", ColorMode.class, ColorMode.YELLOW),
|
||||
TNT("TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||
FIRE("Fire", FireMode.class, FireMode.ALLOW),
|
||||
FREEZE("Freeze", FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT("Protect", ProtectMode.class, ProtectMode.INACTIVE);
|
||||
|
||||
@Getter
|
||||
private static final Set<Flag> flags;
|
||||
@ -42,11 +42,13 @@ public enum Flag {
|
||||
flags = EnumSet.allOf(Flag.class);
|
||||
}
|
||||
|
||||
private final String chatValue;
|
||||
private final Class<? extends Value<?>> valueType;
|
||||
private final Flag.Value<?> defaultValue;
|
||||
private final Value<?>[] values;
|
||||
|
||||
<T extends Enum<T> & Value<T>> Flag(final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) {
|
||||
<T extends Enum<T> & Value<T>> Flag(String chatValue, final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) {
|
||||
this.chatValue = chatValue;
|
||||
this.valueType = valueType;
|
||||
this.defaultValue = defaultValue;
|
||||
this.values = defaultValue.getValues();
|
||||
@ -56,11 +58,18 @@ public enum Flag {
|
||||
return this.defaultValue.getValueOf(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChatValue() {
|
||||
return chatValue;
|
||||
}
|
||||
|
||||
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
|
||||
|
||||
T getValue();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren