예제 #1
0
  public void sendSupportedChannels() {
    if (getHandle().field_71135_a == null) return;
    Set<String> listening = server.getMessenger().getIncomingChannels();

    if (!listening.isEmpty()) {
      net.minecraft.network.packet.Packet250CustomPayload packet =
          new net.minecraft.network.packet.Packet250CustomPayload();

      packet.field_73630_a = "REGISTER";
      ByteArrayOutputStream stream = new ByteArrayOutputStream();

      for (String channel : listening) {
        try {
          stream.write(channel.getBytes("UTF8"));
          stream.write((byte) 0);
        } catch (IOException ex) {
          Logger.getLogger(CraftPlayer.class.getName())
              .log(Level.SEVERE, "Could not send Plugin Channel REGISTER to " + getName(), ex);
        }
      }

      packet.field_73629_c = stream.toByteArray();
      packet.field_73628_b = packet.field_73629_c.length;

      getHandle().field_71135_a.func_72567_b(packet);
    }
  }
예제 #2
0
  public void sendPluginMessage(Plugin source, String channel, byte[] message) {
    StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
    if (getHandle().field_71135_a == null) return;

    if (channels.contains(channel)) {
      net.minecraft.network.packet.Packet250CustomPayload packet =
          new net.minecraft.network.packet.Packet250CustomPayload();
      packet.field_73630_a = channel;
      packet.field_73628_b = message.length;
      packet.field_73629_c = message;
      getHandle().field_71135_a.func_72567_b(packet);
    }
  }