コード例 #1
0
  /**
   * Announce to players that a rival is in their base
   *
   * @param field
   * @param rivalName
   */
  public void bypassAnnounce(Field field, String rivalName) {
    if (!hasSimpleClans()) {
      return;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(field.getOwner());
    ClanPlayer rivalCp = simpleClans.getClanManager().getClanPlayer(rivalName);

    if (cp != null && rivalCp != null) {
      cp.getClan()
          .audioAnnounce(
              "PreciousStones",
              Helper.capitalize(rivalName)
                  + " of rival clan "
                  + Helper.stripColors(rivalCp.getClan().getColorTag())
                  + " has entered one of "
                  + Helper.posessive(Helper.stripColors(cp.getClan().getColorTag()))
                  + " bases ["
                  + field.getX()
                  + " "
                  + field.getY()
                  + " "
                  + field.getZ()
                  + " "
                  + field.getWorld()
                  + "]");
    }
  }
コード例 #2
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    ClanPlayer clanPlayer = clanManager.getClanPlayer(player);
    if (clanPlayer == null) return;
    System.out.println(player.getName() + " is in SimpleClans db.");
    Clan clan = clanPlayer.getClan();
    if (clan == null) // If not part of a clan, do no more
    return;

    final String tag = clan.getColorTag();
    System.out.println(player.getName() + " has a clan: " + tag);

    // Feature: set prefix in tablist
    // compatible with other prefix/suffix plugins since we just set PlayerListName
    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            player.setPlayerListName(tag + " " + player.getDisplayName());
          }
        },
        30L); // Long delay to ensure this has priority & no need to instantly set

    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            Team team = sb.getTeam(player.getName());
            if (team == null) return;
            team.setPrefix(tag + " "); // TODO: Check if a colored tag colors name
          }
        },
        40L); // Ensure healthbar made the team
  }
コード例 #3
0
  /**
   * Adds a message to the player's clan's BB
   *
   * @param player
   * @param message
   */
  public void addBB(Player player, String message) {
    if (!hasSimpleClans()) {
      return;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(player);

    if (cp != null) {
      cp.getClan().addBb("[PreciousStones]", message);
    }
  }
コード例 #4
0
  /**
   * Announce to players clan
   *
   * @param playerName
   * @param message
   */
  public void clanAnnounce(String playerName, String message) {
    if (!hasSimpleClans()) {
      return;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(playerName);

    if (cp != null) {
      cp.getClan().clanAnnounce("PreciousStones", message);
    }
  }
コード例 #5
0
  /**
   * @param playerName
   * @return
   */
  public String getClan(String playerName) {
    if (!hasSimpleClans()) {
      return null;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(playerName);

    if (cp != null) {
      return cp.getTag();
    }

    return null;
  }
コード例 #6
0
ファイル: KickCommand.java プロジェクト: Psithief/SimpleClans
  @Override
  public void execute(Player player, String label, String[] args) {

    if (plugin.getPermissionsManager().has(player, "simpleclans.leader.kick")) {
      ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);

      if (cp != null) {
        Clan clan = cp.getClan();

        if (clan.isLeader(player)) {
          String kicked = args[0];

          if (kicked != null) {
            if (!kicked.equals(player.getName())) {
              if (clan.isMember(kicked)) {
                if (!clan.isLeader(kicked)) {
                  clan.addBb(
                      player.getName(),
                      ChatColor.AQUA
                          + MessageFormat.format(
                              plugin.getLang("has.been.kicked.by"),
                              Helper.capitalize(kicked),
                              player.getName()));
                  clan.removePlayerFromClan(kicked);
                } else {
                  ChatBlock.sendMessage(
                      player, ChatColor.RED + plugin.getLang("you.cannot.kick.another.leader"));
                }
              } else {
                ChatBlock.sendMessage(
                    player,
                    ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
              }
            } else {
              ChatBlock.sendMessage(
                  player, ChatColor.RED + plugin.getLang("you.cannot.kick.yourself"));
            }
          } else {
            ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
          }
        } else {
          ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
        }
      } else {
        ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
      }
    } else {
      ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
    }
  }
コード例 #7
0
  /**
   * Check if a player is in a clan
   *
   * @param playerName
   * @param clanName
   * @return
   */
  public boolean isInClan(String playerName, String clanName) {
    if (!hasSimpleClans()) {
      return false;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(playerName);

    if (cp != null) {
      if (cp.getTag().equals(clanName)) {
        return true;
      }
    }

    return false;
  }
コード例 #8
0
  /**
   * Check whether any of a player's clan members are online
   *
   * @param playerName
   * @return
   */
  public boolean isAnyOnline(String playerName) {
    if (!hasSimpleClans()) {
      return false;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(playerName);

    if (cp != null) {
      if (cp.getClan().isAnyOnline()) {
        return true;
      }
    }

    return false;
  }
コード例 #9
0
  /**
   * Check if two players are clanmates
   *
   * @param playerOne
   * @param playerTwo
   * @return
   */
  public boolean isClanMate(String playerOne, String playerTwo) {
    if (!hasSimpleClans()) {
      return false;
    }

    ClanPlayer cp1 = simpleClans.getClanManager().getClanPlayer(playerOne);
    ClanPlayer cp2 = simpleClans.getClanManager().getClanPlayer(playerTwo);

    if (cp1 != null && cp2 != null) {
      if (cp1.getClan().equals(cp2.getClan())) {
        return true;
      }
    }

    return false;
  }
コード例 #10
0
  /**
   * @param owner
   * @param playerName
   * @return
   */
  public boolean isAllyOwner(String owner, String playerName) {
    if (!hasSimpleClans()) {
      return false;
    }

    Player player = plugin.getServer().getPlayerExact(playerName);

    if (player != null) {
      ClanPlayer cpOwner = simpleClans.getClanManager().getClanPlayer(owner);

      if (cpOwner != null) {
        return cpOwner.isAlly(player);
      }
    }

    return false;
  }
コード例 #11
0
  /**
   * Execute the command
   *
   * @param player
   * @param arg
   */
  public void execute(Player player, String[] arg) {
    SimpleClans plugin = SimpleClans.getInstance();

    if (plugin.getPermissionsManager().has(player, "simpleclans.member.resign")) {
      ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);

      if (cp != null) {
        Clan clan = cp.getClan();

        if (!clan.isLeader(player) || clan.getLeaders().size() > 1) {
          clan.addBb(
              player.getName(),
              ChatColor.AQUA
                  + MessageFormat.format(
                      plugin.getLang().getString("0.has.resigned"),
                      Helper.capitalize(player.getName())));
          clan.removePlayerFromClan(player.getName());
        } else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
          plugin
              .getClanManager()
              .serverAnnounce(
                  ChatColor.AQUA
                      + MessageFormat.format(
                          plugin.getLang().getString("clan.has.been.disbanded"), clan.getName()));
          clan.disband();
        } else {
          ChatBlock.sendMessage(
              player,
              ChatColor.RED
                  + plugin
                      .getLang()
                      .getString(
                          "last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan"));
        }
      } else {
        ChatBlock.sendMessage(
            player, ChatColor.RED + plugin.getLang().getString("not.a.member.of.any.clan"));
      }
    } else {
      ChatBlock.sendMessage(
          player, ChatColor.RED + plugin.getLang().getString("insufficient.permissions"));
    }
  }
コード例 #12
0
  /**
   * Check if
   *
   * @param field
   * @param offenderName
   * @return
   */
  public boolean inWar(Field field, String offenderName) {
    if (!hasSimpleClans()) {
      return false;
    }

    ClanPlayer cp = simpleClans.getClanManager().getClanPlayer(offenderName);
    ClanPlayer cpOwner = simpleClans.getClanManager().getClanPlayer(field.getOwner());

    if (cp != null && cpOwner != null) {
      List<Clan> warringClans = cp.getClan().getWarringClans();

      String ownerClan = cpOwner.getTag();

      for (Clan warring : warringClans) {
        if (ownerClan.equals(warring.getTag())) {
          return true;
        }
      }
    }

    return false;
  }
コード例 #13
0
ファイル: KickCommand.java プロジェクト: Psithief/SimpleClans
 @Override
 public String getMenu(ClanPlayer cp, CommandSender sender) {
   if (cp != null) {
     if (cp.isLeader()) {
       if (plugin.getPermissionsManager().has(sender, "simpleclans.leader.kick")) {
         return MessageFormat.format(
             plugin.getLang("0.kick.player.1.kick.a.player.from.the.clan"),
             plugin.getSettingsManager().getCommandClan(),
             ChatColor.WHITE);
       }
     }
   }
   return null;
 }
コード例 #14
0
  /**
   * Execute the command
   *
   * @param player
   * @param arg
   */
  public void execute(Player player, String[] arg) {
    SimpleClans plugin = SimpleClans.getInstance();

    if (plugin.getPermissionsManager().has(player, "simpleclans.leader.invite")) {
      ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);

      if (cp != null) {
        Clan clan = cp.getClan();

        if (clan.isLeader(player)) {
          if (arg.length == 1) {
            Player invited = Helper.matchOnePlayer(arg[0]);

            if (invited != null) {
              if (plugin.getPermissionsManager().has(invited, "simpleclans.member.can-join")) {
                if (!invited.getName().equals(player.getName())) {
                  if (!plugin.getSettingsManager().isBanned(player.getName())) {
                    ClanPlayer cpInv = plugin.getClanManager().getClanPlayer(invited);

                    if (cpInv == null) {
                      plugin.getRequestManager().addInviteRequest(cp, invited.getName(), clan);
                      ChatBlock.sendMessage(
                          player,
                          ChatColor.AQUA
                              + MessageFormat.format(
                                  plugin.getLang().getString("has.been.asked.to.join"),
                                  Helper.capitalize(invited.getName()),
                                  clan.getName()));
                    } else {
                      ChatBlock.sendMessage(
                          player,
                          ChatColor.RED
                              + plugin
                                  .getLang()
                                  .getString("the.player.is.already.member.of.another.clan"));
                    }
                  } else {
                    ChatBlock.sendMessage(
                        player,
                        ChatColor.RED
                            + plugin
                                .getLang()
                                .getString("this.player.is.banned.from.using.clan.commands"));
                  }
                } else {
                  ChatBlock.sendMessage(
                      player,
                      ChatColor.RED + plugin.getLang().getString("you.cannot.invite.yourself"));
                }
              } else {
                ChatBlock.sendMessage(
                    player,
                    ChatColor.RED
                        + plugin
                            .getLang()
                            .getString(
                                "the.player.doesn.t.not.have.the.permissions.to.join.clans"));
              }
            } else {
              ChatBlock.sendMessage(
                  player, ChatColor.RED + plugin.getLang().getString("no.player.matched"));
            }
          } else {
            ChatBlock.sendMessage(
                player,
                ChatColor.RED
                    + MessageFormat.format(
                        plugin.getLang().getString("usage.0.invite.player"),
                        plugin.getSettingsManager().getCommandClan()));
          }
        } else {
          ChatBlock.sendMessage(
              player, ChatColor.RED + plugin.getLang().getString("no.leader.permissions"));
        }
      } else {
        ChatBlock.sendMessage(
            player, ChatColor.RED + plugin.getLang().getString("not.a.member.of.any.clan"));
      }
    } else {
      ChatBlock.sendMessage(
          player, ChatColor.RED + plugin.getLang().getString("insufficient.permissions"));
    }
  }