Fix NodeFactory#nodeAsCommand when unsetting meta nodes, fix meta unset command

This commit is contained in:
Luck 2017-09-06 21:56:41 +01:00
parent 649748c2d3
commit 81cf50520b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 35 additions and 23 deletions

View File

@ -70,14 +70,18 @@ public class MetaUnset extends SharedSubCommand {
return CommandResult.NO_PERMISSION; return CommandResult.NO_PERMISSION;
} }
holder.clearMetaKeys(key, context, false); if (holder.clearMetaKeys(key, context, false)) {
Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context)); Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder) ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta unset " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) .action("meta unset " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(holder, sender, plugin); save(holder, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} else {
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName());
return CommandResult.STATE_ERROR;
}
} }
} }

View File

@ -70,14 +70,18 @@ public class MetaUnsetTemp extends SharedSubCommand {
return CommandResult.NO_PERMISSION; return CommandResult.NO_PERMISSION;
} }
holder.clearMetaKeys(key, context, true); if (holder.clearMetaKeys(key, context, true)) {
Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context)); Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), Util.contextSetToString(context));
ExtendedLogEntry.build().actor(sender).acted(holder) ExtendedLogEntry.build().actor(sender).acted(holder)
.action("meta unsettemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) .action("meta unsettemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" ")))
.build().submit(plugin, sender); .build().submit(plugin, sender);
save(holder, sender, plugin); save(holder, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} else {
Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName());
return CommandResult.STATE_ERROR;
}
} }
} }

View File

@ -265,13 +265,15 @@ public enum Message {
REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had temporary {1} &f\"{2}&f\"&a at priority &b{3}&a removed in context {4}&a.", true), REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had temporary {1} &f\"{2}&f\"&a at priority &b{3}&a removed in context {4}&a.", true),
BULK_REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had all temporary {1}es at priority &b{2}&a removed in context {3}&a.", true), BULK_REMOVE_TEMP_CHATMETA_SUCCESS("&b{0}&a had all temporary {1}es at priority &b{2}&a removed in context {3}&a.", true),
ALREADY_HAS_META("{0} already has that meta key value pair set.", true), ALREADY_HAS_META("{0} already has that meta pair set.", true),
SET_META_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a in context {3}&a.", true), SET_META_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a in context {3}&a.", true),
SET_META_TEMP_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a for a duration of &b{3}&a in context {4}&a.", true), SET_META_TEMP_SUCCESS("&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a for a duration of &b{3}&a in context {4}&a.", true),
UNSET_META_SUCCESS("&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a.", true), UNSET_META_SUCCESS("&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a.", true),
UNSET_META_TEMP_SUCCESS("&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a.", true), UNSET_META_TEMP_SUCCESS("&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a.", true),
DOESNT_HAVE_META("{0} does not have that meta pair set.", true),
BULK_UPDATE_INVALID_DATA_TYPE("Invalid type. Was expecting 'all', 'users' or 'groups'.", true), BULK_UPDATE_INVALID_DATA_TYPE("Invalid type. Was expecting 'all', 'users' or 'groups'.", true),
BULK_UPDATE_INVALID_CONSTRAINT("Invalid constraint &4{0}&c. Constraints should be in the format '&f<field> <comparison operator> <value>&c'.", true), BULK_UPDATE_INVALID_CONSTRAINT("Invalid constraint &4{0}&c. Constraints should be in the format '&f<field> <comparison operator> <value>&c'.", true),
BULK_UPDATE_INVALID_COMPARISON("Invalid comparison operator '&4{0}&c'. Expected one of the following: &f== != ~~ ~!", true), BULK_UPDATE_INVALID_COMPARISON("Invalid comparison operator '&4{0}&c'. Expected one of the following: &f== != ~~ ~!", true),

View File

@ -180,16 +180,18 @@ public class NodeFactory {
sb.append(node.getMeta().getKey()); sb.append(node.getMeta().getKey());
} }
sb.append(" "); if (set) {
sb.append(" ");
if (node.getMeta().getValue().contains(" ")) { if (node.getMeta().getValue().contains(" ")) {
sb.append("\"").append(node.getMeta().getValue()).append("\""); sb.append("\"").append(node.getMeta().getValue()).append("\"");
} else { } else {
sb.append(node.getMeta().getValue()); sb.append(node.getMeta().getValue());
} }
if (node.isTemporary()) { if (node.isTemporary()) {
sb.append(" ").append(node.getExpiryUnixTime()); sb.append(" ").append(node.getExpiryUnixTime());
}
} }
return appendContextToCommand(sb, node).toString(); return appendContextToCommand(sb, node).toString();