From 89500be756e9809195570ce0b057fabf20bcee61 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sat, 6 Feb 2016 14:33:04 +0100 Subject: [PATCH] MassiveCommand#getRequirementsError --- .../massivecore/command/MassiveCommand.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/com/massivecraft/massivecore/command/MassiveCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommand.java index 2fd74f00..656d8465 100644 --- a/src/com/massivecraft/massivecore/command/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommand.java @@ -659,22 +659,24 @@ public class MassiveCommand public List getRequirements() { return this.requirements; } public void setRequirements(List requirements) { this.requirements = requirements; } - public void addRequirements(Requirement... requirements) { this.requirements.addAll(Arrays.asList(requirements)); } - public boolean isRequirementsMet(CommandSender sender, boolean informSenderIfNot) + public boolean isRequirementsMet(CommandSender sender, boolean verboose) + { + String error = this.getRequirementsError(sender, verboose); + if (error != null && verboose) Mixin.messageOne(sender, error); + return error == null; + } + + public String getRequirementsError(CommandSender sender, boolean verboose) { for (Requirement requirement : this.getRequirements()) { if (requirement.apply(sender, this)) continue; - - if (informSenderIfNot) - { - Mixin.messageOne(sender, requirement.createErrorMessage(sender, this)); - } - return false; + if ( ! verboose) return ""; + return requirement.createErrorMessage(sender, this); } - return true; + return null; } // -------------------------------------------- //