SteamWar/BauSystem2.0
Archiviert
12
0

Simplify InfoCommand

Dieser Commit ist enthalten in:
yoyosource 2021-05-02 14:25:40 +02:00
Ursprung 84d6b57c27
Commit 3a7c494126
2 geänderte Dateien mit 24 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -41,9 +41,14 @@ public class InfoCommand extends SWCommand {
public void sendBauInfo(Player p) { public void sendBauInfo(Player p) {
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName()); p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation()); 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()); for (Flag flag : Flag.getFlags()) {
if (region.getFloorLevel() != 0) { if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + region.get(Flag.PROTECT).getChatValue().toUpperCase()); 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()); List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());

Datei anzeigen

@ -27,13 +27,13 @@ import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.Getter; import lombok.Getter;
@Getter @Getter
public enum Flag { public enum Flag implements EnumDisplay {
COLOR(ColorMode.class, ColorMode.YELLOW), COLOR("Color", ColorMode.class, ColorMode.YELLOW),
TNT(TNTMode.class, TNTMode.ONLY_TB), TNT("TNT", TNTMode.class, TNTMode.ONLY_TB),
FIRE(FireMode.class, FireMode.ALLOW), FIRE("Fire", FireMode.class, FireMode.ALLOW),
FREEZE(FreezeMode.class, FreezeMode.INACTIVE), FREEZE("Freeze", FreezeMode.class, FreezeMode.INACTIVE),
PROTECT(ProtectMode.class, ProtectMode.INACTIVE); PROTECT("Protect", ProtectMode.class, ProtectMode.INACTIVE);
@Getter @Getter
private static final Set<Flag> flags; private static final Set<Flag> flags;
@ -42,11 +42,13 @@ public enum Flag {
flags = EnumSet.allOf(Flag.class); flags = EnumSet.allOf(Flag.class);
} }
private final String chatValue;
private final Class<? extends Value<?>> valueType; private final Class<? extends Value<?>> valueType;
private final Flag.Value<?> defaultValue; private final Flag.Value<?> defaultValue;
private final Value<?>[] values; 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.valueType = valueType;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
this.values = defaultValue.getValues(); this.values = defaultValue.getValues();
@ -56,11 +58,18 @@ public enum Flag {
return this.defaultValue.getValueOf(name); return this.defaultValue.getValueOf(name);
} }
@Override @Override
public String toString() { public String toString() {
return this.name().toLowerCase(); return this.name().toLowerCase();
} }
@Override
public String getChatValue() {
return chatValue;
}
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay { public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
T getValue(); T getValue();