当前位置: 首页>>代码示例>>Java>>正文


Java ServerStatusResponse类代码示例

本文整理汇总了Java中net.minecraft.network.ServerStatusResponse的典型用法代码示例。如果您正苦于以下问题:Java ServerStatusResponse类的具体用法?Java ServerStatusResponse怎么用?Java ServerStatusResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerStatusResponse类属于net.minecraft.network包,在下文中一共展示了ServerStatusResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: func_147138_a

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
private void func_147138_a(ServerStatusResponse p_147138_1_)
{
    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);
            p_147138_1_.func_151320_a("data:image/png;base64," + var5.toString(Charsets.UTF_8));
        }
        catch (Exception var6)
        {
            logger.error("Couldn\'t load server icon", var6);
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:24,代码来源:MinecraftServer.java

示例2: addFaviconToStatusResponse

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
private void addFaviconToStatusResponse(ServerStatusResponse response)
{
    File file1 = this.getFile("server-icon.png");

    if (file1.isFile())
    {
        ByteBuf bytebuf = Unpooled.buffer();

        try
        {
            BufferedImage bufferedimage = ImageIO.read(file1);
            Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
            Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
            ImageIO.write(bufferedimage, "PNG", (OutputStream)(new ByteBufOutputStream(bytebuf)));
            ByteBuf bytebuf1 = Base64.encode(bytebuf);
            response.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
        }
        catch (Exception exception)
        {
            logger.error((String)"Couldn\'t load server icon", (Throwable)exception);
        }
        finally
        {
            bytebuf.release();
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:28,代码来源:MinecraftServer.java

示例3: applyServerIconToResponse

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
public void applyServerIconToResponse(ServerStatusResponse response)
{
    File file1 = this.getFile("server-icon.png");

    if (!file1.exists())
    {
        file1 = this.getActiveAnvilConverter().getFile(this.getFolderName(), "icon.png");
    }

    if (file1.isFile())
    {
        ByteBuf bytebuf = Unpooled.buffer();

        try
        {
            BufferedImage bufferedimage = ImageIO.read(file1);
            Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
            Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
            ImageIO.write(bufferedimage, "PNG", (OutputStream)(new ByteBufOutputStream(bytebuf)));
            ByteBuf bytebuf1 = Base64.encode(bytebuf);
            response.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
        }
        catch (Exception exception)
        {
            LOG.error((String)"Couldn\'t load server icon", (Throwable)exception);
        }
        finally
        {
            bytebuf.release();
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:33,代码来源:MinecraftServer.java

示例4: captureAdditionalData

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
public void captureAdditionalData(ServerStatusResponse serverstatusresponse, JsonObject jsonobject)
{
    if (jsonobject.has("modinfo"))
    {
        JsonObject fmlData = jsonobject.get("modinfo").getAsJsonObject();
        extraServerListData.put(serverstatusresponse, fmlData);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:FMLClientHandler.java

示例5: getProtocolVersion

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Override
public OptionalInt getProtocolVersion(StatusResponse response) {
    if (response instanceof ServerStatusResponse) {
        return OptionalInt.of(((ServerStatusResponse) response).getProtocolVersionInfo().getProtocol());
    } else {
        return OptionalInt.empty();
    }
}
 
开发者ID:Minecrell,项目名称:statusprotocol,代码行数:9,代码来源:StatusProtocolImpl_1_8_9.java

示例6: setVersion

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Override
public boolean setVersion(ClientPingServerEvent.Response response, String name, int protocol) {
    if (response instanceof ServerStatusResponse) {
        ((ServerStatusResponse) response).setProtocolVersionInfo(new ServerStatusResponse.MinecraftProtocolVersionIdentifier(name, protocol));
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Minecrell,项目名称:statusprotocol,代码行数:10,代码来源:StatusProtocolImpl_1_8_9.java

示例7: getProtocolVersion

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Override
public OptionalInt getProtocolVersion(StatusResponse response) {
    if (response instanceof ServerStatusResponse) {
        return OptionalInt.of(((ServerStatusResponse) response).getVersion().getProtocol());
    } else {
        return OptionalInt.empty();
    }
}
 
开发者ID:Minecrell,项目名称:statusprotocol,代码行数:9,代码来源:StatusProtocolImpl_1_9.java

示例8: setVersion

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Override
public boolean setVersion(ClientPingServerEvent.Response response, String name, int protocol) {
    if (response instanceof ServerStatusResponse) {
        ((ServerStatusResponse) response).setVersion(new ServerStatusResponse.Version(name, protocol));
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Minecrell,项目名称:statusprotocol,代码行数:10,代码来源:StatusProtocolImpl_1_9.java

示例9: onDeserialize

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Inject(method = "deserialize", at = @At("RETURN"))
private void onDeserialize(JsonElement element, Type type, JsonDeserializationContext ctx, CallbackInfoReturnable<ServerStatusResponse> cir) {
    JsonObject json = element.getAsJsonObject();
    ServerStatusResponse response = cir.getReturnValue();

    ServerType serverType = null;
    ServerCompatibility serverCompat = null;

    if (json.has("spongeInfo")) {
        JsonObject spongeInfo = json.getAsJsonObject("spongeInfo");
        serverType = spongeInfo.has("serverType") ? ServerType.valueOf(spongeInfo.get("serverType").getAsString().toUpperCase()) : null;
        // Mainly means the server compatibility against the vanilla client
        serverCompat = spongeInfo.has("serverCompat") ? ServerCompatibility.valueOf(
                spongeInfo.get("serverCompat").getAsString().toUpperCase()) : null;
    }

    // System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(json.getAsJsonObject("modinfo")));

    if (serverType == null || serverCompat == null) {
        JsonObject modInfo = json.has("modinfo") ? json.getAsJsonObject("modinfo") : null;
        if (modInfo != null && modInfo.has("modList")) {
            List<String> mods = StreamSupport.stream(modInfo.getAsJsonArray("modList").spliterator(), false)
                    .map(e -> e.getAsJsonObject().get("modid").getAsString())
                    .collect(Collectors.toList());
            if (serverType == null) {
                if (mods.contains("sponge")) {
                    serverType = ServerType.SPONGE_FORGE;
                } else {
                    serverType = ServerType.FORGE;
                }
            }
        } else {
            if (serverCompat == null) {
                serverCompat = ServerCompatibility.UNKNOWN;
            }
        }
    }
    ((IMixinServerStatusResponse) response).setSpongeInfo(new SpongeStatusInfo(
            serverType == null ? ServerType.VANILLA : serverType, serverCompat == null ? ServerCompatibility.UNKNOWN : serverCompat));
}
 
开发者ID:Cybermaxke,项目名称:LiteSpongeClient,代码行数:41,代码来源:MixinServerStatusResponseSerializer.java

示例10: processServerQuery

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
@Overwrite
public void processServerQuery(C00PacketServerQuery packetIn) {
    ServerListPingHook hook =
            (ServerListPingHook) new ServerListPingHook((InetSocketAddress) networkManager.getRemoteAddress(),
                    ((IMixinNetworkManager) networkManager).getProtocolVersion(),
                    ((IMixinNetworkManager) networkManager).getHostnamePinged(),
                    ((IMixinNetworkManager) networkManager).getPortPinged(),
                    new NeptuneChatComponent(server.getServerStatusResponse().getServerDescription()),
                    server.getServerStatusResponse().getPlayerCountData().getOnlinePlayerCount(),
                    server.getServerStatusResponse().getPlayerCountData().getMaxPlayers(),
                    server.getServerStatusResponse().getFavicon(),
                    Arrays.asList(server.getServerStatusResponse().getPlayerCountData().getPlayers())).call();
    if (hook.isCanceled()) {
        networkManager.closeChannel(null);
        return;
    }

    ServerStatusResponse response = new ServerStatusResponse();
    response.setProtocolVersionInfo(server.getServerStatusResponse().getProtocolVersionInfo());
    ServerStatusResponse.PlayerCountData playerCountData = new ServerStatusResponse.PlayerCountData(hook
            .getMaxPlayers(), hook.getCurrentPlayers());
    playerCountData.setPlayers(hook.getProfiles().toArray(new GameProfile[hook.getProfiles().size()]));
    response.setPlayerCountData(playerCountData);
    response.setServerDescription(((NeptuneChatComponent) hook.getMotd()).getHandle());
    response.setFavicon(hook.getFavicon());

    networkManager.sendPacket(new S00PacketServerInfo(response));
}
 
开发者ID:NeptunePowered,项目名称:NeptuneCommon,代码行数:29,代码来源:MixinNetHandlerStatusServer.java

示例11: processServerQuery

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
/**
 * @author jamierocks - 5th May 2015
 * @reason Handle the ServerListPingHook
 */
@Overwrite
public void processServerQuery(C00PacketServerQuery packetIn) {
    if (handled) {
        this.networkManager.closeChannel(EXIT_MESSAGE);
    } else {
        this.handled = true;

        ServerListPingHook hook =
                (ServerListPingHook) new ServerListPingHook((InetSocketAddress) this.networkManager.getRemoteAddress(),
                        ((IMixinNetworkManager) this.networkManager).getProtocolVersion(),
                        ((IMixinNetworkManager) this.networkManager).getHostnamePinged(),
                        ((IMixinNetworkManager) this.networkManager).getPortPinged(),
                        (ChatComponent) this.server.getServerStatusResponse().getServerDescription(),
                        this.server.getServerStatusResponse().getPlayerCountData().getOnlinePlayerCount(),
                        this.server.getServerStatusResponse().getPlayerCountData().getMaxPlayers(),
                        this.server.getServerStatusResponse().getFavicon(),
                        Arrays.asList(this.server.getServerStatusResponse().getPlayerCountData().getPlayers())).call();
        if (hook.isCanceled()) {
            this.networkManager.closeChannel(null);
            return;
        }

        ServerStatusResponse response = new ServerStatusResponse();
        response.setProtocolVersionInfo(this.server.getServerStatusResponse().getProtocolVersionInfo());
        ServerStatusResponse.PlayerCountData playerCountData = new ServerStatusResponse.PlayerCountData(hook
                .getMaxPlayers(), hook.getCurrentPlayers());
        playerCountData.setPlayers(hook.getProfiles().toArray(new GameProfile[hook.getProfiles().size()]));
        response.setPlayerCountData(playerCountData);
        response.setServerDescription((IChatComponent) hook.getMotd());
        response.setFavicon(hook.getFavicon());

        this.networkManager.sendPacket(new S00PacketServerInfo(response));
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:39,代码来源:MixinNetHandlerStatusServer.java

示例12: func_147138_a

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
private void func_147138_a(ServerStatusResponse p_147138_1_)
{
    File file1 = this.getFile("server-icon.png");

    if (file1.isFile())
    {
        ByteBuf bytebuf = Unpooled.buffer();

        try
        {
            BufferedImage bufferedimage = ImageIO.read(file1);
            Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
            Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
            ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf));
            ByteBuf bytebuf1 = Base64.encode(bytebuf);
            p_147138_1_.func_151320_a("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
        }
        catch (Exception exception)
        {
            logger.error("Couldn\'t load server icon", exception);
        }
        finally
        {
            bytebuf.release();
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:28,代码来源:MinecraftServer.java

示例13: S00PacketServerInfo

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
public S00PacketServerInfo(ServerStatusResponse responseIn)
{
    this.response = responseIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:S00PacketServerInfo.java

示例14: readPacketData

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.response = (ServerStatusResponse)GSON.fromJson(buf.readStringFromBuffer(32767), ServerStatusResponse.class);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:S00PacketServerInfo.java

示例15: tick

import net.minecraft.network.ServerStatusResponse; //导入依赖的package包/类
/**
 * Main function called by run() every loop.
 */
protected void tick()
{
    long i = System.nanoTime();
    ++this.tickCounter;

    if (this.startProfiling)
    {
        this.startProfiling = false;
        this.theProfiler.profilingEnabled = true;
        this.theProfiler.clearProfiling();
    }

    this.theProfiler.startSection("root");
    this.updateTimeLightAndEntities();

    if (i - this.nanoTimeSinceStatusRefresh >= 5000000000L)
    {
        this.nanoTimeSinceStatusRefresh = i;
        this.statusResponse.setPlayerCountData(new ServerStatusResponse.PlayerCountData(this.getMaxPlayers(), this.getCurrentPlayerCount()));
        GameProfile[] agameprofile = new GameProfile[Math.min(this.getCurrentPlayerCount(), 12)];
        int j = MathHelper.getRandomIntegerInRange(this.random, 0, this.getCurrentPlayerCount() - agameprofile.length);

        for (int k = 0; k < agameprofile.length; ++k)
        {
            agameprofile[k] = ((EntityPlayerMP)this.serverConfigManager.func_181057_v().get(j + k)).getGameProfile();
        }

        Collections.shuffle(Arrays.asList(agameprofile));
        this.statusResponse.getPlayerCountData().setPlayers(agameprofile);
    }

    if (this.tickCounter % 900 == 0)
    {
        this.theProfiler.startSection("save");
        this.serverConfigManager.saveAllPlayerData();
        this.saveAllWorlds(true);
        this.theProfiler.endSection();
    }

    this.theProfiler.startSection("tallying");
    this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
    this.theProfiler.endSection();
    this.theProfiler.startSection("snooper");

    if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100)
    {
        this.usageSnooper.startSnooper();
    }

    if (this.tickCounter % 6000 == 0)
    {
        this.usageSnooper.addMemoryStatsToSnooper();
    }

    this.theProfiler.endSection();
    this.theProfiler.endSection();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:61,代码来源:MinecraftServer.java


注:本文中的net.minecraft.network.ServerStatusResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。