Example #1
0
  public static void sendPlayerToHome(GSPlayer player, String home) {
    Home h = getHome(player, home);
    if (h == null) {
      PlayerManager.sendMessageToTarget(
          player, ConfigManager.messages.HOME_DOES_NOT_EXIST.replace("{home}", home));
      return;
    }

    TeleportToLocation.execute(player, h.loc);

    PlayerManager.sendMessageToTarget(
        player, ConfigManager.messages.SENT_HOME.replace("{home}", home));
  }
Example #2
0
  public static void sendPlayerToOtherHome(GSPlayer sender, String playername, String home) {
    GSPlayer player = DatabaseManager.players.loadPlayer(playername);

    if (player == null) {
      PlayerManager.sendMessageToTarget(sender, ConfigManager.messages.PLAYER_DOES_NOT_EXIST);
      return;
    }

    loadPlayersHomes(player);
    Home h = getHome(player, home);
    if (h == null) {
      PlayerManager.sendMessageToTarget(
          sender, ConfigManager.messages.HOME_DOES_NOT_EXIST.replace("{home}", home));
      return;
    }

    TeleportToLocation.execute(sender, h.loc);

    PlayerManager.sendMessageToTarget(
        sender, ConfigManager.messages.SENT_HOME.replace("{home}", home));
  }
  @EventHandler
  public void receivePluginMessage(PluginMessageEvent event) throws IOException, SQLException {
    if (event.isCancelled()) {
      return;
    }
    if (!(event.getSender() instanceof Server)) return;
    if (!event.getTag().equalsIgnoreCase("geSuitTeleport")) {
      return;
    }

    // Message debugging (can be toggled live)
    if (geSuit.instance.isDebugEnabled()) {
      Utilities.dumpPacket(event.getTag(), "RECV", event.getData(), true);
    }

    DataInputStream in = new DataInputStream(new ByteArrayInputStream(event.getData()));
    String task = in.readUTF();

    if (task.equals("TpAccept")) {
      TeleportManager.acceptTeleportRequest(PlayerManager.getPlayer(in.readUTF(), true));
      return;
    }

    if (task.equals("TeleportToLocation")) {
      GSPlayer player = PlayerManager.getPlayer(in.readUTF(), true);
      String server = in.readUTF();
      TeleportToLocation.execute(
          player,
          new Location(
              (!server.equals("")) ? server : ((Server) event.getSender()).getInfo().getName(),
              in.readUTF(),
              in.readDouble(),
              in.readDouble(),
              in.readDouble()));
      return;
    }

    if (task.equals("PlayersTeleportBackLocation")) {
      GSPlayer player = PlayerManager.getPlayer(in.readUTF());
      if (player != null) {
        TeleportManager.setPlayersTeleportBackLocation(
            player,
            new Location(
                ((Server) event.getSender()).getInfo(),
                in.readUTF(),
                in.readDouble(),
                in.readDouble(),
                in.readDouble(),
                in.readFloat(),
                in.readFloat()));
      }
      return;
    }

    if (task.equals("PlayersDeathBackLocation")) {
      TeleportManager.setPlayersDeathBackLocation(
          PlayerManager.getPlayer(in.readUTF(), true),
          new Location(
              ((Server) event.getSender()).getInfo(),
              in.readUTF(),
              in.readDouble(),
              in.readDouble(),
              in.readDouble(),
              in.readFloat(),
              in.readFloat()));
      return;
    }

    if (task.equals("TeleportToPlayer")) {
      TeleportManager.teleportPlayerToPlayer(
          in.readUTF(), in.readUTF(), in.readUTF(), in.readBoolean(), in.readBoolean());
      return;
    }

    if (task.equals("TpaHereRequest")) {
      TeleportManager.requestPlayerTeleportToYou(in.readUTF(), in.readUTF());
      return;
    }

    if (task.equals("TpaRequest")) {
      TeleportManager.requestToTeleportToPlayer(in.readUTF(), in.readUTF());
      return;
    }

    if (task.equals("TpDeny")) {
      TeleportManager.denyTeleportRequest(PlayerManager.getPlayer(in.readUTF(), true));
      return;
    }

    if (task.equals("TpAll")) {
      TeleportManager.tpAll(in.readUTF(), in.readUTF());
      return;
    }

    if (task.equals("SendPlayerBack")) {
      TeleportManager.sendPlayerToLastBack(
          PlayerManager.getPlayer(in.readUTF(), true), in.readBoolean(), in.readBoolean());
      return;
    }

    if (task.equals("ToggleTeleports")) {
      TeleportManager.togglePlayersTeleports(PlayerManager.getPlayer(in.readUTF(), true));
      return;
    }

    if (task.equals("SendVersion")) {
      LoggingManager.log(in.readUTF());
    }
  }