Fix npcs script (#266)

* fix the npcs

* add java8 compability

* .
This commit is contained in:
asafgb
2018-10-27 05:59:19 +03:00
committed by Ronan Lana
parent 589492572a
commit ba303432ff
2 changed files with 13 additions and 3 deletions

View File

@@ -987,9 +987,14 @@ public class EventInstanceManager {
}
private List<Integer> convertToIntegerArray(List<Double> list) {
List<Integer> intList = new ArrayList<>();
List<Integer> intList;
if(ServerConstants.JAVA_8)
intList=new ArrayList<Integer> (new ArrayList(java.util.Arrays.asList(list.toArray())));
else
{
intList = new ArrayList<>();
for(Double d: list) intList.add(d.intValue());
}
return intList;
}

View File

@@ -60,6 +60,7 @@ import net.server.audit.LockCollector;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.MonitoredReentrantLock;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
import jdk.nashorn.api.scripting.ScriptUtils;
/**
*
@@ -645,7 +646,11 @@ public class EventManager {
Object p = iv.invokeFunction("getEligibleParty", party.getPartyMembers());
if(p != null) {
List<MaplePartyCharacter> lmpc = new ArrayList<>((List<MaplePartyCharacter>) p);
List<MaplePartyCharacter> lmpc;
if(ServerConstants.JAVA_8)
lmpc = new ArrayList<>(((Map<String, MaplePartyCharacter>)(ScriptUtils.convert(p, Map.class))).values());
else
lmpc = new ArrayList<>((List<MaplePartyCharacter>) p);
party.setEligibleMembers(lmpc);
return lmpc;
}