Skip to content

Commit

Permalink
Simplify List values
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed May 10, 2019
1 parent 74c8283 commit 51a5f2f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w19a</version>
<version>19w19b</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private static Object simplify(Value value, boolean asKey) {
Map<Value, Value> map = value.asMapValue().map();
simple = unpack(value.asMapValue());
} else if (value.isArrayValue()) {
simple = value.asArrayValue().list();
LinkedList<Object> objects = new LinkedList<Object>();
for (Value v : value.asArrayValue().list()) objects.add(simplify(v, false));
simple = objects;
} else if (value.isBooleanValue()) {
simple = value.asBooleanValue().getBoolean();
} else if (value.isFloatValue()) {
Expand Down
2 changes: 1 addition & 1 deletion Client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w19a</version>
<version>19w19b</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion Server/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w19a</version>
<version>19w19b</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
7 changes: 0 additions & 7 deletions Server/api/src/net/ME1312/SubData/Server/DataServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ public void unwhitelist(String address) {
whitelist.put(address, false);
}

/**
* Clone this SubData Server Instance on another port
*
* @param port Port Number
*/
public abstract DataServer clone(int port) throws IOException;

/**
* Drops all connections and close the SubData Listener
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private static Object simplify(Value value, boolean asKey) {
Map<Value, Value> map = value.asMapValue().map();
simple = unpack(value.asMapValue());
} else if (value.isArrayValue()) {
simple = value.asArrayValue().list();
LinkedList<Object> objects = new LinkedList<Object>();
for (Value v : value.asArrayValue().list()) objects.add(simplify(v, false));
simple = objects;
} else if (value.isBooleanValue()) {
simple = value.asBooleanValue().getBoolean();
} else if (value.isFloatValue()) {
Expand Down
2 changes: 1 addition & 1 deletion Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w19a</version>
<version>19w19b</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
17 changes: 0 additions & 17 deletions Server/src/net/ME1312/SubData/Server/SubDataServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class SubDataServer extends DataServer {
private ServerSocket server;
private String address;
SubDataProtocol protocol;
ReturnCallback<Integer, Object[]> constructor;
Callback<Runnable> scheduler;
String cipher;
Logger log;
Expand All @@ -39,18 +38,9 @@ public class SubDataServer extends DataServer {
this.address = server.getLocalSocketAddress().toString();
whitelist(address.getHostAddress());
}

final String fc = cipher;
this.protocol = protocol;
this.scheduler = scheduler;
this.log = log;
this.constructor = i -> new Object[] {
scheduler,
log,
address,
i,
fc
};

this.cipher = cipher = (cipher != null)?cipher:"NULL"; // Validate Cipher
String[] ciphers = (cipher.contains("/"))?cipher.split("/"):new String[]{cipher};
Expand Down Expand Up @@ -168,13 +158,6 @@ public void removeClient(UUID id) throws IOException {
}
}

@SuppressWarnings("unchecked")
@Override
public SubDataServer clone(int port) throws IOException {
Object[] opt = constructor.run(port);
return protocol.open((Callback<Runnable>) opt[0], (Logger) opt[1], (InetAddress) opt[2], (int) opt[3], (String) opt[4]);
}

public void close() throws IOException {
boolean result = true;
LinkedList<ReturnCallback<DataServer, Boolean>> events = on.close;
Expand Down

0 comments on commit 51a5f2f

Please sign in to comment.