Level/exp on all equips + Player stats overhaul + Chair handler patch
Implemented a massive overhaul on Character.wz, adding in equipment level-related nodes in order to make equipments level/EXP info available for anyone to check. Implemented a major overhaul on the player stat management throughout the source, properly encapsulating and concurrency protecting it's mechanics. Reviewed several MoveLifeHandler aspects, some of them trying to prevent mobs from falling from footholds in certain circumstances. Fixed MP Recovery instant killing players when they run out of HP to use. Fixed some chairs arbitrarily disconnecting players upon HP/MP recovery. Fixed Puppets sticking to maps in certain scenarios. Cached data and added concurrency protection for EXP gain on equipments. Reworked Chair Mastery skill, now with recovering amounts based on a player's base HP/MP pool. Fixed several deadlock issues revolving rate coupons and character inventory. Improved overall autopot handler performance. Reworked door bosses (such as Crocell), now spawning each 3 hours instead of upon player's demand. Fixed alliances not saving rank names on DB at creation time. Fixed alliances retaining disbanded guild info on DB. Added Mystic Door support for the Mushroom Castle area.
This commit is contained in:
@@ -67,6 +67,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.server.coordinator.MapleEventRecallCoordinator;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.event.worker.EventScriptScheduler;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.life.MapleLifeFactory;
|
||||
import server.life.MapleNPC;
|
||||
@@ -83,6 +84,7 @@ public class EventInstanceManager {
|
||||
private List<MapleMonster> mobs = new LinkedList<>();
|
||||
private Map<MapleCharacter, Integer> killCount = new HashMap<>();
|
||||
private EventManager em;
|
||||
private EventScriptScheduler ess;
|
||||
private MapleMapFactory mapFactory;
|
||||
private String name;
|
||||
private Properties props = new Properties();
|
||||
@@ -124,6 +126,7 @@ public class EventInstanceManager {
|
||||
public EventInstanceManager(EventManager em, String name) {
|
||||
this.em = em;
|
||||
this.name = name;
|
||||
this.ess = new EventScriptScheduler();
|
||||
mapFactory = new MapleMapFactory(this, MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz")), MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/String.wz")), (byte) 0, (byte) 1);//Fk this
|
||||
mapFactory.setChannel(em.getChannelServer().getId());
|
||||
}
|
||||
@@ -553,9 +556,7 @@ public class EventInstanceManager {
|
||||
} finally {
|
||||
sL.unlock();
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {} // optional
|
||||
}
|
||||
|
||||
public void reviveMonster(MapleMonster mob) {
|
||||
@@ -583,9 +584,8 @@ public class EventInstanceManager {
|
||||
if (b instanceof Boolean) {
|
||||
return (Boolean) b;
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {} // optional
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -674,12 +674,15 @@ public class EventInstanceManager {
|
||||
}
|
||||
|
||||
mapFactory.dispose();
|
||||
ess.dispose();
|
||||
|
||||
wL.lock();
|
||||
try {
|
||||
for(MapleCharacter chr: chars.values()) chr.setEventInstance(null);
|
||||
chars.clear();
|
||||
mobs.clear();
|
||||
mapFactory = null;
|
||||
ess = null;
|
||||
} finally {
|
||||
wL.unlock();
|
||||
}
|
||||
@@ -725,27 +728,31 @@ public class EventInstanceManager {
|
||||
}
|
||||
|
||||
public void schedule(final String methodName, long delay) {
|
||||
List<MapleCharacter> chrList = this.getPlayerList();
|
||||
int mapid = !chrList.isEmpty() ? chrList.get(0).getMapId() : 0;
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sL.lock();
|
||||
try {
|
||||
if(em == null) return;
|
||||
em.getIv().invokeFunction(methodName, EventInstanceManager.this);
|
||||
} finally {
|
||||
sL.unlock();
|
||||
rL.lock();
|
||||
try {
|
||||
if (ess != null) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sL.lock();
|
||||
try {
|
||||
if(em == null) return;
|
||||
em.getIv().invokeFunction(methodName, EventInstanceManager.this);
|
||||
} finally {
|
||||
sL.unlock();
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getEm().getChannelServer().registerEventAction(mapid, r, delay);
|
||||
};
|
||||
|
||||
ess.registerEntry(r, delay);
|
||||
}
|
||||
} finally {
|
||||
rL.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -101,6 +101,10 @@ public class EventManager {
|
||||
for(int i = 0; i < maxLobbys; i++) this.openedLobbys.add(false);
|
||||
}
|
||||
|
||||
private boolean isDisposed() {
|
||||
return onLoadInstances <= -1000;
|
||||
}
|
||||
|
||||
public void cancel() { // make sure to only call this when there are NO PLAYERS ONLINE to mess around with the event manager!
|
||||
ess.dispose();
|
||||
|
||||
@@ -342,6 +346,8 @@ public class EventManager {
|
||||
|
||||
//Expedition method: starts an expedition
|
||||
public boolean startInstance(int lobbyId, MapleExpedition exped, MapleCharacter leader) {
|
||||
if (this.isDisposed()) return false;
|
||||
|
||||
try {
|
||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||
playerPermit.add(leader.getId());
|
||||
@@ -399,6 +405,8 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public boolean startInstance(int lobbyId, MapleCharacter chr, MapleCharacter leader, int difficulty) {
|
||||
if (this.isDisposed()) return false;
|
||||
|
||||
try {
|
||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||
playerPermit.add(leader.getId());
|
||||
@@ -459,6 +467,8 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public boolean startInstance(int lobbyId, MapleParty party, MapleMap map, MapleCharacter leader) {
|
||||
if (this.isDisposed()) return false;
|
||||
|
||||
try {
|
||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||
playerPermit.add(leader.getId());
|
||||
@@ -516,6 +526,8 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public boolean startInstance(int lobbyId, MapleParty party, MapleMap map, int difficulty, MapleCharacter leader) {
|
||||
if (this.isDisposed()) return false;
|
||||
|
||||
try {
|
||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||
playerPermit.add(leader.getId());
|
||||
@@ -577,6 +589,8 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public boolean startInstance(int lobbyId, EventInstanceManager eim, String ldr, MapleCharacter leader) {
|
||||
if (this.isDisposed()) return false;
|
||||
|
||||
try {
|
||||
if(!playerPermit.contains(leader.getId()) && startSemaphore.tryAcquire(7777, TimeUnit.MILLISECONDS)) {
|
||||
playerPermit.add(leader.getId());
|
||||
@@ -811,7 +825,7 @@ public class EventManager {
|
||||
int nextEventId;
|
||||
queueLock.lock();
|
||||
try {
|
||||
if(onLoadInstances <= -1000 || readyInstances.size() + onLoadInstances >= Math.ceil((double)maxLobbys / 3.0)) return;
|
||||
if (this.isDisposed() || readyInstances.size() + onLoadInstances >= Math.ceil((double)maxLobbys / 3.0)) return;
|
||||
|
||||
onLoadInstances++;
|
||||
nextEventId = readyId;
|
||||
@@ -823,7 +837,7 @@ public class EventManager {
|
||||
EventInstanceManager eim = new EventInstanceManager(this, "sampleName" + nextEventId);
|
||||
queueLock.lock();
|
||||
try {
|
||||
if(onLoadInstances <= -1000) { // EM already disposed
|
||||
if (this.isDisposed()) { // EM already disposed
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft 2016 - 2018 RonanLana
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
|
||||
@@ -23,6 +23,7 @@ package scripting.event;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -37,6 +38,7 @@ import scripting.AbstractScriptManager;
|
||||
* @author Matze
|
||||
*/
|
||||
public class EventScriptManager extends AbstractScriptManager {
|
||||
|
||||
private class EventEntry {
|
||||
public EventEntry(Invocable iv, EventManager em) {
|
||||
this.iv = iv;
|
||||
@@ -77,8 +79,20 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void reload(){
|
||||
private void reloadScripts() {
|
||||
if (events.isEmpty()) return;
|
||||
|
||||
Channel cserv = events.values().iterator().next().em.getChannelServer();
|
||||
for (Entry<String, EventEntry> entry : events.entrySet()) {
|
||||
String script = entry.getKey();
|
||||
Invocable iv = getInvocable("event/" + script + ".js", null);
|
||||
events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script)));
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
cancel();
|
||||
reloadScripts();
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft 2016 - 2018 RonanLana
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
|
||||
@@ -288,6 +288,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
|
||||
public ScheduledFuture<?> schedule(final String methodName, final EventInstanceManager eim, long delay) {
|
||||
return TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
iv.invokeFunction(methodName, eim);
|
||||
@@ -300,6 +301,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
|
||||
public ScheduledFuture<?> scheduleAtTimestamp(final String methodName, long timestamp) {
|
||||
return TimerManager.getInstance().scheduleAtTimestamp(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
iv.invokeFunction(methodName, (Object) null);
|
||||
|
||||
@@ -58,10 +58,9 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
ReactorActionManager rm = new ReactorActionManager(c, reactor, iv);
|
||||
engine.put("rm", rm);
|
||||
iv.invokeFunction("hit");
|
||||
} catch(final NoSuchMethodException e) {
|
||||
//do nothing, hit is OPTIONAL
|
||||
}
|
||||
catch (final ScriptException | NullPointerException e) {
|
||||
} catch (final NoSuchMethodException e) {} //do nothing, hit is OPTIONAL
|
||||
|
||||
catch (final ScriptException | NullPointerException e) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user