Ejemplo n.º 1
0
  /**
   * Called when the players use the port command.
   *
   * @param sender the sender of the command.
   * @param command the command itself.
   * @param label the label used for calling the command.
   * @param args the arguments passed to the command.
   * @return true, if the CommandExecutor could handle the command.
   */
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
      sender.sendMessage(
          "Only use the /depart command as players! Doesn't make sense anyway for you ;)");

      return true;
    }

    if (args.length > 0) {
      SubCommandExecutor subCommandExecutor = subCommands.get(args[0]);

      if (subCommandExecutor != null) {
        if (subCommandExecutor.isValidNumberOfArguments(args.length - 1)) {
          PermissionHandler permissionsHandler = plugin.getPermissionsHandler();
          Permission requiredPermission = subCommandExecutor.getRequiredPermission();

          if (requiredPermission == null
              || permissionsHandler.hasPermission(sender, requiredPermission)) {
            return subCommandExecutor.onCommand(sender, command, label, args);
          }
        } else {
          ChatHelper.sendMessage(sender, Messages.get("moderator.problem.invalid-num-args"));
        }
      } else {
        ChatHelper.sendMessage(sender, Messages.get("moderator.problem.invalid-use"));
      }

      return true;
    } else {
      return false;
    }
  }
Ejemplo n.º 2
0
  /** Loads the configuration. */
  private void loadConfiguration() {
    // Properties...
    ARRIVED_NOTIFICATION_DELAY = getConfig().getInt("arrived-notification-delay", 10);
    DEPART_DELAY = getConfig().getInt("depart-delay", 0);
    PAY_OWNER = getConfig().getBoolean("pay-owner", true);
    NOTIFY_OWNER = getConfig().getBoolean("notify-owner", false);

    // Messages...
    Messages.load(getMessagesConfig());

    // TravelPorts...
    travelPortContainer =
        new FlatFileTravelPortContainer(this, new File(getDataFolder(), "ports.csv"));
    travelPortContainer.load();
  }