Rename and clean up MapleClient
This commit is contained in:
@@ -57,13 +57,13 @@ import java.util.*;
|
||||
|
||||
public class AbstractPlayerInteraction {
|
||||
|
||||
public MapleClient c;
|
||||
public Client c;
|
||||
|
||||
public AbstractPlayerInteraction(MapleClient c) {
|
||||
public AbstractPlayerInteraction(Client c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public MapleClient getClient() {
|
||||
public Client getClient() {
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ public class AbstractPlayerInteraction {
|
||||
|
||||
public void givePartyItems(int id, short quantity, List<Character> party) {
|
||||
for (Character chr : party) {
|
||||
MapleClient cl = chr.getClient();
|
||||
Client cl = chr.getClient();
|
||||
if (quantity >= 0) {
|
||||
InventoryManipulator.addById(cl, id, quantity);
|
||||
} else {
|
||||
@@ -857,7 +857,7 @@ public class AbstractPlayerInteraction {
|
||||
removeAll(id, c);
|
||||
}
|
||||
|
||||
public void removeAll(int id, MapleClient cl) {
|
||||
public void removeAll(int id, Client cl) {
|
||||
InventoryType invType = ItemConstants.getInventoryType(id);
|
||||
int possessed = cl.getPlayer().getInventory(invType).countById(id);
|
||||
if (possessed > 0) {
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package scripting;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
|
||||
import constants.string.CharsetConstants;
|
||||
import tools.FilePrinter;
|
||||
@@ -66,7 +66,7 @@ public abstract class AbstractScriptManager {
|
||||
return graalScriptEngine;
|
||||
}
|
||||
|
||||
protected ScriptEngine getInvocableScriptEngine(String path, MapleClient c) {
|
||||
protected ScriptEngine getInvocableScriptEngine(String path, Client c) {
|
||||
ScriptEngine engine = c.getScriptEngine("scripts/" + path);
|
||||
if (engine == null) {
|
||||
engine = getInvocableScriptEngine(path);
|
||||
@@ -85,7 +85,7 @@ public abstract class AbstractScriptManager {
|
||||
bindings.put("polyglot.js.allowHostClassLookup", true);
|
||||
}
|
||||
|
||||
protected void resetContext(String path, MapleClient c) {
|
||||
protected void resetContext(String path, Client c) {
|
||||
c.removeScriptEngine("scripts/" + path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package scripting.item;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import server.MapleItemInformationProvider.ScriptedItem;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ItemScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void runItemScript(MapleClient c, ScriptedItem scriptItem) {
|
||||
public void runItemScript(Client c, ScriptedItem scriptItem) {
|
||||
NPCScriptManager.getInstance().start(c, scriptItem, null);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package scripting.item;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ import scripting.AbstractPlayerInteraction;
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class ItemScriptMethods extends AbstractPlayerInteraction {
|
||||
public ItemScriptMethods(MapleClient c) {
|
||||
public ItemScriptMethods(Client c) {
|
||||
super(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.map;
|
||||
|
||||
import client.Character;
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.AbstractScriptManager;
|
||||
import tools.FilePrinter;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MapScriptManager extends AbstractScriptManager {
|
||||
scripts.clear();
|
||||
}
|
||||
|
||||
public boolean runMapScript(MapleClient c, String mapScriptPath, boolean firstUser) {
|
||||
public boolean runMapScript(Client c, String mapScriptPath, boolean firstUser) {
|
||||
if (firstUser) {
|
||||
Character chr = c.getPlayer();
|
||||
int mapid = chr.getMapId();
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.map;
|
||||
|
||||
import client.Character.DelayedQuestUpdate;
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import client.MapleQuestStatus;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -32,7 +32,7 @@ public class MapScriptMethods extends AbstractPlayerInteraction {
|
||||
|
||||
private String rewardstring = " title has been rewarded. Please see NPC Dalair to receive your Medal.";
|
||||
|
||||
public MapScriptMethods(MapleClient c) {
|
||||
public MapScriptMethods(Client c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,18 +94,18 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
return talk;
|
||||
}
|
||||
|
||||
public NPCConversationManager(MapleClient c, int npc, String scriptName) {
|
||||
public NPCConversationManager(Client c, int npc, String scriptName) {
|
||||
this(c, npc, -1, scriptName, false);
|
||||
}
|
||||
|
||||
public NPCConversationManager(MapleClient c, int npc, List<MaplePartyCharacter> otherParty, boolean test) {
|
||||
public NPCConversationManager(Client c, int npc, List<MaplePartyCharacter> otherParty, boolean test) {
|
||||
super(c);
|
||||
this.c = c;
|
||||
this.npc = npc;
|
||||
this.otherParty = otherParty;
|
||||
}
|
||||
|
||||
public NPCConversationManager(MapleClient c, int npc, int oid, String scriptName, boolean itemScript) {
|
||||
public NPCConversationManager(Client c, int npc, int oid, String scriptName, boolean itemScript) {
|
||||
super(c);
|
||||
this.npc = npc;
|
||||
this.npcOid = oid;
|
||||
@@ -426,7 +426,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
c.sendPacket(GuildPackets.updateAllianceInfo(alliance, c.getWorld())); // thanks Vcoc for finding an alliance update to leader issue
|
||||
}
|
||||
|
||||
public void disbandAlliance(MapleClient c, int allianceId) {
|
||||
public void disbandAlliance(Client c, int allianceId) {
|
||||
MapleAlliance.disbandAlliance(allianceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
package scripting.npc;
|
||||
|
||||
import client.Character;
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.MapleItemInformationProvider.ScriptedItem;
|
||||
@@ -43,14 +43,14 @@ import java.util.Map;
|
||||
public class NPCScriptManager extends AbstractScriptManager {
|
||||
private static final NPCScriptManager instance = new NPCScriptManager();
|
||||
|
||||
private final Map<MapleClient, NPCConversationManager> cms = new HashMap<>();
|
||||
private final Map<MapleClient, Invocable> scripts = new HashMap<>();
|
||||
private final Map<Client, NPCConversationManager> cms = new HashMap<>();
|
||||
private final Map<Client, Invocable> scripts = new HashMap<>();
|
||||
|
||||
public static NPCScriptManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isNpcScriptAvailable(MapleClient c, String fileName) {
|
||||
public boolean isNpcScriptAvailable(Client c, String fileName) {
|
||||
ScriptEngine engine = null;
|
||||
if (fileName != null) {
|
||||
engine = getInvocableScriptEngine("npc/" + fileName + ".js", c);
|
||||
@@ -59,27 +59,27 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
return engine != null;
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, int npc, Character chr) {
|
||||
public boolean start(Client c, int npc, Character chr) {
|
||||
return start(c, npc, -1, chr);
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, int npc, int oid, Character chr) {
|
||||
public boolean start(Client c, int npc, int oid, Character chr) {
|
||||
return start(c, npc, oid, null, chr);
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, int npc, String fileName, Character chr) {
|
||||
public boolean start(Client c, int npc, String fileName, Character chr) {
|
||||
return start(c, npc, -1, fileName, chr);
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, int npc, int oid, String fileName, Character chr) {
|
||||
public boolean start(Client c, int npc, int oid, String fileName, Character chr) {
|
||||
return start(c, npc, oid, fileName, chr, false, "cm");
|
||||
}
|
||||
|
||||
public boolean start(MapleClient c, ScriptedItem scriptItem, Character chr) {
|
||||
public boolean start(Client c, ScriptedItem scriptItem, Character chr) {
|
||||
return start(c, scriptItem.getNpc(), -1, scriptItem.getScript(), chr, true, "im");
|
||||
}
|
||||
|
||||
public void start(String filename, MapleClient c, int npc, List<MaplePartyCharacter> chrs) {
|
||||
public void start(String filename, Client c, int npc, List<MaplePartyCharacter> chrs) {
|
||||
try {
|
||||
final NPCConversationManager cm = new NPCConversationManager(c, npc, chrs, true);
|
||||
cm.dispose();
|
||||
@@ -110,7 +110,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean start(MapleClient c, int npc, int oid, String fileName, Character chr, boolean itemScript, String engineName) {
|
||||
private boolean start(Client c, int npc, int oid, String fileName, Character chr, boolean itemScript, String engineName) {
|
||||
try {
|
||||
final NPCConversationManager cm = new NPCConversationManager(c, npc, oid, fileName, itemScript);
|
||||
if (cms.containsKey(c)) {
|
||||
@@ -162,7 +162,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void action(MapleClient c, byte mode, byte type, int selection) {
|
||||
public void action(Client c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
@@ -178,7 +178,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
public void dispose(NPCConversationManager cm) {
|
||||
MapleClient c = cm.getClient();
|
||||
Client c = cm.getClient();
|
||||
c.getPlayer().setCS(false);
|
||||
c.getPlayer().setNpcCooldown(System.currentTimeMillis());
|
||||
cms.remove(c);
|
||||
@@ -194,14 +194,14 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
c.getPlayer().flushDelayedUpdateQuests();
|
||||
}
|
||||
|
||||
public void dispose(MapleClient c) {
|
||||
public void dispose(Client c) {
|
||||
NPCConversationManager cm = cms.get(c);
|
||||
if (cm != null) {
|
||||
dispose(cm);
|
||||
}
|
||||
}
|
||||
|
||||
public NPCConversationManager getCM(MapleClient c) {
|
||||
public NPCConversationManager getCM(Client c) {
|
||||
return cms.get(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package scripting.portal;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.map.MapScriptManager;
|
||||
import server.maps.MaplePortal;
|
||||
@@ -36,7 +36,7 @@ import java.sql.SQLException;
|
||||
public class PortalPlayerInteraction extends AbstractPlayerInteraction {
|
||||
private final MaplePortal portal;
|
||||
|
||||
public PortalPlayerInteraction(MapleClient c, MaplePortal portal) {
|
||||
public PortalPlayerInteraction(Client c, MaplePortal portal) {
|
||||
super(c);
|
||||
this.portal = portal;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package scripting.portal;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.AbstractScriptManager;
|
||||
@@ -64,7 +64,7 @@ public class PortalScriptManager extends AbstractScriptManager {
|
||||
return script;
|
||||
}
|
||||
|
||||
public boolean executePortalScript(MaplePortal portal, MapleClient c) {
|
||||
public boolean executePortalScript(MaplePortal portal, Client c) {
|
||||
try {
|
||||
PortalScript script = getPortalScript(portal.getScriptName());
|
||||
if (script != null) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package scripting.quest;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.npc.NPCConversationManager;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -36,7 +36,7 @@ public class QuestActionManager extends NPCConversationManager {
|
||||
private boolean start; // this is if the script in question is start or end
|
||||
private int quest;
|
||||
|
||||
public QuestActionManager(MapleClient c, int quest, int npc, boolean start) {
|
||||
public QuestActionManager(Client c, int quest, int npc, boolean start) {
|
||||
super(c, npc, null);
|
||||
this.quest = quest;
|
||||
this.start = start;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package scripting.quest;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import client.MapleQuestStatus;
|
||||
import constants.game.GameConstants;
|
||||
import scripting.AbstractScriptManager;
|
||||
@@ -41,14 +41,14 @@ import java.util.Map;
|
||||
public class QuestScriptManager extends AbstractScriptManager {
|
||||
private static final QuestScriptManager instance = new QuestScriptManager();
|
||||
|
||||
private final Map<MapleClient, QuestActionManager> qms = new HashMap<>();
|
||||
private final Map<MapleClient, Invocable> scripts = new HashMap<>();
|
||||
private final Map<Client, QuestActionManager> qms = new HashMap<>();
|
||||
private final Map<Client, Invocable> scripts = new HashMap<>();
|
||||
|
||||
public static QuestScriptManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ScriptEngine getQuestScriptEngine(MapleClient c, short questid) {
|
||||
private ScriptEngine getQuestScriptEngine(Client c, short questid) {
|
||||
ScriptEngine engine = getInvocableScriptEngine("quest/" + questid + ".js", c);
|
||||
if (engine == null && GameConstants.isMedalQuest(questid)) {
|
||||
engine = getInvocableScriptEngine("quest/medalQuest.js", c); // start generic medal quest
|
||||
@@ -57,7 +57,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
return engine;
|
||||
}
|
||||
|
||||
public void start(MapleClient c, short questid, int npc) {
|
||||
public void start(Client c, short questid, int npc) {
|
||||
MapleQuest quest = MapleQuest.getInstance(questid);
|
||||
try {
|
||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||
@@ -95,7 +95,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void start(MapleClient c, byte mode, byte type, int selection) {
|
||||
public void start(Client c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
@@ -108,7 +108,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void end(MapleClient c, short questid, int npc) {
|
||||
public void end(Client c, short questid, int npc) {
|
||||
MapleQuest quest = MapleQuest.getInstance(questid);
|
||||
if (!c.getPlayer().getQuest(quest).getStatus().equals(MapleQuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) {
|
||||
dispose(c);
|
||||
@@ -150,7 +150,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void end(MapleClient c, byte mode, byte type, int selection) {
|
||||
public void end(Client c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
@@ -163,7 +163,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void raiseOpen(MapleClient c, short questid, int npc) {
|
||||
public void raiseOpen(Client c, short questid, int npc) {
|
||||
try {
|
||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||
if (qms.containsKey(c)) {
|
||||
@@ -195,7 +195,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose(QuestActionManager qm, MapleClient c) {
|
||||
public void dispose(QuestActionManager qm, Client c) {
|
||||
qms.remove(c);
|
||||
scripts.remove(c);
|
||||
c.getPlayer().setNpcCooldown(System.currentTimeMillis());
|
||||
@@ -203,14 +203,14 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
c.getPlayer().flushDelayedUpdateQuests();
|
||||
}
|
||||
|
||||
public void dispose(MapleClient c) {
|
||||
public void dispose(Client c) {
|
||||
QuestActionManager qm = qms.get(c);
|
||||
if (qm != null) {
|
||||
dispose(qm, c);
|
||||
}
|
||||
}
|
||||
|
||||
public QuestActionManager getQM(MapleClient c) {
|
||||
public QuestActionManager getQM(Client c) {
|
||||
return qms.get(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
package scripting.reactor;
|
||||
|
||||
import client.Character;
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import client.inventory.Equip;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
@@ -57,7 +57,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
private final Invocable iv;
|
||||
private ScheduledFuture<?> sprayTask = null;
|
||||
|
||||
public ReactorActionManager(MapleClient c, MapleReactor reactor, Invocable iv) {
|
||||
public ReactorActionManager(Client c, MapleReactor reactor, Invocable iv) {
|
||||
super(c);
|
||||
this.reactor = reactor;
|
||||
this.iv = iv;
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package scripting.reactor;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.Client;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.ReactorDropEntry;
|
||||
@@ -51,7 +51,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void onHit(MapleClient c, MapleReactor reactor) {
|
||||
public void onHit(Client c, MapleReactor reactor) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -66,7 +66,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void act(MapleClient c, MapleReactor reactor) {
|
||||
public void act(Client c, MapleReactor reactor) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -104,15 +104,15 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
drops.clear();
|
||||
}
|
||||
|
||||
public void touch(MapleClient c, MapleReactor reactor) {
|
||||
public void touch(Client c, MapleReactor reactor) {
|
||||
touching(c, reactor, true);
|
||||
}
|
||||
|
||||
public void untouch(MapleClient c, MapleReactor reactor) {
|
||||
public void untouch(Client c, MapleReactor reactor) {
|
||||
touching(c, reactor, false);
|
||||
}
|
||||
|
||||
private void touching(MapleClient c, MapleReactor reactor, boolean touching) {
|
||||
private void touching(Client c, MapleReactor reactor, boolean touching) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -129,7 +129,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Invocable initializeInvocable(MapleClient c, MapleReactor reactor) {
|
||||
private Invocable initializeInvocable(Client c, MapleReactor reactor) {
|
||||
ScriptEngine engine = getInvocableScriptEngine("reactor/" + reactor.getId() + ".js", c);
|
||||
if (engine == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user