public CloseableIterator<PlayerWarnData> getUnreadWarnings(UUID uniqueId) throws SQLException {
   return queryBuilder()
       .where()
       .eq("player_id", UUIDUtils.toBytes(uniqueId))
       .and()
       .eq("read", false)
       .iterator();
 }
Ejemplo n.º 2
0
  private void punishAlts(List<PlayerData> duplicates, UUID uuid) throws SQLException {

    if (!plugin.getPlayerBanStorage().isBanned(uuid)) {
      // Auto ban
      for (PlayerData player : duplicates) {
        if (player.getUUID().equals(uuid)) {
          continue;
        }

        PlayerBanData ban = plugin.getPlayerBanStorage().getBan(player.getUUID());

        if (ban == null) {
          continue;
        }
        if (ban.hasExpired()) {
          continue;
        }

        final PlayerBanData newBan =
            new PlayerBanData(
                plugin.getPlayerStorage().queryForId(UUIDUtils.toBytes(uuid)),
                plugin.getPlayerStorage().getConsole(),
                ban.getReason(),
                ban.getExpires());

        plugin.getPlayerBanStorage().ban(newBan, false);

        plugin
            .getServer()
            .getScheduler()
            .runTask(
                plugin,
                new Runnable() {

                  @Override
                  public void run() {
                    Player bukkitPlayer =
                        plugin.getServer().getPlayer(newBan.getPlayer().getUUID());

                    Message kickMessage =
                        Message.get("ban.player.kick")
                            .set("displayName", bukkitPlayer.getDisplayName())
                            .set("player", newBan.getPlayer().getName())
                            .set("reason", newBan.getReason())
                            .set("actor", newBan.getActor().getName());

                    bukkitPlayer.kickPlayer(kickMessage.toString());
                  }
                });
      }
    } else if (!plugin.getPlayerMuteStorage().isMuted(uuid)) {
      // Auto mute
      for (PlayerData player : duplicates) {
        if (player.getUUID().equals(uuid)) {
          continue;
        }

        PlayerMuteData mute = plugin.getPlayerMuteStorage().getMute(player.getUUID());

        if (mute == null) {
          continue;
        }
        if (mute.hasExpired()) {
          continue;
        }

        PlayerMuteData newMute =
            new PlayerMuteData(
                plugin.getPlayerStorage().queryForId(UUIDUtils.toBytes(uuid)),
                plugin.getPlayerStorage().getConsole(),
                mute.getReason(),
                mute.isSoft(),
                mute.getExpires());

        plugin.getPlayerMuteStorage().mute(newMute, false);
      }
    }
  }