示例#1
0
  @Override
  public String getHelpText(CommandSender sender) {
    // mess
    String usage = "/#{label} #{cmd} <player>"; // get the base usage string
    String desc =
        Fonctions.replaceColor(
            Landlord.getMessages().getString("descRemoveFriendCommand")); // get the description

    // return the constructed and colorized help string
    return Utils.helpString(usage, desc, getTriggers()[0].toLowerCase());
  }
示例#2
0
  /**
   * Removes a friend from an owned chunk Called when landlord remfriend is executed
   *
   * @param sender who executed the command
   * @param args given with command
   * @return boolean
   */
  @Override
  public boolean execute(CommandSender sender, String[] args, String label) {
    if (!(sender instanceof Player)) {
      sender.sendMessage(
          Fonctions.replaceColor(Landlord.getMessages().getString("noConsole"))); // mess
    } else {
      if (args.length < 2) {
        sender.sendMessage(
            Fonctions.replaceColor(Landlord.getMessages().getString("usageLandUnfriend"))); // mess
        return true;
      }
      Player player = (Player) sender;
      if (!player.hasPermission("landlord.player.own")) {
        player.sendMessage(
            Fonctions.replaceColor(Landlord.getMessages().getString("noPermission"))); // mess
        return true;
      }

      Chunk currChunk = player.getLocation().getChunk();
      /*
       * *************************************
       * mark for possible change    !!!!!!!!!
       * *************************************
       */
      Friend frd = Friend.friendFromOfflinePlayer(getOfflinePlayer(args[1]));
      OwnedLand land =
          OwnedLand.getLandFromDatabase(
              currChunk.getX(), currChunk.getZ(), currChunk.getWorld().getName());
      if (land == null
          || (!land.ownerUUID().equals(player.getUniqueId())
              && !player.hasPermission("landlord.admin.modifyfriends"))) {
        player.sendMessage(
            Fonctions.replaceColor(Landlord.getMessages().getString("noOwner"))); // mess
        return true;
      }
      if (!land.removeFriend(frd)) {
        player.sendMessage(
            Fonctions.replaceColor(Landlord.getMessages().getString("playerNotFriendLand"))
                .replaceAll("%pseudo%", args[1])); // mess
        return true;
      }
      if (plugin.getConfig().getBoolean("options.particleEffects", true)) { // conf
        land.highlightLand(player, Effect.VILLAGER_THUNDERCLOUD, 2);
      }
      plugin.getDatabase().save(land);
      if (plugin.getConfig().getBoolean("options.soundEffects", true)) { // conf
        player.playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 10, .5f);
      }
      player.sendMessage(
          Fonctions.replaceColor(Landlord.getMessages().getString("playerIsNoLongerFriendLand"))
              .replaceAll("%pseudo%", args[1])); // mess
    }
    return true;
  }