示例#1
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;
  }
示例#2
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());
  }
示例#3
0
 /** Constructor needs to be defined and properly call super() */
 public Build(Landlord plugin) {
   super(
       plugin,
       plugin
           .getMessageConfig()
           .getString("flags.build.displayName"), // Display name (will be displayed to players)
       plugin.getMessageConfig().getString("flags.build.description"),
       new ItemStack(Material.COBBLESTONE), // Itemstack (represented in manager)
       plugin
           .getMessageConfig()
           .getString("flags.build.allowedTitle"), // Text shown in manager for granted permission
       plugin
           .getMessageConfig()
           .getString(
               "flags.build.allowedText"), // Description in manager for granted permission (ex:
       // Friendly players <desc>)
       plugin
           .getMessageConfig()
           .getString("flags.build.deniedTitle"), // Text shown in manager for denied permission
       plugin
           .getMessageConfig()
           .getString("flags.build.deniedText") // Desciption in manager for denied permission (ex:
       // Regular players <desc>)
       );
 }