forked from KNEMC/KLALB
优化代码,性能暴涨
This commit is contained in:
@@ -3,8 +3,11 @@ package org.kne.cloud.network.minecraft;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
@@ -37,7 +40,7 @@ public class MinecraftServerPinger implements Serializable{
|
||||
|
||||
private long latency=-1;
|
||||
private String json;
|
||||
private BufferedImage icon;
|
||||
//private BufferedImage icon;
|
||||
private int max;
|
||||
private int online;
|
||||
private String description;
|
||||
@@ -47,6 +50,8 @@ public class MinecraftServerPinger implements Serializable{
|
||||
private String klalbversion;
|
||||
private Inet6Address klalbvaddr;
|
||||
private int klalbvport;
|
||||
private String icon;
|
||||
private transient BufferedImage image;
|
||||
|
||||
public MinecraftServerPinger(MultipurposeSocketAddress target) throws UnknownHostException, IOException {
|
||||
this(target,target.connectSocket());
|
||||
@@ -146,12 +151,8 @@ public class MinecraftServerPinger implements Serializable{
|
||||
if(favicon!=null) {
|
||||
String s=favicon.getAsString();
|
||||
if(s.startsWith("data:image/png;base64,")){
|
||||
s=s.replace("\n", "");
|
||||
try {
|
||||
icon=ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(s.substring("data:image/png;base64,".length()))));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
icon=s.replace("\n", "");
|
||||
|
||||
}
|
||||
}
|
||||
/*try {
|
||||
@@ -261,7 +262,15 @@ public class MinecraftServerPinger implements Serializable{
|
||||
}
|
||||
|
||||
public BufferedImage getIcon() {
|
||||
return icon;
|
||||
if(icon==null)
|
||||
return null;
|
||||
if(image==null)
|
||||
try {
|
||||
image= ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(icon.substring("data:image/png;base64,".length()))));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
@@ -305,4 +314,6 @@ public class MinecraftServerPinger implements Serializable{
|
||||
MinecraftServerPinger sp=new MinecraftServerPinger(MinecraftServerAddress.findAddress("mc.hypixel.cn"));
|
||||
System.out.println(sp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user