Exemple #1
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamageByPlayer(final EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player == false || e.getDamager() instanceof Player == false)
      return;

    Player player = (Player) e.getEntity();
    Player target = (Player) e.getDamager();
    SCPlayer scp = getSCPlayer(player.getUniqueId());
    SCPlayer sct = getSCPlayer(target.getUniqueId());
    Faction faction = BoardColl.get().getFactionAt(PS.valueOf(target.getLocation().getChunk()));

    if (faction.getName().equalsIgnoreCase("Safezone")) {
      return;
    }

    final Faction pFaction = MPlayerColl.get().get(player).getFaction();
    final Faction tFaction = MPlayerColl.get().get(target).getFaction();

    if (pFaction.getRelationTo(tFaction) == Rel.MEMBER && !pFaction.isNone()) {
      return;
    }

    if (pFaction.getRelationTo(tFaction) == Rel.ALLY) {
      return;
    }

    scp.combatTag();
    sct.combatTag();
  }
Exemple #2
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerJoin(final PlayerJoinEvent e) {
    Player player = e.getPlayer();
    addSCPlayer(player.getUniqueId());
    SCPlayer scPlayer = getSCPlayer(player.getUniqueId());

    if (rankManager.getRank(player.getUniqueId()).getId() >= Rank.MOD.getId())
      staff(
          new FancyMessage("§9[STAFF] ")
              .then(scPlayer.getTag())
              .tooltip(scPlayer.getHoverText())
              .then(" §econnected."));

    e.setJoinMessage(null);
  }
Exemple #3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerQuit(final PlayerQuitEvent e) {
    Player player = e.getPlayer();
    SCPlayer scPlayer = getSCPlayer(player.getUniqueId());

    e.setQuitMessage(null);

    if (scPlayer.isCombatTagged()) {
      player.setHealth(0);
      scPlayer.removeCombatTag();
      broadcast(
          new FancyMessage(scPlayer.getTag())
              .tooltip(scPlayer.getHoverText())
              .then(" §5has logged off while in combat!"));
    }

    if (rankManager.getRank(player.getUniqueId()).getId() >= Rank.MOD.getId())
      staff(
          new FancyMessage("§9[STAFF] ")
              .then(scPlayer.getTag())
              .tooltip(scPlayer.getHoverText())
              .then(" §edisconnected."));

    removeSCPlayer(player.getUniqueId());
  }
Exemple #4
0
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerChat(final AsyncPlayerChatEvent e) {
    List<Punishment> punishments = punishmentManager.getPunishments(e.getPlayer().getUniqueId());

    for (Punishment punishment : punishments) {
      if (punishment.getType().equals(PunishmentType.MUTE)) {
        if (!punishment.hasExpired()) {
          e.getPlayer().sendMessage("§cYou are permanently muted.");
          e.setCancelled(true);
          return;
        }
      }

      if (punishment.getType().equals(PunishmentType.TEMPMUTE)) {
        if (!punishment.hasExpired()) {
          e.getPlayer()
              .sendMessage(
                  "§cYou are temporarily muted until §3" + punishment.getEndTimestamp() + " §c.");
          e.setCancelled(true);
          return;
        }
      }
    }

    e.setCancelled(true);

    Player player = e.getPlayer();
    SCPlayer scPlayer = getSCPlayer(player.getUniqueId());

    if (player.isOp()) e.setMessage(e.getMessage().replace('&', ChatColor.COLOR_CHAR));

    FancyMessage message =
        new FancyMessage(" §7- ")
            .then(scPlayer.getTag())
            .tooltip(scPlayer.getHoverText())
            .then("§8: §7" + e.getMessage());

    for (final Player other : e.getRecipients()) {
      if (other.getWorld() != player.getWorld()) continue;
      if (other.getLocation().distanceSquared(player.getLocation()) <= 900) message.send(other);
    }
  }