コード例 #1
0
 /**
  * Sends a login response.
  *
  * @param protocolVersion The protocol version.
  * @param name The server name.
  * @param message The server message of the day.
  * @param op Operator flag.
  */
 public void sendLoginResponse(int protocolVersion, String name, String message, boolean op) {
   PacketBuilder bldr =
       new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(0));
   bldr.putByte("protocol_version", protocolVersion);
   bldr.putString("server_name", name);
   bldr.putString("server_message", message);
   bldr.putByte("user_type", op ? 100 : 0);
   session.send(bldr.toPacket());
 }
コード例 #2
0
 /**
  * Sends a login failure.
  *
  * @param message The message to send to the client.
  */
 public void sendLoginFailure(String message) {
   PacketBuilder bldr =
       new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(14));
   bldr.putString("reason", message);
   session.send(bldr.toPacket());
   session.close();
 }
コード例 #3
0
 public void sendSpawn(byte id, String name, int x, int y, int z, byte rotation, byte look) {
   PacketBuilder bldr =
       new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(7));
   bldr.putByte("id", id);
   bldr.putString("name", name);
   bldr.putShort("x", x);
   bldr.putShort("y", y);
   bldr.putShort("z", z);
   bldr.putByte("rotation", rotation);
   bldr.putByte("look", look);
   session.send(bldr.toPacket());
 }
コード例 #4
0
 /**
  * Sends the add entity packet.
  *
  * @param entity The entity being added.
  */
 public void sendAddEntity(Entity entity) {
   PacketBuilder bldr =
       new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(7));
   bldr.putByte("id", entity.getId());
   bldr.putString("name", entity.getColoredName());
   bldr.putShort("x", entity.getPosition().getX());
   bldr.putShort("y", entity.getPosition().getY());
   bldr.putShort("z", entity.getPosition().getZ());
   bldr.putByte("rotation", entity.getRotation().getRotation());
   bldr.putByte("look", entity.getRotation().getLook());
   session.send(bldr.toPacket());
 }
コード例 #5
0
 /**
  * Sends a chat message.
  *
  * @param id The source player id.
  * @param message The message.
  */
 public void sendChatMessage(int id, String message) {
   PacketBuilder bldr =
       new PacketBuilder(PersistingPacketManager.getPacketManager().getOutgoingPacket(13));
   String message2 = "";
   if (message.length() > 64) {
     message2 = message.substring(64);
     int idx = message.lastIndexOf("&");
     if (idx != -1) message2 = "&" + message.charAt(idx + 1) + message2;
     message = message.substring(0, 64);
   }
   bldr.putByte("id", id);
   bldr.putString("message", message);
   session.send(bldr.toPacket());
   if (!message2.equals("")) sendChatMessage(id, "> " + message2);
 }