forked from SteamWar/SteamWar
Merge pull request 'Fix color region reset' (#73) from BauSystem/resetColor into main
Reviewed-on: https://steamwar.de/devlabs/SteamWar/SteamWar/pulls/73 Reviewed-by: YoyoNow <jwsteam@nidido.de>
This commit is contained in:
+1
-4
@@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
@@ -31,7 +30,6 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.sql.Punishment;
|
||||
@@ -40,7 +38,6 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Linked
|
||||
@@ -61,7 +58,7 @@ public class ResetCommand extends SWCommand {
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||
for (Flag value : Flag.values()) {
|
||||
for (Flag value : Flag.getResetFlags()) {
|
||||
region.set(value, value.getDefaultValue());
|
||||
}
|
||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||
|
||||
@@ -21,41 +21,40 @@ package de.steamwar.bausystem.region.flags;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.*;
|
||||
import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Flag implements EnumDisplay {
|
||||
|
||||
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW),
|
||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE),
|
||||
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE),
|
||||
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE),
|
||||
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, false),
|
||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, true),
|
||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, true),
|
||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, true),
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, true),
|
||||
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE, true),
|
||||
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE, true),
|
||||
;
|
||||
|
||||
@Getter
|
||||
private static final Set<Flag> flags;
|
||||
@Getter
|
||||
private static final Set<Flag> resetFlags;
|
||||
|
||||
static {
|
||||
flags = EnumSet.allOf(Flag.class);
|
||||
resetFlags = flags.stream().filter(flag -> flag.reset).collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
|
||||
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(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();
|
||||
}
|
||||
private final boolean reset;
|
||||
|
||||
public Value<?> getFlagValueOf(final String name) {
|
||||
return this.defaultValue.getValueOf(name);
|
||||
|
||||
Reference in New Issue
Block a user