Package net.glowstone

Examples of net.glowstone.GlowServer


    @Override
    @SuppressWarnings("unchecked")
    public void handle(GlowSession session, StatusRequestMessage message) {
        // create and call the event
        GlowServer server = session.getServer();
        int online = server.getOnlinePlayers().size();
        InetAddress address = session.getAddress().getAddress();

        StatusEvent event = new StatusEvent(address, server.getMotd(), online, server.getMaxPlayers());
        event.icon = server.getServerIcon();
        EventFactory.callEvent(event);

        // build the json
        JSONObject json = new JSONObject();
View Full Code Here


        writeString(out, String.valueOf(challengeToken));
        ctx.write(new DatagramPacket(out, packet.sender()));
    }

    private void handleBasicStats(ChannelHandlerContext ctx, DatagramPacket packet, int sessionId) {
        GlowServer server = queryServer.getServer();

        ByteBuf buf = ctx.alloc().buffer();
        buf.writeByte(ACTION_STATS);
        buf.writeInt(sessionId);
        writeString(buf, server.getMotd());
        writeString(buf, "SMP");
        writeString(buf, server.getWorlds().get(0).getName());
        writeString(buf, String.valueOf(server.getOnlinePlayers().size()));
        writeString(buf, String.valueOf(server.getMaxPlayers()));
        buf.order(ByteOrder.LITTLE_ENDIAN).writeShort(server.getPort());
        writeString(buf, getIpString());
        ctx.write(new DatagramPacket(buf, packet.sender()));
    }
View Full Code Here

        writeString(buf, getIpString());
        ctx.write(new DatagramPacket(buf, packet.sender()));
    }

    private void handleFullStats(ChannelHandlerContext ctx, DatagramPacket packet, int sessionId) {
        GlowServer server = queryServer.getServer();

        StringBuilder plugins = new StringBuilder("Glowstone ").append(server.getVersion()).append(" on Bukkit ").append(server.getBukkitVersion());
        if (showPlugins) {
            char delim = ':';
            for (Plugin plugin : server.getPluginManager().getPlugins()) {
                plugins.append(delim).append(' ').append(plugin.getDescription().getFullName());
                delim = ';';
            }
        }

        Map<String, Object> data = new LinkedHashMap<>();
        data.put("hostname", server.getMotd());
        data.put("gametype", "SMP");
        data.put("game_id", "MINECRAFT");
        data.put("version", GlowServer.GAME_VERSION);
        data.put("plugins", plugins);
        data.put("map", server.getWorlds().get(0).getName());
        data.put("numplayers", server.getOnlinePlayers().size());
        data.put("maxplayers", server.getMaxPlayers());
        data.put("hostport", server.getPort());
        data.put("hostip", getIpString());

        ByteBuf buf = ctx.alloc().buffer();
        buf.writeByte(ACTION_STATS);
        buf.writeInt(sessionId);
        // constant: splitnum\x00\x80\x00
        buf.writeBytes(new byte[]{0x73, 0x70, 0x6C, 0x69, 0x74, 0x6E, 0x75, 0x6D, 0x00, (byte) 0x80, 0x00});
        for (Entry<String, Object> e : data.entrySet()) {
            writeString(buf, e.getKey());
            writeString(buf, String.valueOf(e.getValue()));
        }
        buf.writeByte(0);
        // constant: \x01player_\x00\x00
        buf.writeBytes(new byte[]{0x01, 0x70, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x5F, 0x00, 0x00});
        for (GlowPlayer player : server.getOnlinePlayers()) {
            writeString(buf, player.getName());
        }
        buf.writeByte(0);
        ctx.write(new DatagramPacket(buf, packet.sender()));
    }
View Full Code Here

TOP

Related Classes of net.glowstone.GlowServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.