MassiveCommand#getRequirementsError
This commit is contained in:
parent
0cf098302a
commit
89500be756
@ -659,22 +659,24 @@ public class MassiveCommand
|
|||||||
|
|
||||||
public List<Requirement> getRequirements() { return this.requirements; }
|
public List<Requirement> getRequirements() { return this.requirements; }
|
||||||
public void setRequirements(List<Requirement> requirements) { this.requirements = requirements; }
|
public void setRequirements(List<Requirement> requirements) { this.requirements = requirements; }
|
||||||
|
|
||||||
public void addRequirements(Requirement... requirements) { this.requirements.addAll(Arrays.asList(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())
|
for (Requirement requirement : this.getRequirements())
|
||||||
{
|
{
|
||||||
if (requirement.apply(sender, this)) continue;
|
if (requirement.apply(sender, this)) continue;
|
||||||
|
if ( ! verboose) return "";
|
||||||
if (informSenderIfNot)
|
return requirement.createErrorMessage(sender, this);
|
||||||
{
|
|
||||||
Mixin.messageOne(sender, requirement.createErrorMessage(sender, this));
|
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user