Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
2
Indexable
Never
package ballistickemu.Lobby.handlers;

import ballistickemu.Lobby.LobbyServer;
import ballistickemu.Main;
import ballistickemu.Tools.StickPacketMaker;
import ballistickemu.Types.StickClient;
import ballistickemu.Types.StickRoom;
import ballistickemu.Types.StickRoomRegistry;


public class MapCycleRequestHandler
{
  public static void HandlePacket(StickClient client, String Packet)
  {
    String RoomName = Packet.substring(2, Packet.length() - 4);
    String Action = Packet.substring(Packet.length() - 3, Packet.length() - 1);
    

    StickRoom Room = Main.getLobbyServer().getRoomRegistry().GetRoomFromName(RoomName);
    if (Action.equalsIgnoreCase("mp"))
    {
      if ((Room != null) && (Room.getMapCycleList() != null))
      {
        client.write(StickPacketMaker.getMapCycleRequestResponse(Room.getMapCycleList()));
      }
    }
    else if (Action.equalsIgnoreCase("rc"))
    {
      if (Room.getCreatorName() == null) {
        client.write(StickPacketMaker.getRoomCreatorResponse("bad player"));
      } else
        client.write(StickPacketMaker.getRoomCreatorResponse(Room.getCreatorName()));
      return;
    }
    

    client.write(StickPacketMaker.getMapCycleRequestResponse("No WORKY"));
  }
}