Ejemplo n.º 1
0
  public void a(C00PacketServerQuery c00packetserverquery) {
    // CanaryMod: ServerListPingHook
    ServerStatusResponse ssr = this.a.aE();
    ServerListPingHook hook =
        (ServerListPingHook)
            new ServerListPingHook(
                    (InetSocketAddress) this.b.b(),
                    c00handshake.b(),
                    c00handshake.b.split("\00")[0],
                    c00handshake.getPort(),
                    ((ChatComponentText) ssr.a()).getWrapper(),
                    ssr.b().b(),
                    ssr.b().a(),
                    ssr.d(),
                    Lists.newArrayList(ssr.b().c()))
                .call();
    if (hook.isCanceled()) {
      // Response Denied!
      return;
    }
    // Recreate the ServerStatusResponse to be sent so that the default isn't destroyed
    ssr = new ServerStatusResponse();
    ssr.a(
        new ServerStatusResponse.MinecraftProtocolVersionIdentifier(
            this.a.F(), this.a.getProtocolVersion()));
    ServerStatusResponse.PlayerCountData ssrpcd =
        new ServerStatusResponse.PlayerCountData(hook.getMaxPlayers(), hook.getCurrentPlayers());
    ssrpcd.a(hook.getProfiles().toArray(new GameProfile[hook.getProfiles().size()]));
    ssr.a(ssrpcd); // Max/Online Players & GameProfiles
    ssr.a(((CanaryChatComponent) hook.getMotd()).getNative()); // MOTD
    ssr.a(hook.getFavicon()); // Server Favicon

    this.b.a((Packet) new S00PacketServerInfo(ssr));
    //
  }
Ejemplo n.º 2
0
  private void addFaviconToStatusResponse(ServerStatusResponse response) {
    File var2 = this.getFile("server-icon.png");

    if (var2.isFile()) {
      ByteBuf var3 = Unpooled.buffer();

      try {
        BufferedImage var4 = ImageIO.read(var2);
        Validate.validState(var4.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
        Validate.validState(var4.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
        ImageIO.write(var4, "PNG", new ByteBufOutputStream(var3));
        ByteBuf var5 = Base64.encode(var3);
        response.setFavicon("data:image/png;base64," + var5.toString(Charsets.UTF_8));
      } catch (Exception var9) {
        logger.error("Couldn\'t load server icon", var9);
      } finally {
        var3.release();
      }
    }
  }