Add actionbar message for notification flags

- Move title_as_actionbar boolean into enabled_components
This commit is contained in:
NotMyFault 2021-05-24 13:49:00 +02:00
parent a69b1d895c
commit 1d2aa74e51
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
3 changed files with 42 additions and 25 deletions

View File

@ -311,7 +311,7 @@ permissions:
default: false
plots.permpack.basicflags:
default: op
default: false
children:
plots.set.flag: true
plots.flag: true
@ -360,7 +360,7 @@ permissions:
plots.set.flag.price.*: true
plots.set.flag.no-worldedit.*: true
plots.permpack.basicinbox:
default: op
default: false
children:
plots.inbox.read.public: true
plots.inbox.modify.public: true
@ -373,7 +373,7 @@ permissions:
plots.comment: true
plots.inbox: true
plots.permpack.wilderness:
default: op
default: false
children:
plots.admin.interact.unowned: true
plots.admin.destroy.unowned: true
@ -382,7 +382,7 @@ permissions:
plots.admin.vehicle.break.unowned: true
plots.admin.pve.unowned: true
plots.permpack.basic:
default: op
default: false
children:
plots.use: true
plots.info: true

View File

@ -46,7 +46,7 @@ public class Settings extends Config {
@Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.",
"Leave it off if you don't need it, it can spam your console."})
public static boolean DEBUG = false;
public static boolean DEBUG = true;
@Comment({"The big text that appears when you enter a plot.",
"For a single plot set `/plot flag set titles false` to disable it.", "For just you run `/plot toggle titles` to disable it.",
"For all plots: Add `titles: false` in the worlds.yml flags block to disable it."})
@ -58,11 +58,6 @@ public class Settings extends Config {
public static int TITLES_STAY = 50;
@Comment("Plot titles fading out (duration in ticks)")
public static int TITLES_FADE_OUT = 20;
@Comment({"Changes the notification method on plot entry from Title + SubTitle -> ActionBar.",
"The message still sent to the player is pulled from the lang key \"titles.title_entered_plot\".",
"If you would like to still show the owner of the plot, append the contents of \"titles.title_entered_plot_sub\" onto the " +
"former lang key."})
public static boolean TITLES_AS_ACTIONBAR = false;
@Create // This value will be generated automatically
public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null;
@ -663,7 +658,7 @@ public class Settings extends Config {
@Comment({"Time to wait in ms before beginning to notify player or console of progress.",
"Prevent needless notification of progress for short queues."})
public static int NOTIFY_WAIT = 5000;
@Comment({"How lighitng should be handled by the queue. Modes:",
@Comment({"How lighting should be handled by the queue. Modes:",
" - 0 - Do not do any lighting (fastest)",
" - 1 - Only execute lighting where blocks with light values are placed",
" - 2 - Only execute lighting where blocks with light values are placed or removed/replaced",
@ -723,7 +718,7 @@ public class Settings extends Config {
public static boolean KILL_ROAD_VEHICLES = false;
@Comment("Notify a player of any missed plot comments upon plot entry")
public static boolean
COMMENT_NOTIFIER = false;
COMMENT_NOTIFIER = true;
@Comment("Let players claim entire worlds with PlotSquared")
public static boolean WORLDS =
false;
@ -763,6 +758,14 @@ public class Settings extends Config {
);
@Comment("Whether PlotSquared should hook into MvDWPlaceholderAPI or not")
public static boolean USE_MVDWAPI = true;
@Comment({"Changes the notification method on plot entry from Title + SubTitle -> ActionBar.",
"The message still sent to the player is pulled from the lang key \"titles.title_entered_plot\".",
"If you would like to still show the owner of the plot, append the contents of \"titles.title_entered_plot_sub\" onto the " +
"former lang key."})
public static boolean TITLES_AS_ACTIONBAR = false;
@Comment({"Whether an action bar message should be send over a chat message for notification purposes such for the ",
"notify-enter, notify-leave, greeting or farewell flag."})
public static boolean NOTIFICATION_AS_ACTIONBAR = false;
}

View File

@ -171,7 +171,11 @@ public class PlotListener {
final String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
} else {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar);
}
}
if (plot.getFlag(NotifyEnterFlag.class)) {
@ -179,11 +183,14 @@ public class PlotListener {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
owner.sendMessage(
TranslatableCaption.of("notification.notify_enter"),
Template.of("player", player.getName()),
Template.of("plot", plot.getId().toString())
);
Caption caption = TranslatableCaption.of("notification.notify_enter");
Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString());
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate);
} else {
owner.sendActionBar(caption, playerTemplate, plotTemplate);
}
}
}
}
@ -305,7 +312,7 @@ public class PlotListener {
Template ownerTemplate = Template.of("owner", owner);
final Consumer<String> userConsumer = user -> {
if (Settings.TITLES_AS_ACTIONBAR) {
if (Settings.Enabled_Components.TITLES_AS_ACTIONBAR) {
player.sendActionBar(header, plotTemplate, worldTemplate, ownerTemplate);
} else {
player.sendTitle(header, subHeader, plotTemplate, worldTemplate, ownerTemplate);
@ -385,7 +392,11 @@ public class PlotListener {
final String farewell = plot.getFlag(FarewellFlag.class);
if (!farewell.isEmpty()) {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
} else {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar);
}
}
if (plot.getFlag(NotifyLeaveFlag.class)) {
@ -393,11 +404,14 @@ public class PlotListener {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
owner.sendMessage(
TranslatableCaption.of("notification.notify_leave"),
Template.of("player", player.getName()),
Template.of("plot", plot.getId().toString())
);
Caption caption = TranslatableCaption.of("notification.notify_leave");
Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString());
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate);
} else {
owner.sendActionBar(caption, playerTemplate, plotTemplate);
}
}
}
}