mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Port greeting and farewell flags
This commit is contained in:
parent
a3192c9668
commit
70e965d5cb
@ -554,6 +554,7 @@ public enum Captions implements Caption {
|
||||
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"),
|
||||
FLAG_DESCRIPTION_FAREWELL("Message sent to players when leaving the plot. Supports '&' color codes.", "Flags"),
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Flag category errors">
|
||||
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
||||
|
@ -8,8 +8,6 @@ public final class Flags {
|
||||
|
||||
public static final IntegerListFlag ANALYSIS =
|
||||
(IntegerListFlag) new IntegerListFlag("analysis").reserve();
|
||||
public static final StringFlag GREETING = new StringFlag("greeting");
|
||||
public static final StringFlag FAREWELL = new StringFlag("farewell");
|
||||
public static final IntervalFlag FEED = new IntervalFlag("feed");
|
||||
public static final IntervalFlag HEAL = new IntervalFlag("heal");
|
||||
public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode");
|
||||
|
@ -3,7 +3,9 @@ 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.FarewellFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GreetingFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.UntrustedVisitFlag;
|
||||
import lombok.Getter;
|
||||
@ -31,6 +33,8 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(UntrustedVisitFlag.UNTRUSTED_VISIT_FLAG_TRUE);
|
||||
this.addFlag(DenyExitFlag.DENY_EXIT_FLAG_TRUE);
|
||||
this.addFlag(DescriptionFlag.DESCRIPTION_FLAG_EMPTY);
|
||||
this.addFlag(GreetingFlag.GREETING_FLAG_EMPTY);
|
||||
this.addFlag(FarewellFlag.FAREWELL_FLAG_EMPTY);
|
||||
}
|
||||
|
||||
@Override public PlotFlag<?, ?> getFlagErased(Class<?> flagClass) {
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||
|
||||
public interface InternalFlag {
|
||||
}
|
@ -25,7 +25,7 @@ public class DescriptionFlag extends PlotFlag<String, DescriptionFlag> {
|
||||
}
|
||||
|
||||
@Override public String getExample() {
|
||||
return "&6Welcome to my plot!";
|
||||
return "&6This is my plot!";
|
||||
}
|
||||
|
||||
@Override protected DescriptionFlag flagOf(@NotNull String value) {
|
||||
|
@ -20,4 +20,5 @@ public class ExplosionFlag extends BooleanFlag<ExplosionFlag> {
|
||||
@Override protected ExplosionFlag flagOf(@NotNull Boolean value) {
|
||||
return value ? EXPLOSION_TRUE : EXPLOSION_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 FarewellFlag extends PlotFlag<String, FarewellFlag> {
|
||||
|
||||
public static final FarewellFlag FAREWELL_FLAG_EMPTY = new FarewellFlag("");
|
||||
|
||||
protected FarewellFlag(@NotNull String value) {
|
||||
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_FAREWELL);
|
||||
}
|
||||
|
||||
@Override public FarewellFlag parse(@NotNull String input) {
|
||||
return flagOf(input);
|
||||
}
|
||||
|
||||
@Override public FarewellFlag merge(@NotNull String newValue) {
|
||||
return flagOf(this.getValue() + " " + newValue);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
@Override public String getExample() {
|
||||
return "&cBye :(";
|
||||
}
|
||||
|
||||
@Override protected FarewellFlag flagOf(@NotNull String value) {
|
||||
return new FarewellFlag(value);
|
||||
}
|
||||
|
||||
}
|
@ -19,4 +19,5 @@ public class FlightFlag extends BooleanFlag<FlightFlag> {
|
||||
@Override protected FlightFlag flagOf(@NotNull Boolean value) {
|
||||
return new FlightFlag(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 GreetingFlag extends PlotFlag<String, GreetingFlag> {
|
||||
|
||||
public static final GreetingFlag GREETING_FLAG_EMPTY = new GreetingFlag("");
|
||||
|
||||
protected GreetingFlag(@NotNull String value) {
|
||||
super(value, Captions.FLAG_CATEGORY_STRING, Captions.FLAG_DESCRIPTION_GREETING);
|
||||
}
|
||||
|
||||
@Override public GreetingFlag parse(@NotNull String input) {
|
||||
return flagOf(input);
|
||||
}
|
||||
|
||||
@Override public GreetingFlag 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 GreetingFlag flagOf(@NotNull String value) {
|
||||
return new GreetingFlag(value);
|
||||
}
|
||||
|
||||
}
|
@ -19,4 +19,5 @@ public class UntrustedVisitFlag extends BooleanFlag<UntrustedVisitFlag> {
|
||||
@Override protected UntrustedVisitFlag flagOf(@NotNull Boolean value) {
|
||||
return new UntrustedVisitFlag(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ 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.DenyExitFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FarewellFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.GreetingFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -60,7 +62,7 @@ public class PlotListener {
|
||||
} else {
|
||||
titles = Settings.TITLES;
|
||||
}
|
||||
final String greeting;
|
||||
String greeting;
|
||||
if (flags.isEmpty()) {
|
||||
if (titles) {
|
||||
greeting = "";
|
||||
@ -69,9 +71,9 @@ public class PlotListener {
|
||||
}
|
||||
} else {
|
||||
titles = plot.getFlag(Flags.TITLES, titles);
|
||||
Optional<String> greetingFlag = plot.getFlag(Flags.GREETING);
|
||||
if (greetingFlag.isPresent()) {
|
||||
greeting = greetingFlag.get();
|
||||
|
||||
greeting = plot.getFlag(GreetingFlag.class);
|
||||
if (!greeting.isEmpty()) {
|
||||
MainUtil
|
||||
.format(Captions.PREFIX_GREETING.getTranslated() + greeting, plot, player,
|
||||
false,
|
||||
@ -80,8 +82,6 @@ public class PlotListener {
|
||||
MainUtil.sendMessage(player, value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
greeting = "";
|
||||
}
|
||||
Optional<Boolean> enter = plot.getFlag(Flags.NOTIFY_ENTER);
|
||||
if (enter.isPresent() && enter.get()) {
|
||||
@ -234,14 +234,18 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
Optional<String> farewell = plot.getFlag(Flags.FAREWELL);
|
||||
farewell.ifPresent(s -> MainUtil
|
||||
.format(Captions.PREFIX_FAREWELL.getTranslated() + s, plot, player, false,
|
||||
new RunnableVal<String>() {
|
||||
@Override public void run(String value) {
|
||||
MainUtil.sendMessage(player, value);
|
||||
}
|
||||
}));
|
||||
|
||||
final String farewell = plot.getFlag(FarewellFlag.class);
|
||||
if (!farewell.isEmpty()) {
|
||||
MainUtil
|
||||
.format(Captions.PREFIX_FAREWELL.getTranslated() + farewell, plot, player, false,
|
||||
new RunnableVal<String>() {
|
||||
@Override public void run(String value) {
|
||||
MainUtil.sendMessage(player, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Optional<Boolean> leave = plot.getFlag(Flags.NOTIFY_LEAVE);
|
||||
if (leave.isPresent() && leave.get()) {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.object;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@ -118,28 +115,6 @@ public class PlotSettings {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public String getJoinMessage(PlotArea area) {
|
||||
if (flags.containsKey(Flags.GREETING)) {
|
||||
return (String) flags.get(Flags.GREETING);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "farewell" flag value.
|
||||
*
|
||||
* @param plotArea The PlotArea
|
||||
* @return Farewell flag
|
||||
*/
|
||||
public String getLeaveMessage(PlotArea plotArea) {
|
||||
if (flags.containsKey(Flags.FAREWELL)) {
|
||||
return (String) flags.get(Flags.FAREWELL);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnstableApiUsage"}) public List<PlotComment> getComments(String inbox) {
|
||||
if (this.comments == null) {
|
||||
return Collections.emptyList();
|
||||
|
Loading…
Reference in New Issue
Block a user