Java 类net.minecraft.util.org.apache.commons.lang3.Validate 实例源码
项目:CraftBukkit
文件:MinecraftServer.java
private void a(ServerPing serverping) {
File file1 = this.d("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);
serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
} catch (Exception exception) {
i.error("Couldn\'t load server icon", exception);
} finally {
bytebuf.release();
}
}
}
项目:Tweakkit-Server
文件:MinecraftServer.java
private void a(ServerPing serverping) {
File file1 = this.d("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);
serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
} catch (Exception exception) {
i.error("Couldn\'t load server icon", exception);
} finally {
bytebuf.release();
}
}
}
项目:CraftBukkit
文件:LoginListener.java
public void a(PacketLoginInStart packetlogininstart) {
Validate.validState(this.g == EnumProtocolState.HELLO, "Unexpected hello packet", new Object[0]);
this.i = packetlogininstart.c();
if (this.server.getOnlineMode() && !this.networkManager.c()) {
this.g = EnumProtocolState.KEY;
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.K().getPublic(), this.e), new GenericFutureListener[0]);
} else {
this.g = EnumProtocolState.READY_TO_ACCEPT;
}
}
项目:CraftBukkit
文件:LoginListener.java
public void a(PacketLoginInEncryptionBegin packetlogininencryptionbegin) {
Validate.validState(this.g == EnumProtocolState.KEY, "Unexpected key packet", new Object[0]);
PrivateKey privatekey = this.server.K().getPrivate();
if (!Arrays.equals(this.e, packetlogininencryptionbegin.b(privatekey))) {
throw new IllegalStateException("Invalid nonce!");
} else {
this.loginKey = packetlogininencryptionbegin.a(privatekey);
this.g = EnumProtocolState.AUTHENTICATING;
this.networkManager.a(this.loginKey);
(new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start();
}
}
项目:Tweakkit-Server
文件:LoginListener.java
public void a(PacketLoginInStart packetlogininstart) {
Validate.validState(this.g == EnumProtocolState.HELLO, "Unexpected hello packet", new Object[0]);
this.i = packetlogininstart.c();
if (this.server.getOnlineMode() && !this.networkManager.c()) {
this.g = EnumProtocolState.KEY;
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.K().getPublic(), this.e), new GenericFutureListener[0]);
} else {
(new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start(); // Spigot
}
}
项目:Tweakkit-Server
文件:LoginListener.java
public void a(PacketLoginInEncryptionBegin packetlogininencryptionbegin) {
Validate.validState(this.g == EnumProtocolState.KEY, "Unexpected key packet", new Object[0]);
PrivateKey privatekey = this.server.K().getPrivate();
if (!Arrays.equals(this.e, packetlogininencryptionbegin.b(privatekey))) {
throw new IllegalStateException("Invalid nonce!");
} else {
this.loginKey = packetlogininencryptionbegin.a(privatekey);
this.g = EnumProtocolState.AUTHENTICATING;
this.networkManager.a(this.loginKey);
(new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start();
}
}
项目:CraftBukkit
文件:LoginListener.java
public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) {
Validate.validState(this.g == EnumProtocolState.e || this.g == EnumProtocolState.HELLO, "Unexpected change in protocol", new Object[0]);
Validate.validState(enumprotocol1 == EnumProtocol.PLAY || enumprotocol1 == EnumProtocol.LOGIN, "Unexpected protocol " + enumprotocol1, new Object[0]);
}
项目:CraftBukkit
文件:NetworkManager.java
public void a(PacketListener packetlistener) {
Validate.notNull(packetlistener, "packetListener", new Object[0]);
i.debug("Set listener of {} to {}", new Object[] { this, packetlistener});
this.o = packetlistener;
}
项目:Tweakkit-Server
文件:LoginListener.java
public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) {
Validate.validState(this.g == EnumProtocolState.e || this.g == EnumProtocolState.HELLO, "Unexpected change in protocol", new Object[0]);
Validate.validState(enumprotocol1 == EnumProtocol.PLAY || enumprotocol1 == EnumProtocol.LOGIN, "Unexpected protocol " + enumprotocol1, new Object[0]);
}
项目:Tweakkit-Server
文件:NetworkManager.java
public void a(PacketListener packetlistener) {
Validate.notNull(packetlistener, "packetListener", new Object[0]);
i.debug("Set listener of {} to {}", new Object[] { this, packetlistener});
this.o = packetlistener;
}