Fix claim option command adding wrong context.

The claim option command should no longer add a claim context when using
default or override contexts.

* Fix invalid value error when using 'undefined' to unset an option
using claim option commands.
This commit is contained in:
bloodshot 2020-02-01 12:42:27 -05:00
parent 99d0085d96
commit 44fc1c94e6
2 changed files with 16 additions and 4 deletions

View File

@ -217,7 +217,7 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
showOptionPermissions(src, (GDClaim) claim, MenuType.CLAIM);
return;
} else if (option != null && value != null) {
if (!((GDOption) option).validateStringValue(value, false)) {
if (!value.equalsIgnoreCase("undefined") && !((GDOption) option).validateStringValue(value, false)) {
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.OPTION_INVALID_VALUE,
ImmutableMap.of(
"value", value,
@ -227,17 +227,23 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
}
MenuType type = MenuType.DEFAULT;
boolean useClaimContext = true;
for (Context context : contextSet) {
if (context.getKey().equals(ContextKeys.CLAIM_DEFAULT)) {
useClaimContext = false;
break;
}
if (context.getKey().equals(ContextKeys.CLAIM)) {
type = MenuType.CLAIM;
break;
}
if (context.getKey().equals(ContextKeys.CLAIM_OVERRIDE)) {
type = MenuType.OVERRIDE;
useClaimContext = false;
break;
}
}
if (!option.isGlobal()) {
if (!option.isGlobal() && useClaimContext) {
contextSet.add(claim.getContext());
if (contextSet.isEmpty() ) {
type = MenuType.CLAIM;

View File

@ -217,7 +217,7 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
showOptionPermissions(src, (GDClaim) claim, MenuType.CLAIM);
return;
} else if (option != null && value != null) {
if (!((GDOption) option).validateStringValue(value, false)) {
if (!value.equalsIgnoreCase("undefined") && !((GDOption) option).validateStringValue(value, false)) {
GriefDefenderPlugin.sendMessage(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.OPTION_INVALID_VALUE,
ImmutableMap.of(
"value", value,
@ -227,17 +227,23 @@ public void execute(Player player, String[] args) throws InvalidCommandArgument
}
MenuType type = MenuType.DEFAULT;
boolean useClaimContext = true;
for (Context context : contextSet) {
if (context.getKey().equals(ContextKeys.CLAIM_DEFAULT)) {
useClaimContext = false;
break;
}
if (context.getKey().equals(ContextKeys.CLAIM)) {
type = MenuType.CLAIM;
break;
}
if (context.getKey().equals(ContextKeys.CLAIM_OVERRIDE)) {
type = MenuType.OVERRIDE;
useClaimContext = false;
break;
}
}
if (!option.isGlobal()) {
if (!option.isGlobal() && useClaimContext) {
contextSet.add(claim.getContext());
if (contextSet.isEmpty() ) {
type = MenuType.CLAIM;