mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-04 18:00:00 +01:00
Add /npc command hideerrors
This commit is contained in:
parent
78824a341e
commit
968f3fd68b
@ -394,6 +394,10 @@ public class NPCCommands {
|
||||
} else if (args.getString(1).equalsIgnoreCase("expcost")) {
|
||||
commands.setExperienceCost((float) args.getDouble(2));
|
||||
Messaging.sendTr(sender, Messages.COMMAND_EXPERIENCE_COST_SET, args.getDouble(2));
|
||||
} else if (args.getString(1).equalsIgnoreCase("hideerrors")) {
|
||||
commands.setHideErrorMessages(!commands.isHideErrorMessages());
|
||||
Messaging.sendTr(sender, commands.isHideErrorMessages() ? Messages.COMMAND_HIDE_ERROR_MESSAGES_SET
|
||||
: Messages.COMMAND_HIDE_ERROR_MESSAGES_UNSET);
|
||||
} else if (args.getString(1).equalsIgnoreCase("random")) {
|
||||
commands.setExecutionMode(
|
||||
commands.getExecutionMode() == ExecutionMode.RANDOM ? ExecutionMode.LINEAR : ExecutionMode.RANDOM);
|
||||
|
@ -68,6 +68,8 @@ public class CommandTrait extends Trait {
|
||||
@Persist
|
||||
private final Map<String, Long> globalCooldowns = Maps.newHashMap();
|
||||
@Persist
|
||||
private boolean hideErrorMessages;
|
||||
@Persist
|
||||
private List<ItemStack> itemRequirements = Lists.newArrayList();
|
||||
@Persist
|
||||
private final List<String> temporaryPermissions = Lists.newArrayList();
|
||||
@ -296,12 +298,19 @@ public class CommandTrait extends Trait {
|
||||
return commands.containsKey(String.valueOf(id));
|
||||
}
|
||||
|
||||
public boolean isHideErrorMessages() {
|
||||
return hideErrorMessages;
|
||||
}
|
||||
|
||||
public void removeCommandById(int id) {
|
||||
commands.remove(String.valueOf(id));
|
||||
}
|
||||
|
||||
private void sendErrorMessage(Player player, CommandTraitMessages msg, Function<String, String> transform,
|
||||
Object... objects) {
|
||||
if (hideErrorMessages) {
|
||||
return;
|
||||
}
|
||||
Set<CommandTraitMessages> sent = executionErrors.get(player.getUniqueId().toString());
|
||||
if (sent != null) {
|
||||
if (sent.contains(msg))
|
||||
@ -329,6 +338,10 @@ public class CommandTrait extends Trait {
|
||||
this.experienceCost = experienceCost;
|
||||
}
|
||||
|
||||
public void setHideErrorMessages(boolean hide) {
|
||||
this.hideErrorMessages = hide;
|
||||
}
|
||||
|
||||
public void setTemporaryPermissions(List<String> permissions) {
|
||||
temporaryPermissions.clear();
|
||||
temporaryPermissions.addAll(permissions);
|
||||
@ -350,6 +363,11 @@ public class CommandTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
public enum ErrorHandling {
|
||||
ERROR_MESSAGE,
|
||||
RUN_ANYWAY;
|
||||
}
|
||||
|
||||
public enum ExecutionMode {
|
||||
LINEAR,
|
||||
RANDOM,
|
||||
|
@ -59,6 +59,8 @@ public class Messages {
|
||||
public static final String COMMAND_COST_SET = "citizens.commands.npc.command.cost-set";
|
||||
public static final String COMMAND_EXPERIENCE_COST_SET = "citizens.commands.npc.command.experience-cost-set";
|
||||
public static final String COMMAND_HELP_HEADER = "citizens.commands.help.header";
|
||||
public static final String COMMAND_HIDE_ERROR_MESSAGES_SET = "citizens.commands.npc.command.hide-error-messages-set";
|
||||
public static final String COMMAND_HIDE_ERROR_MESSAGES_UNSET = "citizens.commands.npc.command.hide-error-messages-unset";
|
||||
public static final String COMMAND_INVALID_MOBTYPE = "citizens.commands.invalid-mobtype";
|
||||
public static final String COMMAND_LEFT_HAND_HEADER = "citizens.commands.npc.command.left-hand-header";
|
||||
public static final String COMMAND_MISSING = "citizens.commands.help.command-missing";
|
||||
|
@ -51,6 +51,8 @@ citizens.commands.npc.collidable.set=[[{0}]] will now collide with entities.
|
||||
citizens.commands.npc.collidable.unset=[[{0}]] will no longer collide with entities.
|
||||
citizens.commands.npc.command.none-added=No commands have been added.
|
||||
citizens.commands.npc.command.cost-set=Set cost per click to [[{0}]].
|
||||
citizens.commands.npc.command.hide-error-messages-set=Now hiding error messages.
|
||||
citizens.commands.npc.command.hide-error-messages-unset=No longer hiding error messages.
|
||||
citizens.commands.npc.command.experience-cost-set=Set experience cost per click to [[{0}]].
|
||||
citizens.commands.npc.command.left-hand-header=Commands to run on [[left click]]:
|
||||
citizens.commands.npc.command.right-hand-header=Commands to run on [[right click]]:
|
||||
|
Loading…
Reference in New Issue
Block a user