mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Port description flag
This commit is contained in:
parent
83a33d2b41
commit
a3192c9668
@ -547,11 +547,13 @@ public enum Captions implements Caption {
|
||||
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Flag descriptions">
|
||||
FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them", "Flags"),
|
||||
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot", "Flags"),
|
||||
FLAG_DESCRIPTION_FLIGHT("Set to 'true' to enable flight within the plot when in survival or adventure mode", "Flags"),
|
||||
FLAG_DESCRIPTION_UNTRUSTED("Set to 'false' to disallow untrusted players from visiting the plot", "Flags"),
|
||||
FLAG_DESCRIPTION_DENY_EXIT("Set to 'true' to disallow players from exiting the plot", "Flags"),
|
||||
FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them.", "Flags"),
|
||||
FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_FLIGHT("Set to 'true' to enable flight within the plot when in survival or adventure mode.", "Flags"),
|
||||
FLAG_DESCRIPTION_UNTRUSTED("Set to 'false' to disallow untrusted players from visiting the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DENY_EXIT("Set to 'true' to disallow players from exiting the plot.", "Flags"),
|
||||
FLAG_DESCRIPTION_DESCRIPTION("Plot description. Supports '&' color codes.", "Flags"),
|
||||
FLAG_DESCRIPTION_GREETING("Message sent to players on plot entry. Supports '&' color codes.", "Flags"),
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Flag category errors">
|
||||
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
||||
|
@ -6,7 +6,6 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
|
||||
public final class Flags {
|
||||
|
||||
public static final StringFlag DESCRIPTION = new StringFlag("description");
|
||||
public static final IntegerListFlag ANALYSIS =
|
||||
(IntegerListFlag) new IntegerListFlag("analysis").reserve();
|
||||
public static final StringFlag GREETING = new StringFlag("greeting");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||
@ -29,6 +30,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE);
|
||||
this.addFlag(UntrustedVisitFlag.UNTRUSTED_VISIT_FLAG_TRUE);
|
||||
this.addFlag(DenyExitFlag.DENY_EXIT_FLAG_TRUE);
|
||||
this.addFlag(DescriptionFlag.DESCRIPTION_FLAG_EMPTY);
|
||||
}
|
||||
|
||||
@Override public PlotFlag<?, ?> getFlagErased(Class<?> flagClass) {
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DescriptionFlag extends PlotFlag<String, DescriptionFlag> {
|
||||
|
||||
public static final DescriptionFlag DESCRIPTION_FLAG_EMPTY = new DescriptionFlag("");
|
||||
|
||||
protected DescriptionFlag(@NotNull String value) {
|
||||
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_DESCRIPTION);
|
||||
}
|
||||
|
||||
@Override public DescriptionFlag parse(@NotNull String input) {
|
||||
return flagOf(input);
|
||||
}
|
||||
|
||||
@Override public DescriptionFlag merge(@NotNull String newValue) {
|
||||
return flagOf(this.getValue() + " " + newValue);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
@Override public String getExample() {
|
||||
return "&6Welcome to my plot!";
|
||||
}
|
||||
|
||||
@Override protected DescriptionFlag flagOf(@NotNull String value) {
|
||||
return new DescriptionFlag(value);
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.DoubleFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -772,9 +773,11 @@ public class MainUtil {
|
||||
} else {
|
||||
seen = Captions.NEVER.getTranslated();
|
||||
}
|
||||
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
|
||||
String description = !descriptionFlag.isPresent() ? Captions.NONE.getTranslated() :
|
||||
Flags.DESCRIPTION.valueToString(descriptionFlag.get());
|
||||
|
||||
String description = plot.getFlag(DescriptionFlag.class);
|
||||
if (description.isEmpty()) {
|
||||
description = Captions.NONE.getTranslated();
|
||||
}
|
||||
|
||||
StringBuilder flags = new StringBuilder();
|
||||
HashMap<Flag<?>, Object> flagMap =
|
||||
|
Loading…
Reference in New Issue
Block a user