Add hide-info flag

This commit is contained in:
Sauilitired 2019-03-30 12:50:32 +01:00
parent d9407d6329
commit 08ebf57c90
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
3 changed files with 29 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
@ -10,7 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info",
usage = "/plot info <id>", category = CommandCategory.INFO) public class Info
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO) public class Info
extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -53,6 +54,7 @@ import java.util.UUID;
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT.s());
return false;
}
if (arg != null) {
if (args.length == 1) {
args = new String[0];
@ -60,6 +62,26 @@ import java.util.UUID;
args = new String[] {args[1]};
}
}
// hide-info flag
if (plot.getFlag(Flags.HIDE_INFO).orElse(false)) {
boolean allowed = false;
for (final String argument : args) {
if (argument.equalsIgnoreCase("-f")) {
if (!player.hasPermission(Captions.PERMISSION_AREA_INFO_FORCE.s())) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_INFO_FORCE);
return true;
}
allowed = true;
break;
}
}
if (!allowed) {
Captions.PLOT_INFO_HIDDEN.send(player);
return true;
}
}
if (args.length == 1 && args[0].equalsIgnoreCase("inv")) {
PlotInventory inv = new PlotInventory(player) {
@Override public boolean onClick(int index) {

View File

@ -65,6 +65,7 @@ public enum Captions {
"plots.admin.command.trust", "static.permissions"), PERMISSION_TRUST_EVERYONE(
"plots.trust.everyone", "static.permissions"), PERMISSION_AREA_CREATE("plots.area.create",
"static.permissions"), PERMISSION_AREA_INFO("plots.area.info",
"static.permissions"), PERMISSION_AREA_INFO_FORCE("plots.admin.info.force",
"static.permissions"), PERMISSION_AREA_LIST("plots.area.list",
"static.permissions"), PERMISSION_AREA_REGEN("plots.area.regen",
"static.permissions"), PERMISSION_AREA_TP("plots.area.tp",
@ -675,6 +676,8 @@ public enum Captions {
PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"), PLOT_INFO_HEADER(
"$3&m---------&r $1INFO $3&m---------", false, "Info"),
PLOT_INFO_HIDDEN("$2You cannot view the information about this plot", "Info"),
PLOT_INFO("$1ID: $2%id%$1&-" + "$1Alias: $2%alias%$1&-" + "$1Owner: $2%owner%$1&-"
+ "$1Biome: $2%biome%$1&-" + "$1Can Build: $2%build%$1&-" + "$1Rating: $2%rating%&-"
+ "$1Seen: $2%seen%&-" + "$1Trusted: $2%trusted%$1&-" + "$1Members: $2%members%$1&-"
@ -1067,4 +1070,5 @@ public enum Captions {
} else {
caller.sendMessage(msg);
}
}}
}
}

View File

@ -28,6 +28,7 @@ public final class Flags {
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave");
public static final BooleanFlag TITLES = new BooleanFlag("titles");
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
public static final BooleanFlag HIDE_INFO = new BooleanFlag("hide-info");
public static final LongFlag TIME = new LongFlag("time");
public static final PlotWeatherFlag WEATHER = new PlotWeatherFlag("weather");
public static final DoubleFlag PRICE = new DoubleFlag("price") {