示例#1
0
  public static void loadPlayer(ProxiedPlayer player) {
    if (playerExists(player, FeatureDetector.canUseUUID())) {
      boolean tps;

      if (FeatureDetector.canUseUUID()) {
        tps = DatabaseManager.players.getPlayerTPS(player.getUUID());
      } else {
        tps = DatabaseManager.players.getPlayerTPS(player.getName());
      }

      GSPlayer gsPlayer =
          new GSPlayer(
              player.getName(),
              (FeatureDetector.canUseUUID()) ? player.getUUID() : null,
              tps,
              player.getAddress().getHostString());
      onlinePlayers.put(player.getName(), gsPlayer);

      DatabaseManager.players.updatePlayer(gsPlayer);

      LoggingManager.log(
          ConfigManager.messages.PLAYER_LOAD.replace("{player}", gsPlayer.getName()));

      HomesManager.loadPlayersHomes(gsPlayer);
    } else {
      createNewPlayer(player);
    }
  }
示例#2
0
  private static void createNewPlayer(final ProxiedPlayer player) {
    String ip = player.getAddress().getAddress().toString();
    final GSPlayer gsPlayer =
        new GSPlayer(
            player.getName(), (FeatureDetector.canUseUUID()) ? player.getUUID() : null, true);

    DatabaseManager.players.insertPlayer(gsPlayer, ip.substring(1, ip.length()));

    if (ConfigManager.main.NewPlayerBroadcast) {
      String welcomeMsg = null;
      sendBroadcast(
          welcomeMsg =
              ConfigManager.messages.NEW_PLAYER_BROADCAST.replace("{player}", player.getName()));
      // Firing custom event
      ProxyServer.getInstance()
          .getPluginManager()
          .callEvent(new NewPlayerJoinEvent(player.getName(), welcomeMsg));
    }

    onlinePlayers.put(player.getName(), gsPlayer);
    LoggingManager.log(ConfigManager.messages.PLAYER_LOAD.replace("{player}", gsPlayer.getName()));

    if (ConfigManager.spawn.SpawnNewPlayerAtNewspawn && SpawnManager.NewPlayerSpawn != null) {
      SpawnManager.newPlayers.add(player);

      ProxyServer.getInstance()
          .getScheduler()
          .schedule(
              geSuit.instance,
              new Runnable() {

                @Override
                public void run() {
                  SpawnManager.sendPlayerToNewPlayerSpawn(gsPlayer);
                  SpawnManager.newPlayers.remove(player);
                }
              },
              300,
              TimeUnit.MILLISECONDS);
    }
  }