Add toggle for time

This commit is contained in:
jewome62 2019-08-11 21:15:02 +02:00
parent 8ab10de4ad
commit ca954ccc97
5 changed files with 16 additions and 1 deletions

View File

@ -126,6 +126,7 @@ permissions:
plots.toggle: true
plots.toggle.titles: true
plots.toggle.chat: true
plots.toggle.time: true
plots.set.biome: true
plots.set.home: true
plots.set.alias: true

View File

@ -75,6 +75,18 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
}
}
@CommandDeclaration(command = "time", permission = "plots.toggle.time",
description = "Toggle plot time settings")
public void time(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) {
if (toggle(player, "disabletime")) {
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
} else {
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
}
}
public boolean toggle(PlotPlayer player, String key) {
if (player.getAttribute(key)) {
player.removeAttribute(key);

View File

@ -52,6 +52,7 @@ public enum Captions {
PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass", "static.permissions"),
PERMISSION_PLOT_TOGGLE_TITLES("plots.toggle.titles", "static.permissions"),
PERMISSION_PLOT_TOGGLE_CHAT("plots.toggle.chat", "static.permissions"),
PERMISSION_PLOT_TOGGLE_TIME("plots.toggle.time", "static.permissions"),
PERMISSION_ADMIN_UPDATE_NOTIFICATION("plots.admin.update.notify", "static.permissions"),
PERMISSION_ADMIN_EXIT_DENIED("plots.admin.exit.denied", "static.permissions"),
PERMISSION_ADMIN_ENTRY_DENIED("plots.admin.entry.denied", "static.permissions"),

View File

@ -122,7 +122,7 @@ public class PlotListener {
}
}
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
if (timeFlag.isPresent()) {
if (timeFlag.isPresent() && !player.getAttribute("disabletime")) {
try {
long time = timeFlag.get();
player.setTime(time);

View File

@ -119,6 +119,7 @@ permissions:
plots.toggle: true
plots.toggle.titles: true
plots.toggle.chat: true
plots.toggle.time: true
plots.set.biome: true
plots.set.home: true
plots.set.alias: true