From 9597159f5ab204c7adb85594ef7a573941ad9f09 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Tue, 28 Feb 2012 13:39:23 +0100 Subject: [PATCH] added a few comments --- .../ancientgates/commands/BaseCommand.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/org/mcteam/ancientgates/commands/BaseCommand.java b/src/org/mcteam/ancientgates/commands/BaseCommand.java index 2f783d8..4346097 100644 --- a/src/org/mcteam/ancientgates/commands/BaseCommand.java +++ b/src/org/mcteam/ancientgates/commands/BaseCommand.java @@ -5,12 +5,14 @@ import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; + import org.mcteam.ancientgates.Gate; import org.mcteam.ancientgates.Plugin; import org.mcteam.ancientgates.Conf; import org.mcteam.ancientgates.util.TextUtil; -public class BaseCommand { +public class BaseCommand +{ public List aliases; public List requiredParameters; public List optionalParameters; @@ -26,7 +28,8 @@ public class BaseCommand { public List parameters; - public BaseCommand() { + public BaseCommand() + { aliases = new ArrayList(); requiredParameters = new ArrayList(); optionalParameters = new ArrayList(); @@ -70,25 +73,36 @@ public class BaseCommand { } } - public boolean validateCall() { - if ( this.senderMustBePlayer && ! (sender instanceof Player)) { + public boolean validateCall() + { + // validate player + if ( this.senderMustBePlayer && ! (sender instanceof Player)) + { sendMessage("This command can only be used by ingame players."); return false; } - if( ! hasPermission(sender)) { + // validate permission + if( ! hasPermission(sender)) + { sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+"."); return false; } - if (parameters.size() < requiredParameters.size()) { + // valide parameter count + if (parameters.size() < requiredParameters.size()) + { sendMessage("Usage: "+this.getUseageTemplate(true)); return false; } - if (this.hasGateParam) { + // validate gate parameter + if (this.hasGateParam) + { String id = parameters.get(0); - if ( ! Gate.exists(id)) { + + if ( ! Gate.exists(id)) + { sendMessage("There exists no gate with id "+id); return false; }