Fix Java 8 support (#489)
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
package scripting.event;
|
||||
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import jdk.nashorn.api.scripting.ScriptUtils;
|
||||
import tools.exceptions.EventInstanceInProgressException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -165,14 +167,14 @@ public class EventManager {
|
||||
startLock = startLock.dispose();
|
||||
}
|
||||
|
||||
private static List<Integer> convertToIntegerArray(List<Double> list) {
|
||||
private List<Integer> convertToIntegerArray(List<Double> list) {
|
||||
List<Integer> intList = new ArrayList<>();
|
||||
for(Double d: list) intList.add(d.intValue());
|
||||
|
||||
return intList;
|
||||
}
|
||||
|
||||
public static long getLobbyDelay() {
|
||||
public long getLobbyDelay() {
|
||||
return ServerConstants.EVENT_LOBBY_DELAY;
|
||||
}
|
||||
|
||||
@@ -181,7 +183,6 @@ public class EventManager {
|
||||
if (!ServerConstants.JAVA_8) {
|
||||
return convertToIntegerArray((List<Double>)iv.invokeFunction("setLobbyRange", (Object) null));
|
||||
} else { // java 8 support here thanks to MedicOP
|
||||
/*
|
||||
ScriptObjectMirror object = (ScriptObjectMirror) iv.invokeFunction("setLobbyRange", (Object) null);
|
||||
int[] to = object.to(int[].class);
|
||||
List<Integer> list = new ArrayList<>();
|
||||
@@ -189,9 +190,7 @@ public class EventManager {
|
||||
list.add(i);
|
||||
}
|
||||
return list;
|
||||
*/
|
||||
|
||||
throw new NoSuchMethodException();
|
||||
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) { // they didn't define a lobby range
|
||||
List<Integer> defaultRange = new ArrayList<>();
|
||||
@@ -750,13 +749,12 @@ public class EventManager {
|
||||
if(p != null) {
|
||||
List<MaplePartyCharacter> lmpc;
|
||||
|
||||
/*if(ServerConstants.JAVA_8) {
|
||||
if(ServerConstants.JAVA_8) {
|
||||
lmpc = new ArrayList<>(((Map<String, MaplePartyCharacter>)(ScriptUtils.convert(p, Map.class))).values());
|
||||
} else {
|
||||
lmpc = new ArrayList<>((List<MaplePartyCharacter>) p);
|
||||
}*/
|
||||
|
||||
lmpc = new ArrayList<>((List<MaplePartyCharacter>) p);
|
||||
}
|
||||
|
||||
party.setEligibleMembers(lmpc);
|
||||
return lmpc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user