Reformat and clean up "scripting" package
This commit is contained in:
1 parent
9b1dc76854
commit
d389665bd7
16 files changed
+3382
-3314
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -32,7 +32,6 @@ import java.io.FileReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractScriptManager {
|
public abstract class AbstractScriptManager {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -54,7 +54,6 @@ import java.util.logging.Logger;
|
|||||||
//import jdk.nashorn.api.scripting.ScriptUtils;
|
//import jdk.nashorn.api.scripting.ScriptUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
@@ -63,22 +62,22 @@ public class EventManager {
|
|||||||
private Channel cserv;
|
private Channel cserv;
|
||||||
private World wserv;
|
private World wserv;
|
||||||
private Server server;
|
private Server server;
|
||||||
private EventScriptScheduler ess = new EventScriptScheduler();
|
private final EventScriptScheduler ess = new EventScriptScheduler();
|
||||||
private Map<String, EventInstanceManager> instances = new HashMap<>();
|
private final Map<String, EventInstanceManager> instances = new HashMap<>();
|
||||||
private Map<String, Integer> instanceLocks = new HashMap<>();
|
private final Map<String, Integer> instanceLocks = new HashMap<>();
|
||||||
private final Queue<Integer> queuedGuilds = new LinkedList<>();
|
private final Queue<Integer> queuedGuilds = new LinkedList<>();
|
||||||
private final Map<Integer, Integer> queuedGuildLeaders = new HashMap<>();
|
private final Map<Integer, Integer> queuedGuildLeaders = new HashMap<>();
|
||||||
private List<Boolean> openedLobbys;
|
private final List<Boolean> openedLobbys;
|
||||||
private List<EventInstanceManager> readyInstances = new LinkedList<>();
|
private final List<EventInstanceManager> readyInstances = new LinkedList<>();
|
||||||
private Integer readyId = 0, onLoadInstances = 0;
|
private Integer readyId = 0, onLoadInstances = 0;
|
||||||
private Properties props = new Properties();
|
private final Properties props = new Properties();
|
||||||
private String name;
|
private final String name;
|
||||||
private MonitoredReentrantLock lobbyLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_LOBBY);
|
private MonitoredReentrantLock lobbyLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_LOBBY);
|
||||||
private MonitoredReentrantLock queueLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_QUEUE);
|
private MonitoredReentrantLock queueLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_QUEUE);
|
||||||
private MonitoredReentrantLock startLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_START);
|
private MonitoredReentrantLock startLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_START);
|
||||||
|
|
||||||
private Set<Integer> playerPermit = new HashSet<>();
|
private final Set<Integer> playerPermit = new HashSet<>();
|
||||||
private Semaphore startSemaphore = new Semaphore(7);
|
private final Semaphore startSemaphore = new Semaphore(7);
|
||||||
|
|
||||||
private static final int maxLobbys = 8; // an event manager holds up to this amount of concurrent lobbys
|
private static final int maxLobbys = 8; // an event manager holds up to this amount of concurrent lobbys
|
||||||
|
|
||||||
@@ -90,7 +89,9 @@ public class EventManager {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
this.openedLobbys = new ArrayList<>();
|
this.openedLobbys = new ArrayList<>();
|
||||||
for(int i = 0; i < maxLobbys; i++) this.openedLobbys.add(false);
|
for (int i = 0; i < maxLobbys; i++) {
|
||||||
|
this.openedLobbys.add(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDisposed() {
|
private boolean isDisposed() {
|
||||||
@@ -107,12 +108,12 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collection<EventInstanceManager> eimList;
|
Collection<EventInstanceManager> eimList;
|
||||||
synchronized(instances) {
|
synchronized (instances) {
|
||||||
eimList = getInstances();
|
eimList = getInstances();
|
||||||
instances.clear();
|
instances.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(EventInstanceManager eim : eimList) {
|
for (EventInstanceManager eim : eimList) {
|
||||||
eim.dispose(true);
|
eim.dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ public class EventManager {
|
|||||||
queueLock.unlock();
|
queueLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(EventInstanceManager eim : readyEims) {
|
for (EventInstanceManager eim : readyEims) {
|
||||||
eim.dispose(true);
|
eim.dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ public class EventManager {
|
|||||||
public EventInstanceManager newInstance(String name) throws EventInstanceInProgressException {
|
public EventInstanceManager newInstance(String name) throws EventInstanceInProgressException {
|
||||||
EventInstanceManager ret = getReadyInstance();
|
EventInstanceManager ret = getReadyInstance();
|
||||||
|
|
||||||
if(ret == null) {
|
if (ret == null) {
|
||||||
ret = new EventInstanceManager(this, name);
|
ret = new EventInstanceManager(this, name);
|
||||||
} else {
|
} else {
|
||||||
ret.setName(name);
|
ret.setName(name);
|
||||||
@@ -305,7 +306,7 @@ public class EventManager {
|
|||||||
lobbyId = maxLobbys - 1;
|
lobbyId = maxLobbys - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!openedLobbys.get(lobbyId)) {
|
if (!openedLobbys.get(lobbyId)) {
|
||||||
openedLobbys.set(lobbyId, true);
|
openedLobbys.set(lobbyId, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -318,10 +319,14 @@ public class EventManager {
|
|||||||
|
|
||||||
private void freeLobbyInstance(String lobbyName) {
|
private void freeLobbyInstance(String lobbyName) {
|
||||||
Integer i = instanceLocks.get(lobbyName);
|
Integer i = instanceLocks.get(lobbyName);
|
||||||
if(i == null) return;
|
if (i == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
instanceLocks.remove(lobbyName);
|
instanceLocks.remove(lobbyName);
|
||||||
if(i > -1) setLockLobby(i, false);
|
if (i > -1) {
|
||||||
|
setLockLobby(i, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -347,7 +352,7 @@ public class EventManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(true) {
|
while (true) {
|
||||||
Throwable t = a;
|
Throwable t = a;
|
||||||
a = a.getCause();
|
a = a.getCause();
|
||||||
|
|
||||||
@@ -380,21 +385,26 @@ public class EventManager {
|
|||||||
|
|
||||||
//Expedition method: starts an expedition
|
//Expedition method: starts an expedition
|
||||||
public boolean startInstance(int lobbyId, Expedition exped, Character leader) {
|
public boolean startInstance(int lobbyId, Expedition exped, Character leader) {
|
||||||
if (this.isDisposed()) return false;
|
if (this.isDisposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
if (!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||||
playerPermit.add(leader.getId());
|
playerPermit.add(leader.getId());
|
||||||
|
|
||||||
startLock.lock();
|
startLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
lobbyId = availableLobbyInstance();
|
lobbyId = availableLobbyInstance();
|
||||||
if(lobbyId == -1) return false;
|
if (lobbyId == -1) {
|
||||||
}
|
return false;
|
||||||
else {
|
}
|
||||||
if(!startLobbyInstance(lobbyId)) return false;
|
} else {
|
||||||
|
if (!startLobbyInstance(lobbyId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventInstanceManager eim;
|
EventInstanceManager eim;
|
||||||
@@ -407,7 +417,7 @@ public class EventManager {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lobbyId > -1) {
|
if (lobbyId > -1) {
|
||||||
setLockLobby(lobbyId, false);
|
setLockLobby(lobbyId, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -430,7 +440,7 @@ public class EventManager {
|
|||||||
startSemaphore.release();
|
startSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
playerPermit.remove(leader.getId());
|
playerPermit.remove(leader.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,23 +457,24 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean startInstance(int lobbyId, Character chr, Character leader, int difficulty) {
|
public boolean startInstance(int lobbyId, Character chr, Character leader, int difficulty) {
|
||||||
if (this.isDisposed()) return false;
|
if (this.isDisposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
if (!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||||
playerPermit.add(leader.getId());
|
playerPermit.add(leader.getId());
|
||||||
|
|
||||||
startLock.lock();
|
startLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
lobbyId = availableLobbyInstance();
|
lobbyId = availableLobbyInstance();
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
if (!startLobbyInstance(lobbyId)) {
|
||||||
if(!startLobbyInstance(lobbyId)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,14 +489,16 @@ public class EventManager {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lobbyId > -1) {
|
if (lobbyId > -1) {
|
||||||
setLockLobby(lobbyId, false);
|
setLockLobby(lobbyId, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
eim.setLeader(leader);
|
eim.setLeader(leader);
|
||||||
|
|
||||||
if(chr != null) eim.registerPlayer(chr);
|
if (chr != null) {
|
||||||
|
eim.registerPlayer(chr);
|
||||||
|
}
|
||||||
|
|
||||||
eim.startEvent();
|
eim.startEvent();
|
||||||
} catch (ScriptException | NoSuchMethodException ex) {
|
} catch (ScriptException | NoSuchMethodException ex) {
|
||||||
@@ -499,7 +512,7 @@ public class EventManager {
|
|||||||
startSemaphore.release();
|
startSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
playerPermit.remove(leader.getId());
|
playerPermit.remove(leader.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,21 +529,26 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean startInstance(int lobbyId, Party party, MapleMap map, Character leader) {
|
public boolean startInstance(int lobbyId, Party party, MapleMap map, Character leader) {
|
||||||
if (this.isDisposed()) return false;
|
if (this.isDisposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
if (!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||||
playerPermit.add(leader.getId());
|
playerPermit.add(leader.getId());
|
||||||
|
|
||||||
startLock.lock();
|
startLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
lobbyId = availableLobbyInstance();
|
lobbyId = availableLobbyInstance();
|
||||||
if(lobbyId == -1) return false;
|
if (lobbyId == -1) {
|
||||||
}
|
return false;
|
||||||
else {
|
}
|
||||||
if(!startLobbyInstance(lobbyId)) return false;
|
} else {
|
||||||
|
if (!startLobbyInstance(lobbyId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventInstanceManager eim;
|
EventInstanceManager eim;
|
||||||
@@ -543,7 +561,7 @@ public class EventManager {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lobbyId > -1) {
|
if (lobbyId > -1) {
|
||||||
setLockLobby(lobbyId, false);
|
setLockLobby(lobbyId, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -566,7 +584,7 @@ public class EventManager {
|
|||||||
startSemaphore.release();
|
startSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
playerPermit.remove(leader.getId());
|
playerPermit.remove(leader.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,21 +601,26 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean startInstance(int lobbyId, Party party, MapleMap map, int difficulty, Character leader) {
|
public boolean startInstance(int lobbyId, Party party, MapleMap map, int difficulty, Character leader) {
|
||||||
if (this.isDisposed()) return false;
|
if (this.isDisposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
if (!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||||
playerPermit.add(leader.getId());
|
playerPermit.add(leader.getId());
|
||||||
|
|
||||||
startLock.lock();
|
startLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
lobbyId = availableLobbyInstance();
|
lobbyId = availableLobbyInstance();
|
||||||
if(lobbyId == -1) return false;
|
if (lobbyId == -1) {
|
||||||
}
|
return false;
|
||||||
else {
|
}
|
||||||
if(!startLobbyInstance(lobbyId)) return false;
|
} else {
|
||||||
|
if (!startLobbyInstance(lobbyId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventInstanceManager eim;
|
EventInstanceManager eim;
|
||||||
@@ -610,7 +633,7 @@ public class EventManager {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lobbyId > -1) {
|
if (lobbyId > -1) {
|
||||||
setLockLobby(lobbyId, false);
|
setLockLobby(lobbyId, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -633,7 +656,7 @@ public class EventManager {
|
|||||||
startSemaphore.release();
|
startSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
playerPermit.remove(leader.getId());
|
playerPermit.remove(leader.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,25 +677,30 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean startInstance(int lobbyId, EventInstanceManager eim, String ldr, Character leader) {
|
public boolean startInstance(int lobbyId, EventInstanceManager eim, String ldr, Character leader) {
|
||||||
if (this.isDisposed()) return false;
|
if (this.isDisposed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
if (!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||||
playerPermit.add(leader.getId());
|
playerPermit.add(leader.getId());
|
||||||
|
|
||||||
startLock.lock();
|
startLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(lobbyId == -1) {
|
if (lobbyId == -1) {
|
||||||
lobbyId = availableLobbyInstance();
|
lobbyId = availableLobbyInstance();
|
||||||
if(lobbyId == -1) return false;
|
if (lobbyId == -1) {
|
||||||
}
|
return false;
|
||||||
else {
|
}
|
||||||
if(!startLobbyInstance(lobbyId)) return false;
|
} else {
|
||||||
|
if (!startLobbyInstance(lobbyId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eim == null) {
|
if (eim == null) {
|
||||||
if(lobbyId > -1) {
|
if (lobbyId > -1) {
|
||||||
setLockLobby(lobbyId, false);
|
setLockLobby(lobbyId, false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -695,7 +723,7 @@ public class EventManager {
|
|||||||
startSemaphore.release();
|
startSemaphore.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
playerPermit.remove(leader.getId());
|
playerPermit.remove(leader.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,14 +766,14 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Monster getMonster(int mid) {
|
public Monster getMonster(int mid) {
|
||||||
return(LifeFactory.getMonster(mid));
|
return (LifeFactory.getMonster(mid));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportReadyGuild(Integer guildId) {
|
private void exportReadyGuild(Integer guildId) {
|
||||||
Guild mg = server.getGuild(guildId);
|
Guild mg = server.getGuild(guildId);
|
||||||
String callout = "[Guild Quest] Your guild has been registered to attend to the Sharenian Guild Quest at channel " + this.getChannelServer().getId()
|
String callout = "[Guild Quest] Your guild has been registered to attend to the Sharenian Guild Quest at channel " + this.getChannelServer().getId()
|
||||||
+ " and HAS JUST STARTED THE STRATEGY PHASE. After 3 minutes, no more guild members will be allowed to join the effort."
|
+ " and HAS JUST STARTED THE STRATEGY PHASE. After 3 minutes, no more guild members will be allowed to join the effort."
|
||||||
+ " Check out Shuang at the excavation site in Perion for more info.";
|
+ " Check out Shuang at the excavation site in Perion for more info.";
|
||||||
|
|
||||||
mg.dropMessage(6, callout);
|
mg.dropMessage(6, callout);
|
||||||
}
|
}
|
||||||
@@ -753,49 +781,54 @@ public class EventManager {
|
|||||||
private void exportMovedQueueToGuild(Integer guildId, int place) {
|
private void exportMovedQueueToGuild(Integer guildId, int place) {
|
||||||
Guild mg = server.getGuild(guildId);
|
Guild mg = server.getGuild(guildId);
|
||||||
String callout = "[Guild Quest] Your guild has been registered to attend to the Sharenian Guild Quest at channel " + this.getChannelServer().getId()
|
String callout = "[Guild Quest] Your guild has been registered to attend to the Sharenian Guild Quest at channel " + this.getChannelServer().getId()
|
||||||
+ " and is currently on the " + GameConstants.ordinal(place) + " place on the waiting queue.";
|
+ " and is currently on the " + GameConstants.ordinal(place) + " place on the waiting queue.";
|
||||||
|
|
||||||
mg.dropMessage(6, callout);
|
mg.dropMessage(6, callout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getNextGuildQueue() {
|
private List<Integer> getNextGuildQueue() {
|
||||||
synchronized(queuedGuilds) {
|
synchronized (queuedGuilds) {
|
||||||
Integer guildId = queuedGuilds.poll();
|
Integer guildId = queuedGuilds.poll();
|
||||||
if(guildId == null) return null;
|
if (guildId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
wserv.removeGuildQueued(guildId);
|
wserv.removeGuildQueued(guildId);
|
||||||
Integer leaderId = queuedGuildLeaders.remove(guildId);
|
Integer leaderId = queuedGuildLeaders.remove(guildId);
|
||||||
|
|
||||||
int place = 1;
|
int place = 1;
|
||||||
for(Integer i: queuedGuilds) {
|
for (Integer i : queuedGuilds) {
|
||||||
exportMovedQueueToGuild(i, place);
|
exportMovedQueueToGuild(i, place);
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> list = new ArrayList<>(2);
|
List<Integer> list = new ArrayList<>(2);
|
||||||
list.add(guildId); list.add(leaderId);
|
list.add(guildId);
|
||||||
|
list.add(leaderId);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQueueFull() {
|
public boolean isQueueFull() {
|
||||||
synchronized(queuedGuilds) {
|
synchronized (queuedGuilds) {
|
||||||
return queuedGuilds.size() >= YamlConfig.config.server.EVENT_MAX_GUILD_QUEUE;
|
return queuedGuilds.size() >= YamlConfig.config.server.EVENT_MAX_GUILD_QUEUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQueueSize() {
|
public int getQueueSize() {
|
||||||
synchronized(queuedGuilds) {
|
synchronized (queuedGuilds) {
|
||||||
return queuedGuilds.size();
|
return queuedGuilds.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte addGuildToQueue(Integer guildId, Integer leaderId) {
|
public byte addGuildToQueue(Integer guildId, Integer leaderId) {
|
||||||
if(wserv.isGuildQueued(guildId)) return -1;
|
if (wserv.isGuildQueued(guildId)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if(!isQueueFull()) {
|
if (!isQueueFull()) {
|
||||||
boolean canStartAhead;
|
boolean canStartAhead;
|
||||||
synchronized(queuedGuilds) {
|
synchronized (queuedGuilds) {
|
||||||
canStartAhead = queuedGuilds.isEmpty();
|
canStartAhead = queuedGuilds.isEmpty();
|
||||||
|
|
||||||
queuedGuilds.add(guildId);
|
queuedGuilds.add(guildId);
|
||||||
@@ -806,9 +839,9 @@ public class EventManager {
|
|||||||
exportMovedQueueToGuild(guildId, place);
|
exportMovedQueueToGuild(guildId, place);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canStartAhead) {
|
if (canStartAhead) {
|
||||||
if(!attemptStartGuildInstance()) {
|
if (!attemptStartGuildInstance()) {
|
||||||
synchronized(queuedGuilds) {
|
synchronized (queuedGuilds) {
|
||||||
queuedGuilds.add(guildId);
|
queuedGuilds.add(guildId);
|
||||||
wserv.putGuildQueued(guildId);
|
wserv.putGuildQueued(guildId);
|
||||||
queuedGuildLeaders.put(guildId, leaderId);
|
queuedGuildLeaders.put(guildId, leaderId);
|
||||||
@@ -827,16 +860,16 @@ public class EventManager {
|
|||||||
public boolean attemptStartGuildInstance() {
|
public boolean attemptStartGuildInstance() {
|
||||||
Character chr = null;
|
Character chr = null;
|
||||||
List<Integer> guildInstance = null;
|
List<Integer> guildInstance = null;
|
||||||
while(chr == null) {
|
while (chr == null) {
|
||||||
guildInstance = getNextGuildQueue();
|
guildInstance = getNextGuildQueue();
|
||||||
if(guildInstance == null) {
|
if (guildInstance == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
chr = cserv.getPlayerStorage().getCharacterById(guildInstance.get(1));
|
chr = cserv.getPlayerStorage().getCharacterById(guildInstance.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(startInstance(chr)) {
|
if (startInstance(chr)) {
|
||||||
exportReadyGuild(guildInstance.get(0));
|
exportReadyGuild(guildInstance.get(0));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -871,7 +904,7 @@ public class EventManager {
|
|||||||
private EventInstanceManager getReadyInstance() {
|
private EventInstanceManager getReadyInstance() {
|
||||||
queueLock.lock();
|
queueLock.lock();
|
||||||
try {
|
try {
|
||||||
if(readyInstances.isEmpty()) {
|
if (readyInstances.isEmpty()) {
|
||||||
fillEimQueue();
|
fillEimQueue();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -889,7 +922,9 @@ public class EventManager {
|
|||||||
int nextEventId;
|
int nextEventId;
|
||||||
queueLock.lock();
|
queueLock.lock();
|
||||||
try {
|
try {
|
||||||
if (this.isDisposed() || readyInstances.size() + onLoadInstances >= Math.ceil((double)maxLobbys / 3.0)) return;
|
if (this.isDisposed() || readyInstances.size() + onLoadInstances >= Math.ceil((double) maxLobbys / 3.0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
onLoadInstances++;
|
onLoadInstances++;
|
||||||
nextEventId = readyId;
|
nextEventId = readyId;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package scripting.event;
|
|||||||
import scripting.event.scheduler.EventScriptScheduler;
|
import scripting.event.scheduler.EventScriptScheduler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class EventScheduledFuture {
|
public class EventScheduledFuture {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
*/
|
*/
|
||||||
public class EventScriptManager extends AbstractScriptManager {
|
public class EventScriptManager extends AbstractScriptManager {
|
||||||
@@ -51,6 +50,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
|||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
this.em = em;
|
this.em = em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Invocable iv;
|
public Invocable iv;
|
||||||
public EventManager em;
|
public EventManager em;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,18 +36,17 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class EventScriptScheduler {
|
public class EventScriptScheduler {
|
||||||
|
|
||||||
private boolean disposed = false;
|
private boolean disposed = false;
|
||||||
private int idleProcs = 0;
|
private int idleProcs = 0;
|
||||||
private Map<Runnable, Long> registeredEntries = new HashMap<>();
|
private final Map<Runnable, Long> registeredEntries = new HashMap<>();
|
||||||
|
|
||||||
private ScheduledFuture<?> schedulerTask = null;
|
private ScheduledFuture<?> schedulerTask = null;
|
||||||
private MonitoredReentrantLock schedulerLock;
|
private MonitoredReentrantLock schedulerLock;
|
||||||
private Runnable monitorTask = () -> runBaseSchedule();
|
private final Runnable monitorTask = () -> runBaseSchedule();
|
||||||
|
|
||||||
public EventScriptScheduler() {
|
public EventScriptScheduler() {
|
||||||
schedulerLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_SCHDL, true);
|
schedulerLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_SCHDL, true);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import server.ItemInformationProvider.ScriptedItem;
|
|||||||
|
|
||||||
public class ItemScriptManager {
|
public class ItemScriptManager {
|
||||||
|
|
||||||
private static ItemScriptManager instance = new ItemScriptManager();
|
private static final ItemScriptManager instance = new ItemScriptManager();
|
||||||
|
|
||||||
public static ItemScriptManager getInstance() {
|
public static ItemScriptManager getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
|
|||||||
@@ -25,11 +25,10 @@ import client.Client;
|
|||||||
import scripting.AbstractPlayerInteraction;
|
import scripting.AbstractPlayerInteraction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevintjuh93
|
* @author kevintjuh93
|
||||||
*/
|
*/
|
||||||
public class ItemScriptMethods extends AbstractPlayerInteraction {
|
public class ItemScriptMethods extends AbstractPlayerInteraction {
|
||||||
public ItemScriptMethods(Client c) {
|
public ItemScriptMethods(Client c) {
|
||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,9 +30,9 @@ import tools.PacketCreator;
|
|||||||
|
|
||||||
public class MapScriptMethods extends AbstractPlayerInteraction {
|
public class MapScriptMethods extends AbstractPlayerInteraction {
|
||||||
|
|
||||||
private String rewardstring = " title has been rewarded. Please see NPC Dalair to receive your Medal.";
|
private final String rewardstring = " title has been rewarded. Please see NPC Dalair to receive your Medal.";
|
||||||
|
|
||||||
public MapScriptMethods(Client c) {
|
public MapScriptMethods(Client c) {
|
||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -37,7 +37,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
*/
|
*/
|
||||||
public class NPCScriptManager extends AbstractScriptManager {
|
public class NPCScriptManager extends AbstractScriptManager {
|
||||||
|
|||||||
@@ -29,12 +29,11 @@ import server.quest.actions.ExpAction;
|
|||||||
import server.quest.actions.MesoAction;
|
import server.quest.actions.MesoAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RMZero213
|
* @author RMZero213
|
||||||
*/
|
*/
|
||||||
public class QuestActionManager extends NPCConversationManager {
|
public class QuestActionManager extends NPCConversationManager {
|
||||||
private boolean start; // this is if the script in question is start or end
|
private final boolean start; // this is if the script in question is start or end
|
||||||
private int quest;
|
private final int quest;
|
||||||
|
|
||||||
public QuestActionManager(Client c, int quest, int npc, boolean start) {
|
public QuestActionManager(Client c, int quest, int npc, boolean start) {
|
||||||
super(c, npc, null);
|
super(c, npc, null);
|
||||||
|
|||||||
@@ -35,14 +35,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RMZero213
|
* @author RMZero213
|
||||||
*/
|
*/
|
||||||
public class QuestScriptManager extends AbstractScriptManager {
|
public class QuestScriptManager extends AbstractScriptManager {
|
||||||
private static final QuestScriptManager instance = new QuestScriptManager();
|
private static final QuestScriptManager instance = new QuestScriptManager();
|
||||||
|
|
||||||
private final Map<Client, QuestActionManager> qms = new HashMap<>();
|
private final Map<Client, QuestActionManager> qms = new HashMap<>();
|
||||||
private final Map<Client, Invocable> scripts = new HashMap<>();
|
private final Map<Client, Invocable> scripts = new HashMap<>();
|
||||||
|
|
||||||
public static QuestScriptManager getInstance() {
|
public static QuestScriptManager getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
@@ -57,7 +56,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Client c, short questid, int npc) {
|
public void start(Client c, short questid, int npc) {
|
||||||
Quest quest = Quest.getInstance(questid);
|
Quest quest = Quest.getInstance(questid);
|
||||||
try {
|
try {
|
||||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||||
@@ -95,20 +94,20 @@ public class QuestScriptManager extends AbstractScriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Client c, byte mode, byte type, int selection) {
|
public void start(Client c, byte mode, byte type, int selection) {
|
||||||
Invocable iv = scripts.get(c);
|
Invocable iv = scripts.get(c);
|
||||||
if (iv != null) {
|
if (iv != null) {
|
||||||
try {
|
try {
|
||||||
c.setClickedNPC();
|
c.setClickedNPC();
|
||||||
iv.invokeFunction("start", mode, type, selection);
|
iv.invokeFunction("start", mode, type, selection);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
||||||
dispose(c);
|
dispose(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void end(Client c, short questid, int npc) {
|
public void end(Client c, short questid, int npc) {
|
||||||
Quest quest = Quest.getInstance(questid);
|
Quest quest = Quest.getInstance(questid);
|
||||||
if (!c.getPlayer().getQuest(quest).getStatus().equals(QuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) {
|
if (!c.getPlayer().getQuest(quest).getStatus().equals(QuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) {
|
||||||
dispose(c);
|
dispose(c);
|
||||||
@@ -150,50 +149,50 @@ public class QuestScriptManager extends AbstractScriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void end(Client c, byte mode, byte type, int selection) {
|
public void end(Client c, byte mode, byte type, int selection) {
|
||||||
Invocable iv = scripts.get(c);
|
Invocable iv = scripts.get(c);
|
||||||
if (iv != null) {
|
if (iv != null) {
|
||||||
try {
|
|
||||||
c.setClickedNPC();
|
|
||||||
iv.invokeFunction("end", mode, type, selection);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
|
||||||
dispose(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void raiseOpen(Client c, short questid, int npc) {
|
|
||||||
try {
|
try {
|
||||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
c.setClickedNPC();
|
||||||
if (qms.containsKey(c)) {
|
iv.invokeFunction("end", mode, type, selection);
|
||||||
return;
|
} catch (final Exception e) {
|
||||||
}
|
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e);
|
||||||
if (c.canClickNPC()) {
|
|
||||||
qms.put(c, qm);
|
|
||||||
|
|
||||||
ScriptEngine engine = getQuestScriptEngine(c, questid);
|
|
||||||
if (engine == null) {
|
|
||||||
//FilePrinter.printError(FilePrinter.QUEST_UNCODED, "RAISE Quest " + questid + " is uncoded.");
|
|
||||||
qm.dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
engine.put("qm", qm);
|
|
||||||
|
|
||||||
Invocable iv = (Invocable) engine;
|
|
||||||
scripts.put(c, iv);
|
|
||||||
c.setClickedNPC();
|
|
||||||
iv.invokeFunction("raiseOpen");
|
|
||||||
}
|
|
||||||
} catch (final UndeclaredThrowableException ute) {
|
|
||||||
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
|
||||||
dispose(c);
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
|
||||||
dispose(c);
|
dispose(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void raiseOpen(Client c, short questid, int npc) {
|
||||||
|
try {
|
||||||
|
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||||
|
if (qms.containsKey(c)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (c.canClickNPC()) {
|
||||||
|
qms.put(c, qm);
|
||||||
|
|
||||||
|
ScriptEngine engine = getQuestScriptEngine(c, questid);
|
||||||
|
if (engine == null) {
|
||||||
|
//FilePrinter.printError(FilePrinter.QUEST_UNCODED, "RAISE Quest " + questid + " is uncoded.");
|
||||||
|
qm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.put("qm", qm);
|
||||||
|
|
||||||
|
Invocable iv = (Invocable) engine;
|
||||||
|
scripts.put(c, iv);
|
||||||
|
c.setClickedNPC();
|
||||||
|
iv.invokeFunction("raiseOpen");
|
||||||
|
}
|
||||||
|
} catch (final UndeclaredThrowableException ute) {
|
||||||
|
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
||||||
|
dispose(c);
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
||||||
|
dispose(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void dispose(QuestActionManager qm, Client c) {
|
public void dispose(QuestActionManager qm, Client c) {
|
||||||
qms.remove(c);
|
qms.remove(c);
|
||||||
@@ -203,12 +202,12 @@ public class QuestScriptManager extends AbstractScriptManager {
|
|||||||
c.getPlayer().flushDelayedUpdateQuests();
|
c.getPlayer().flushDelayedUpdateQuests();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose(Client c) {
|
public void dispose(Client c) {
|
||||||
QuestActionManager qm = qms.get(c);
|
QuestActionManager qm = qms.get(c);
|
||||||
if (qm != null) {
|
if (qm != null) {
|
||||||
dispose(qm, c);
|
dispose(qm, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestActionManager getQM(Client c) {
|
public QuestActionManager getQM(Client c) {
|
||||||
return qms.get(c);
|
return qms.get(c);
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
private static void sortDropEntries(List<ReactorDropEntry> from, List<ReactorDropEntry> item, List<ReactorDropEntry> visibleQuest, List<ReactorDropEntry> otherQuest, Character chr) {
|
private static void sortDropEntries(List<ReactorDropEntry> from, List<ReactorDropEntry> item, List<ReactorDropEntry> visibleQuest, List<ReactorDropEntry> otherQuest, Character chr) {
|
||||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||||
|
|
||||||
for(ReactorDropEntry mde : from) {
|
for (ReactorDropEntry mde : from) {
|
||||||
if(!ii.isQuestItem(mde.itemId)) {
|
if (!ii.isQuestItem(mde.itemId)) {
|
||||||
item.add(mde);
|
item.add(mde);
|
||||||
} else {
|
} else {
|
||||||
if(chr.needQuestItem(mde.questid, mde.itemId)) {
|
if (chr.needQuestItem(mde.questid, mde.itemId)) {
|
||||||
visibleQuest.add(mde);
|
visibleQuest.add(mde);
|
||||||
} else {
|
} else {
|
||||||
otherQuest.add(mde);
|
otherQuest.add(mde);
|
||||||
@@ -128,7 +128,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sprayItems(boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
public void sprayItems(boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||||
sprayItems((int)reactor.getPosition().getX(), (int)reactor.getPosition().getY(), meso, mesoChance, minMeso, maxMeso, minItems);
|
sprayItems((int) reactor.getPosition().getX(), (int) reactor.getPosition().getY(), meso, mesoChance, minMeso, maxMeso, minItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sprayItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
public void sprayItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||||
@@ -144,7 +144,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dropItems(boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
public void dropItems(boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||||
dropItems((int)reactor.getPosition().getX(), (int)reactor.getPosition().getY(), meso, mesoChance, minMeso, maxMeso, minItems);
|
dropItems((int) reactor.getPosition().getX(), (int) reactor.getPosition().getY(), meso, mesoChance, minMeso, maxMeso, minItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
public void dropItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||||
@@ -153,13 +153,17 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
|
|
||||||
public void dropItems(boolean delayed, int posX, int posY, boolean meso, int mesoChance, final int minMeso, final int maxMeso, int minItems) {
|
public void dropItems(boolean delayed, int posX, int posY, boolean meso, int mesoChance, final int minMeso, final int maxMeso, int minItems) {
|
||||||
Character chr = c.getPlayer();
|
Character chr = c.getPlayer();
|
||||||
if(chr == null) return;
|
if (chr == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<ReactorDropEntry> items = assembleReactorDropEntries(chr, generateDropList(getDropChances(), chr.getDropRate(), meso, mesoChance, minItems));
|
List<ReactorDropEntry> items = assembleReactorDropEntries(chr, generateDropList(getDropChances(), chr.getDropRate(), meso, mesoChance, minItems));
|
||||||
if(items.size() % 2 == 0) posX -= 12;
|
if (items.size() % 2 == 0) {
|
||||||
|
posX -= 12;
|
||||||
|
}
|
||||||
final Point dropPos = new Point(posX, posY);
|
final Point dropPos = new Point(posX, posY);
|
||||||
|
|
||||||
if(!delayed) {
|
if (!delayed) {
|
||||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||||
|
|
||||||
byte p = 1;
|
byte p = 1;
|
||||||
@@ -192,7 +196,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
dropPos.x -= (12 * items.size());
|
dropPos.x -= (12 * items.size());
|
||||||
|
|
||||||
sprayTask = TimerManager.getInstance().register(() -> {
|
sprayTask = TimerManager.getInstance().register(() -> {
|
||||||
if(dropItems.isEmpty()) {
|
if (dropItems.isEmpty()) {
|
||||||
sprayTask.cancel(false);
|
sprayTask.cancel(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -231,7 +235,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
items.add(new ReactorDropEntry(0, mesoChance, -1));
|
items.add(new ReactorDropEntry(0, mesoChance, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ReactorDropEntry mde : drops) {
|
for (ReactorDropEntry mde : drops) {
|
||||||
if (Math.random() < (dropRate / (double) mde.chance)) {
|
if (Math.random() < (dropRate / (double) mde.chance)) {
|
||||||
items.add(mde);
|
items.add(mde);
|
||||||
}
|
}
|
||||||
@@ -282,17 +286,17 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
|
|
||||||
public void hitMonsterWithReactor(int id, int hitsToKill) { // until someone comes with a better solution, why not?
|
public void hitMonsterWithReactor(int id, int hitsToKill) { // until someone comes with a better solution, why not?
|
||||||
int customTime = YamlConfig.config.server.MOB_REACTOR_REFRESH_TIME;
|
int customTime = YamlConfig.config.server.MOB_REACTOR_REFRESH_TIME;
|
||||||
if(customTime > 0) {
|
if (customTime > 0) {
|
||||||
reactor.setDelay(customTime);
|
reactor.setDelay(customTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
MapleMap map = reactor.getMap();
|
MapleMap map = reactor.getMap();
|
||||||
Monster mm = map.getMonsterById(id);
|
Monster mm = map.getMonsterById(id);
|
||||||
if(mm != null) {
|
if (mm != null) {
|
||||||
int damage = (int)Math.ceil(mm.getMaxHp() / hitsToKill);
|
int damage = (int) Math.ceil(mm.getMaxHp() / hitsToKill);
|
||||||
Character chr = this.getPlayer();
|
Character chr = this.getPlayer();
|
||||||
|
|
||||||
if(chr != null) {
|
if (chr != null) {
|
||||||
map.damageMonster(chr, mm, damage);
|
map.damageMonster(chr, mm, damage);
|
||||||
map.broadcastMessage(PacketCreator.damageMonster(mm.getObjectId(), damage));
|
map.broadcastMessage(PacketCreator.damageMonster(mm.getObjectId(), damage));
|
||||||
}
|
}
|
||||||
@@ -327,7 +331,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
final MCSkill skil = CarnivalFactory.getInstance().getGuardian(num);
|
final MCSkill skil = CarnivalFactory.getInstance().getGuardian(num);
|
||||||
if (skil != null) {
|
if (skil != null) {
|
||||||
for (Monster mons : getMap().getAllMonsters()) {
|
for (Monster mons : getMap().getAllMonsters()) {
|
||||||
if(mons.getTeam() == team) {
|
if (mons.getTeam() == team) {
|
||||||
mons.dispelSkill(skil.getSkill());
|
mons.dispelSkill(skil.getSkill());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,9 +59,10 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iv.invokeFunction("hit");
|
iv.invokeFunction("hit");
|
||||||
} catch (final NoSuchMethodException e) {} //do nothing, hit is OPTIONAL
|
} catch (final NoSuchMethodException e) {
|
||||||
|
} //do nothing, hit is OPTIONAL
|
||||||
|
|
||||||
catch (final ScriptException | NullPointerException e) {
|
catch (final ScriptException | NullPointerException e) {
|
||||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user