Résolutions de tous les messages d'avertissement et d'informations d'Eclipse à propos du code
This commit is contained in:
parent
4ae06be523
commit
dd47b2b392
@ -122,7 +122,7 @@ public class GifDecoder {
|
|||||||
//
|
//
|
||||||
delay = -1;
|
delay = -1;
|
||||||
if ((n >= 0) && (n < frameCount)) {
|
if ((n >= 0) && (n < frameCount)) {
|
||||||
delay = ((GifFrame) frames.get(n)).delay;
|
delay = frames.get(n).delay;
|
||||||
}
|
}
|
||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ public class GifDecoder {
|
|||||||
int sx = i * iw; // start of line in source
|
int sx = i * iw; // start of line in source
|
||||||
while (dx < dlim) {
|
while (dx < dlim) {
|
||||||
// map color and insert in destination
|
// map color and insert in destination
|
||||||
int index = ((int) pixels[sx++]) & 0xff;
|
int index = (pixels[sx++]) & 0xff;
|
||||||
int c = act[index];
|
int c = act[index];
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
dest[dx] = c;
|
dest[dx] = c;
|
||||||
@ -253,7 +253,7 @@ public class GifDecoder {
|
|||||||
public BufferedImage getFrame(int n) {
|
public BufferedImage getFrame(int n) {
|
||||||
BufferedImage im = null;
|
BufferedImage im = null;
|
||||||
if ((n >= 0) && (n < frameCount)) {
|
if ((n >= 0) && (n < frameCount)) {
|
||||||
im = ((GifFrame) frames.get(n)).image;
|
im = frames.get(n).image;
|
||||||
}
|
}
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
@ -284,13 +284,13 @@ public class GifDecoder {
|
|||||||
status = STATUS_FORMAT_ERROR;
|
status = STATUS_FORMAT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status = STATUS_OPEN_ERROR;
|
status = STATUS_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,13 +313,13 @@ public class GifDecoder {
|
|||||||
status = STATUS_FORMAT_ERROR;
|
status = STATUS_FORMAT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status = STATUS_OPEN_ERROR;
|
status = STATUS_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ public class GifDecoder {
|
|||||||
break;
|
break;
|
||||||
bi = 0;
|
bi = 0;
|
||||||
}
|
}
|
||||||
datum += (((int) block[bi]) & 0xff) << bits;
|
datum += ((block[bi]) & 0xff) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
bi++;
|
bi++;
|
||||||
count--;
|
count--;
|
||||||
@ -450,7 +450,7 @@ public class GifDecoder {
|
|||||||
pixelStack[top++] = suffix[code];
|
pixelStack[top++] = suffix[code];
|
||||||
code = prefix[code];
|
code = prefix[code];
|
||||||
}
|
}
|
||||||
first = ((int) suffix[code]) & 0xff;
|
first = (suffix[code]) & 0xff;
|
||||||
|
|
||||||
// Add a new string to the string table,
|
// Add a new string to the string table,
|
||||||
|
|
||||||
@ -563,9 +563,9 @@ public class GifDecoder {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (i < ncolors) {
|
while (i < ncolors) {
|
||||||
int r = ((int) c[j++]) & 0xff;
|
int r = (c[j++]) & 0xff;
|
||||||
int g = ((int) c[j++]) & 0xff;
|
int g = (c[j++]) & 0xff;
|
||||||
int b = ((int) c[j++]) & 0xff;
|
int b = (c[j++]) & 0xff;
|
||||||
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
|
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -746,8 +746,8 @@ public class GifDecoder {
|
|||||||
readBlock();
|
readBlock();
|
||||||
if (block[0] == 1) {
|
if (block[0] == 1) {
|
||||||
// loop count sub-block
|
// loop count sub-block
|
||||||
int b1 = ((int) block[1]) & 0xff;
|
int b1 = (block[1]) & 0xff;
|
||||||
int b2 = ((int) block[2]) & 0xff;
|
int b2 = (block[2]) & 0xff;
|
||||||
loopCount = (b2 << 8) | b1;
|
loopCount = (b2 << 8) | b1;
|
||||||
}
|
}
|
||||||
} while ((blockSize > 0) && !err());
|
} while ((blockSize > 0) && !err());
|
||||||
|
@ -21,7 +21,7 @@ public class ServerPropertyFile {
|
|||||||
if (f == null) throw new IllegalArgumentException("f ne doit pas être null");
|
if (f == null) throw new IllegalArgumentException("f ne doit pas être null");
|
||||||
file = f;
|
file = f;
|
||||||
|
|
||||||
data = new HashMap<String, Object>();
|
data = new HashMap<>();
|
||||||
data.put("name", "default_name");
|
data.put("name", "default_name");
|
||||||
data.put("memory", "512M");
|
data.put("memory", "512M");
|
||||||
data.put("javaArgs", "");
|
data.put("javaArgs", "");
|
||||||
@ -63,9 +63,7 @@ public class ServerPropertyFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean save() {
|
public boolean save() {
|
||||||
BufferedWriter out = null;
|
try (BufferedWriter out = new BufferedWriter(new FileWriter(file, false))) {
|
||||||
try {
|
|
||||||
out = new BufferedWriter(new FileWriter(file, false));
|
|
||||||
|
|
||||||
String jsonStr = new Gson().toJson(data);
|
String jsonStr = new Gson().toJson(data);
|
||||||
|
|
||||||
@ -76,10 +74,6 @@ public class ServerPropertyFile {
|
|||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.severe(e);
|
Log.severe(e);
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,9 +2,9 @@ package fr.pandacube.java.util;
|
|||||||
|
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
public static String formatDouble(double d) {
|
public static String formatDouble(double d) {
|
||||||
if (d == (long) d) return String.format("%d", (long) d);
|
if (d == (long) d)
|
||||||
else
|
return String.format("%d", (long) d);
|
||||||
return String.valueOf(d);
|
return String.valueOf(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public abstract class AbstractConfig {
|
|||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(f));
|
BufferedReader reader = new BufferedReader(new FileReader(f));
|
||||||
|
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
@ -111,8 +111,7 @@ public abstract class AbstractConfig {
|
|||||||
public static List<String> splitPermissionsString(String perms) {
|
public static List<String> splitPermissionsString(String perms) {
|
||||||
if (perms == null || perms.equals("*"))
|
if (perms == null || perms.equals("*"))
|
||||||
return null;
|
return null;
|
||||||
else
|
return getSplittedString(perms, ";");
|
||||||
return getSplittedString(perms, ";");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public final class ORM {
|
|||||||
if (offset != null) sql += " OFFSET " + offset;
|
if (offset != null) sql += " OFFSET " + offset;
|
||||||
sql += ";";
|
sql += ";";
|
||||||
|
|
||||||
SQLElementList<E> elmts = new SQLElementList<E>();
|
SQLElementList<E> elmts = new SQLElementList<>();
|
||||||
|
|
||||||
PreparedStatement ps = connection.getNativeConnection().prepareStatement(sql);
|
PreparedStatement ps = connection.getNativeConnection().prepareStatement(sql);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public abstract class SQLElement<E extends SQLElement<E>> {
|
|||||||
fieldsCache.put((Class<E>)getClass(), fields);
|
fieldsCache.put((Class<E>)getClass(), fields);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fields = (SQLFieldMap<E>) fieldsCache.get((Class<E>)getClass());
|
fields = (SQLFieldMap<E>) fieldsCache.get(getClass());
|
||||||
|
|
||||||
values = new LinkedHashMap<>(fields.size());
|
values = new LinkedHashMap<>(fields.size());
|
||||||
modifiedSinceLastSave = new HashSet<>(fields.size());
|
modifiedSinceLastSave = new HashSet<>(fields.size());
|
||||||
@ -188,7 +188,7 @@ public abstract class SQLElement<E extends SQLElement<E>> {
|
|||||||
return modifiedSinceLastSave.contains(field.name);
|
return modifiedSinceLastSave.contains(field.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "resource" })
|
||||||
public void save() throws ORMException {
|
public void save() throws ORMException {
|
||||||
if (!isValidForSave())
|
if (!isValidForSave())
|
||||||
throw new IllegalStateException(toString() + " has at least one undefined value and can't be saved.");
|
throw new IllegalStateException(toString() + " has at least one undefined value and can't be saved.");
|
||||||
|
@ -47,8 +47,10 @@ public class SQLElementList<E extends SQLElement<E>> extends ArrayList<E> {
|
|||||||
public synchronized <T> void setCommon(SQLField<E, T> field, T value) {
|
public synchronized <T> void setCommon(SQLField<E, T> field, T value) {
|
||||||
if (field != null && field.name == "id")
|
if (field != null && field.name == "id")
|
||||||
throw new IllegalArgumentException("Can't modify id field in a SQLElementList");
|
throw new IllegalArgumentException("Can't modify id field in a SQLElementList");
|
||||||
|
if (field == null)
|
||||||
|
throw new IllegalArgumentException("field can't be null");
|
||||||
|
|
||||||
Class<E> elemClass = (Class<E>) field.getSQLElementType();
|
Class<E> elemClass = field.getSQLElementType();
|
||||||
try {
|
try {
|
||||||
E emptyElement = elemClass.newInstance();
|
E emptyElement = elemClass.newInstance();
|
||||||
emptyElement.set(field, value, false);
|
emptyElement.set(field, value, false);
|
||||||
|
@ -32,7 +32,7 @@ public class DistanceUtil {
|
|||||||
return distanceToString(meterDist, precision, DistanceUnit.M, DistanceUnit.KM);
|
return distanceToString(meterDist, precision, DistanceUnit.M, DistanceUnit.KM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DistanceUnit implements Comparable<DistanceUnit> {
|
public enum DistanceUnit {
|
||||||
NM(0.000000001, "nm"), µM(0.000001, "µm"), MM(0.001, "mm"), CM(0.01, "cm"), M(1, "m"), KM(1000, "km");
|
NM(0.000000001, "nm"), µM(0.000001, "µm"), MM(0.001, "mm"), CM(0.01, "cm"), M(1, "m"), KM(1000, "km");
|
||||||
|
|
||||||
private final double multiplicator;
|
private final double multiplicator;
|
||||||
|
@ -164,7 +164,7 @@ public class TCPClient extends Thread implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PacketServer sendAndWaitForResponse(PacketClient packet, Predicate<PacketServer> responseCondition, boolean avoidListener) throws IOException, InterruptedException {
|
public PacketServer sendAndWaitForResponse(PacketClient packet, Predicate<PacketServer> responseCondition) throws IOException, InterruptedException {
|
||||||
AtomicReference<PacketServer> psStorage = new AtomicReference<>(null);
|
AtomicReference<PacketServer> psStorage = new AtomicReference<>(null);
|
||||||
synchronized (psStorage) {
|
synchronized (psStorage) {
|
||||||
sendAndGetResponse(packet, responseCondition, packetServer -> {
|
sendAndGetResponse(packet, responseCondition, packetServer -> {
|
||||||
|
@ -64,7 +64,7 @@ public abstract class Packet implements ByteSerializable {
|
|||||||
|
|
||||||
public static final Charset CHARSET = Pandacube.NETWORK_CHARSET;
|
public static final Charset CHARSET = Pandacube.NETWORK_CHARSET;
|
||||||
|
|
||||||
private static Map<Byte, Class<? extends Packet>> packetTypes = new HashMap<Byte, Class<? extends Packet>>();
|
private static Map<Byte, Class<? extends Packet>> packetTypes = new HashMap<>();
|
||||||
|
|
||||||
public static Packet constructPacket(byte[] data) {
|
public static Packet constructPacket(byte[] data) {
|
||||||
if (!packetTypes.containsKey(data[0]))
|
if (!packetTypes.containsKey(data[0]))
|
||||||
|
@ -8,7 +8,7 @@ import fr.pandacube.java.util.network.server.TCPServer.TCPServerClientConnection
|
|||||||
|
|
||||||
public class BandwidthCalculation {
|
public class BandwidthCalculation {
|
||||||
|
|
||||||
private List<PacketStat> packetHistory = new LinkedList<PacketStat>();
|
private List<PacketStat> packetHistory = new LinkedList<>();
|
||||||
|
|
||||||
public synchronized void addPacket(TCPServerClientConnection co, boolean in, long size) {
|
public synchronized void addPacket(TCPServerClientConnection co, boolean in, long size) {
|
||||||
packetHistory.add(new PacketStat(co, in, size));
|
packetHistory.add(new PacketStat(co, in, size));
|
||||||
|
@ -75,6 +75,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@SuppressWarnings("resource")
|
||||||
Socket socketClient = socket.accept();
|
Socket socketClient = socket.accept();
|
||||||
socketClient.setSendBufferSize(Pandacube.NETWORK_TCP_BUFFER_SIZE);
|
socketClient.setSendBufferSize(Pandacube.NETWORK_TCP_BUFFER_SIZE);
|
||||||
socketClient.setSoTimeout(Pandacube.NETWORK_TIMEOUT);
|
socketClient.setSoTimeout(Pandacube.NETWORK_TIMEOUT);
|
||||||
@ -96,7 +97,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class TCPServerClientConnection extends Thread {
|
public class TCPServerClientConnection extends Thread {
|
||||||
private Socket socket;
|
private Socket cSocket;
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
private OutputStream out;
|
private OutputStream out;
|
||||||
private SocketAddress address;
|
private SocketAddress address;
|
||||||
@ -108,10 +109,10 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
public TCPServerClientConnection(Socket s, int coId) throws IOException {
|
public TCPServerClientConnection(Socket s, int coId) throws IOException {
|
||||||
super("TCPSv " + socketName + " Conn#" + coId + " In");
|
super("TCPSv " + socketName + " Conn#" + coId + " In");
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
socket = s;
|
cSocket = s;
|
||||||
in = socket.getInputStream();
|
in = cSocket.getInputStream();
|
||||||
out = socket.getOutputStream();
|
out = cSocket.getOutputStream();
|
||||||
address = new InetSocketAddress(socket.getInetAddress(), socket.getPort());
|
address = new InetSocketAddress(cSocket.getInetAddress(), cSocket.getPort());
|
||||||
try {
|
try {
|
||||||
listener.onClientConnect(TCPServer.this, this);
|
listener.onClientConnect(TCPServer.this, this);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
@ -125,7 +126,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
byte[] code = new byte[1];
|
byte[] code = new byte[1];
|
||||||
while (!socket.isClosed() && in.read(code) != -1) {
|
while (!cSocket.isClosed() && in.read(code) != -1) {
|
||||||
byte[] sizeB = new byte[4];
|
byte[] sizeB = new byte[4];
|
||||||
if (in.read(sizeB) != 4) throw new IOException("Socket " + address + " closed");
|
if (in.read(sizeB) != 4) throw new IOException("Socket " + address + " closed");
|
||||||
|
|
||||||
@ -241,7 +242,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
if (socket.isClosed()) return;
|
if (cSocket.isClosed()) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
listener.onClientDisconnect(TCPServer.this, this);
|
listener.onClientDisconnect(TCPServer.this, this);
|
||||||
@ -252,7 +253,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
socket.close();
|
cSocket.close();
|
||||||
if (!Thread.currentThread().equals(outThread)) send(new PacketServer((byte) 0) {
|
if (!Thread.currentThread().equals(outThread)) send(new PacketServer((byte) 0) {
|
||||||
@Override public void serializeToByteBuffer(ByteBuffer buffer) {}
|
@Override public void serializeToByteBuffer(ByteBuffer buffer) {}
|
||||||
@Override public void deserializeFromByteBuffer(ByteBuffer buffer) {}
|
@Override public void deserializeFromByteBuffer(ByteBuffer buffer) {}
|
||||||
@ -263,7 +264,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class TCPServerConnectionOutputThread extends Thread {
|
private class TCPServerConnectionOutputThread extends Thread {
|
||||||
private BlockingQueue<PacketServer> packetQueue = new LinkedBlockingDeque<PacketServer>();
|
private BlockingQueue<PacketServer> packetQueue = new LinkedBlockingDeque<>();
|
||||||
|
|
||||||
public TCPServerConnectionOutputThread(int coId) {
|
public TCPServerConnectionOutputThread(int coId) {
|
||||||
super("TCPSv " + socketName + " Conn#" + coId + " Out");
|
super("TCPSv " + socketName + " Conn#" + coId + " Out");
|
||||||
@ -277,7 +278,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
while (!socket.isClosed()) {
|
while (!cSocket.isClosed()) {
|
||||||
PacketServer packet = packetQueue.poll(1, TimeUnit.SECONDS);
|
PacketServer packet = packetQueue.poll(1, TimeUnit.SECONDS);
|
||||||
byte[] data;
|
byte[] data;
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
@ -306,7 +307,7 @@ public class TCPServer extends Thread implements Closeable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this)
|
return new ToStringBuilder(this)
|
||||||
.append("thread", getName())
|
.append("thread", getName())
|
||||||
.append("socket", socket).toString();
|
.append("socket", cSocket).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class NetworkAPIListener implements Runnable {
|
|||||||
private int port = 0;
|
private int port = 0;
|
||||||
String pass;
|
String pass;
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
private HashMap<String, AbstractRequestExecutor> requestExecutors = new HashMap<String, AbstractRequestExecutor>();
|
private HashMap<String, AbstractRequestExecutor> requestExecutors = new HashMap<>();
|
||||||
private String name;
|
private String name;
|
||||||
private NAPIExecutionHandler nAPIExecutionHandler;
|
private NAPIExecutionHandler nAPIExecutionHandler;
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ public class NetworkAPIListener implements Runnable {
|
|||||||
try {
|
try {
|
||||||
// réception des connexion client
|
// réception des connexion client
|
||||||
while (!serverSocket.isClosed()) {
|
while (!serverSocket.isClosed()) {
|
||||||
|
@SuppressWarnings("resource")
|
||||||
Socket socketClient = serverSocket.accept();
|
Socket socketClient = serverSocket.accept();
|
||||||
nAPIExecutionHandler.handleRun(new PacketExecutor(socketClient, this));
|
nAPIExecutionHandler.handleRun(new PacketExecutor(socketClient, this));
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public enum ChatColor {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
|
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
|
||||||
BY_CHAR = new HashMap<Character, ChatColor>();
|
BY_CHAR = new HashMap<>();
|
||||||
for (ChatColor colour : ChatColor.values())
|
for (ChatColor colour : ChatColor.values())
|
||||||
BY_CHAR.put(Character.valueOf(colour.code), colour);
|
BY_CHAR.put(Character.valueOf(colour.code), colour);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public abstract class BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addExtra(BaseComponent component) {
|
public void addExtra(BaseComponent component) {
|
||||||
if (extra == null) extra = new ArrayList<BaseComponent>();
|
if (extra == null) extra = new ArrayList<>();
|
||||||
component.parent = this;
|
component.parent = this;
|
||||||
extra.add(component);
|
extra.add(component);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
|
|
||||||
public class ComponentBuilder {
|
public class ComponentBuilder {
|
||||||
private TextComponent current;
|
private TextComponent current;
|
||||||
private final List<BaseComponent> parts = new ArrayList<BaseComponent>();
|
private final List<BaseComponent> parts = new ArrayList<>();
|
||||||
|
|
||||||
public ComponentBuilder(ComponentBuilder original) {
|
public ComponentBuilder(ComponentBuilder original) {
|
||||||
current = new TextComponent(original.current);
|
current = new TextComponent(original.current);
|
||||||
|
@ -16,7 +16,7 @@ public class TextComponent extends BaseComponent {
|
|||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
public static BaseComponent[] fromLegacyText(String message) {
|
public static BaseComponent[] fromLegacyText(String message) {
|
||||||
ArrayList<TextComponent> components = new ArrayList<TextComponent>();
|
ArrayList<TextComponent> components = new ArrayList<>();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
TextComponent component = new TextComponent();
|
TextComponent component = new TextComponent();
|
||||||
Matcher matcher = url.matcher(message);
|
Matcher matcher = url.matcher(message);
|
||||||
@ -103,7 +103,7 @@ public class TextComponent extends BaseComponent {
|
|||||||
|
|
||||||
public /* varargs */ TextComponent(BaseComponent... extras) {
|
public /* varargs */ TextComponent(BaseComponent... extras) {
|
||||||
setText("");
|
setText("");
|
||||||
setExtra(new ArrayList<BaseComponent>(Arrays.asList(extras)));
|
setExtra(new ArrayList<>(Arrays.asList(extras)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ public class TranslatableComponent extends BaseComponent {
|
|||||||
super(original);
|
super(original);
|
||||||
setTranslate(original.getTranslate());
|
setTranslate(original.getTranslate());
|
||||||
if (original.getWith() != null) {
|
if (original.getWith() != null) {
|
||||||
ArrayList<BaseComponent> temp = new ArrayList<BaseComponent>();
|
ArrayList<BaseComponent> temp = new ArrayList<>();
|
||||||
for (BaseComponent baseComponent : original.getWith())
|
for (BaseComponent baseComponent : original.getWith())
|
||||||
temp.add(baseComponent.duplicate());
|
temp.add(baseComponent.duplicate());
|
||||||
setWith(temp);
|
setWith(temp);
|
||||||
@ -31,7 +31,7 @@ public class TranslatableComponent extends BaseComponent {
|
|||||||
|
|
||||||
public /* varargs */ TranslatableComponent(String translate, Object... with) {
|
public /* varargs */ TranslatableComponent(String translate, Object... with) {
|
||||||
setTranslate(translate);
|
setTranslate(translate);
|
||||||
ArrayList<BaseComponent> temp = new ArrayList<BaseComponent>();
|
ArrayList<BaseComponent> temp = new ArrayList<>();
|
||||||
for (Object w : with) {
|
for (Object w : with) {
|
||||||
if (w instanceof String) {
|
if (w instanceof String) {
|
||||||
temp.add(new TextComponent((String) w));
|
temp.add(new TextComponent((String) w));
|
||||||
@ -58,7 +58,7 @@ public class TranslatableComponent extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addWith(BaseComponent component) {
|
public void addWith(BaseComponent component) {
|
||||||
if (with == null) with = new ArrayList<BaseComponent>();
|
if (with == null) with = new ArrayList<>();
|
||||||
component.parent = this;
|
component.parent = this;
|
||||||
with.add(component);
|
with.add(component);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user