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


Java Validate.validState方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.Validate.validState方法的典型用法代码示例。如果您正苦于以下问题:Java Validate.validState方法的具体用法?Java Validate.validState怎么用?Java Validate.validState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.Validate的用法示例。


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

示例1: applyServerIconToResponse

import org.apache.commons.lang3.Validate; //导入方法依赖的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

示例2: processLoginStart

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void processLoginStart(C00PacketLoginStart packetIn)
{
    Validate.validState(this.currentLoginState == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]);
    this.loginGameProfile = packetIn.getProfile();

    if (this.server.isServerInOnlineMode() && !this.networkManager.isLocalChannel())
    {
        this.currentLoginState = NetHandlerLoginServer.LoginState.KEY;
        this.networkManager.sendPacket(new S01PacketEncryptionRequest(this.serverId, this.server.getKeyPair().getPublic(), this.verifyToken));
    }
    else
    {
        this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:16,代码来源:NetHandlerLoginServer.java

示例3: addFaviconToStatusResponse

import org.apache.commons.lang3.Validate; //导入方法依赖的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

示例4: processLoginStart

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void processLoginStart(CPacketLoginStart packetIn)
{
    Validate.validState(this.currentLoginState == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]);
    this.loginGameProfile = packetIn.getProfile();

    if (this.server.isServerInOnlineMode() && !this.networkManager.isLocalChannel())
    {
        this.currentLoginState = NetHandlerLoginServer.LoginState.KEY;
        this.networkManager.sendPacket(new SPacketEncryptionRequest("", this.server.getKeyPair().getPublic(), this.verifyToken));
    }
    else
    {
        this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:NetHandlerLoginServer.java

示例5: loadServerIcon

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
private void loadServerIcon()
{
    boolean flag = this.iconFile != null && this.iconFile.isFile();

    if (flag)
    {
        BufferedImage bufferedimage;

        try
        {
            bufferedimage = ImageIO.read(this.iconFile);
            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]);
        }
        catch (Throwable throwable)
        {
            LOGGER.error("Invalid icon for world {}", new Object[] {this.worldSummary.getFileName(), throwable});
            this.iconFile = null;
            return;
        }

        if (this.icon == null)
        {
            this.icon = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight());
            this.client.getTextureManager().loadTexture(this.iconLocation, this.icon);
        }

        bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.icon.getTextureData(), 0, bufferedimage.getWidth());
        this.icon.updateDynamicTexture();
    }
    else if (!flag)
    {
        this.client.getTextureManager().deleteTexture(this.iconLocation);
        this.icon = null;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:37,代码来源:GuiListWorldSelectionEntry.java

示例6: assertContextInjected

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * 检查ApplicationContext不为空.
 */
private static void assertContextInjected() {
	Validate.validState(applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.");
}
 
开发者ID:funtl,项目名称:framework,代码行数:7,代码来源:SpringContextHolder.java

示例7: prepareServerIcon

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
private void prepareServerIcon()
{
    if (this.field_148301_e.getBase64EncodedIconData() == null)
    {
        this.mc.getTextureManager().deleteTexture(this.field_148306_i);
        this.field_148305_h = null;
    }
    else
    {
        ByteBuf bytebuf = Unpooled.copiedBuffer((CharSequence)this.field_148301_e.getBase64EncodedIconData(), Charsets.UTF_8);
        ByteBuf bytebuf1 = Base64.decode(bytebuf);
        BufferedImage bufferedimage;
        label101:
        {
            try
            {
                bufferedimage = TextureUtil.readBufferedImage(new ByteBufInputStream(bytebuf1));
                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]);
                break label101;
            }
            catch (Throwable throwable)
            {
                logger.error("Invalid icon for server " + this.field_148301_e.serverName + " (" + this.field_148301_e.serverIP + ")", throwable);
                this.field_148301_e.setBase64EncodedIconData((String)null);
            }
            finally
            {
                bytebuf.release();
                bytebuf1.release();
            }

            return;
        }

        if (this.field_148305_h == null)
        {
            this.field_148305_h = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight());
            this.mc.getTextureManager().loadTexture(this.field_148306_i, this.field_148305_h);
        }

        bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.field_148305_h.getTextureData(), 0, bufferedimage.getWidth());
        this.field_148305_h.updateDynamicTexture();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:46,代码来源:ServerListEntryNormal.java

示例8: processEncryptionResponse

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void processEncryptionResponse(C01PacketEncryptionResponse packetIn)
{
    Validate.validState(this.currentLoginState == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]);
    PrivateKey privatekey = this.server.getKeyPair().getPrivate();

    if (!Arrays.equals(this.verifyToken, packetIn.getVerifyToken(privatekey)))
    {
        throw new IllegalStateException("Invalid nonce!");
    }
    else
    {
        this.secretKey = packetIn.getSecretKey(privatekey);
        this.currentLoginState = NetHandlerLoginServer.LoginState.AUTHENTICATING;
        this.networkManager.enableEncryption(this.secretKey);
        (new Thread("User Authenticator #" + AUTHENTICATOR_THREAD_ID.incrementAndGet())
        {
            public void run()
            {
                GameProfile gameprofile = NetHandlerLoginServer.this.loginGameProfile;

                try
                {
                    String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.this.serverId, NetHandlerLoginServer.this.server.getKeyPair().getPublic(), NetHandlerLoginServer.this.secretKey))).toString(16);
                    NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);

                    if (NetHandlerLoginServer.this.loginGameProfile != null)
                    {
                        NetHandlerLoginServer.logger.info("UUID of player " + NetHandlerLoginServer.this.loginGameProfile.getName() + " is " + NetHandlerLoginServer.this.loginGameProfile.getId());
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.logger.warn("Failed to verify username but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Failed to verify username!");
                        NetHandlerLoginServer.logger.error("Username \'" + NetHandlerLoginServer.this.loginGameProfile.getName() + "\' tried to join with an invalid session");
                    }
                }
                catch (AuthenticationUnavailableException var3)
                {
                    if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.logger.warn("Authentication servers are down but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Authentication servers are down. Please try again later, sorry!");
                        NetHandlerLoginServer.logger.error("Couldn\'t verify username because servers are unavailable");
                    }
                }
            }
        }).start();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:61,代码来源:NetHandlerLoginServer.java

示例9: processEncryptionResponse

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void processEncryptionResponse(CPacketEncryptionResponse packetIn)
{
    Validate.validState(this.currentLoginState == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]);
    PrivateKey privatekey = this.server.getKeyPair().getPrivate();

    if (!Arrays.equals(this.verifyToken, packetIn.getVerifyToken(privatekey)))
    {
        throw new IllegalStateException("Invalid nonce!");
    }
    else
    {
        this.secretKey = packetIn.getSecretKey(privatekey);
        this.currentLoginState = NetHandlerLoginServer.LoginState.AUTHENTICATING;
        this.networkManager.enableEncryption(this.secretKey);
        (new Thread("User Authenticator #" + AUTHENTICATOR_THREAD_ID.incrementAndGet())
        {
            public void run()
            {
                GameProfile gameprofile = NetHandlerLoginServer.this.loginGameProfile;

                try
                {
                    String s = (new BigInteger(CryptManager.getServerIdHash("", NetHandlerLoginServer.this.server.getKeyPair().getPublic(), NetHandlerLoginServer.this.secretKey))).toString(16);
                    NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.func_191235_a());

                    if (NetHandlerLoginServer.this.loginGameProfile != null)
                    {
                        NetHandlerLoginServer.LOGGER.info("UUID of player {} is {}", new Object[] {NetHandlerLoginServer.this.loginGameProfile.getName(), NetHandlerLoginServer.this.loginGameProfile.getId()});
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.LOGGER.warn("Failed to verify username but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Failed to verify username!");
                        NetHandlerLoginServer.LOGGER.error("Username \'{}\' tried to join with an invalid session", new Object[] {gameprofile.getName()});
                    }
                }
                catch (AuthenticationUnavailableException var3)
                {
                    if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.LOGGER.warn("Authentication servers are down but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Authentication servers are down. Please try again later, sorry!");
                        NetHandlerLoginServer.LOGGER.error("Couldn\'t verify username because servers are unavailable");
                    }
                }
            }
            @Nullable
            private InetAddress func_191235_a()
            {
                SocketAddress socketaddress = NetHandlerLoginServer.this.networkManager.getRemoteAddress();
                return NetHandlerLoginServer.this.server.func_190518_ac() && socketaddress instanceof InetSocketAddress ? ((InetSocketAddress)socketaddress).getAddress() : null;
            }
        }).start();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:67,代码来源:NetHandlerLoginServer.java

示例10: processEncryptionResponse

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void processEncryptionResponse(CPacketEncryptionResponse packetIn)
{
    Validate.validState(this.currentLoginState == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]);
    PrivateKey privatekey = this.server.getKeyPair().getPrivate();

    if (!Arrays.equals(this.verifyToken, packetIn.getVerifyToken(privatekey)))
    {
        throw new IllegalStateException("Invalid nonce!");
    }
    else
    {
        this.secretKey = packetIn.getSecretKey(privatekey);
        this.currentLoginState = NetHandlerLoginServer.LoginState.AUTHENTICATING;
        this.networkManager.enableEncryption(this.secretKey);
        (new Thread("User Authenticator #" + AUTHENTICATOR_THREAD_ID.incrementAndGet())
        {
            public void run()
            {
                GameProfile gameprofile = NetHandlerLoginServer.this.loginGameProfile;

                try
                {
                    String s = (new BigInteger(CryptManager.getServerIdHash("", NetHandlerLoginServer.this.server.getKeyPair().getPublic(), NetHandlerLoginServer.this.secretKey))).toString(16);
                    NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);

                    if (NetHandlerLoginServer.this.loginGameProfile != null)
                    {
                        NetHandlerLoginServer.LOGGER.info("UUID of player {} is {}", new Object[] {NetHandlerLoginServer.this.loginGameProfile.getName(), NetHandlerLoginServer.this.loginGameProfile.getId()});
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.LOGGER.warn("Failed to verify username but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Failed to verify username!");
                        NetHandlerLoginServer.LOGGER.error("Username \'{}\' tried to join with an invalid session", new Object[] {gameprofile.getName()});
                    }
                }
                catch (AuthenticationUnavailableException var3)
                {
                    if (NetHandlerLoginServer.this.server.isSinglePlayer())
                    {
                        NetHandlerLoginServer.LOGGER.warn("Authentication servers are down but will let them in anyway!");
                        NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(gameprofile);
                        NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
                    }
                    else
                    {
                        NetHandlerLoginServer.this.closeConnection("Authentication servers are down. Please try again later, sorry!");
                        NetHandlerLoginServer.LOGGER.error("Couldn\'t verify username because servers are unavailable");
                    }
                }
            }
        }).start();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:61,代码来源:NetHandlerLoginServer.java

示例11: assertContextInjected

import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
 * 检查ApplicationContext不为空.
 */
private static void assertContextInjected() {
    Validate.validState(applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.");
}
 
开发者ID:liuxx001,项目名称:bird-java,代码行数:7,代码来源:SpringContextHolder.java


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