diff --git a/.dockerignore b/.dockerignore index 3fbb8c079e..389407f6ea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,13 @@ -/docs -/handbook -/tools \ No newline at end of file +# Project administration files +.idea +.git +.github + +# Not used by the build. +docs +handbook +sql +tools + +# Created by the db when using docker-compose, large and causes rebuild issues if sent to the context. +docker-db-data diff --git a/.gitignore b/.gitignore index d13e4644ed..99c411b1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .idea/ *.iml /target -/docker-db-data # build files diff --git a/Dockerfile b/Dockerfile index b24fea224d..c286375f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,42 @@ # Initial Docker support thanks to xinyifly +# Optimisation performed by wejrox # -# Build stage +# Cosmic JAR creation stage # -FROM maven:3.6.3-jdk-8 AS build -COPY src /home/app/src -COPY pom.xml /home/app -RUN mvn -f /home/app/pom.xml clean package +FROM maven:3.8.1-openjdk-16 AS jar + +# Build in a separated location which won't have permissions issues. +WORKDIR /opt/cosmic +# Any changes to the pom will affect the entire build, so it should be copied first. +COPY pom.xml ./pom.xml +# Grab all the dependencies listed in the pom early, since it prevents changes to source code from requiring a complete re-download. +# Skip compiling tests since we don't want all the dependecies to be downloaded. +RUN mvn -f ./pom.xml clean dependency:go-offline -Dmaven.test.skip -T 1C +# Source code changes may not change dependencies, so it can go last. +# Skip compiling tests since we don't want all the dependecies to be downloaded for plugins. +COPY src ./src +RUN mvn -f ./pom.xml clean package -Dmaven.test.skip -T 1C # -# Package stage +# Server creation stage # -FROM openjdk:8 -COPY --from=build /home/app/target/Cosmic.jar /usr/local/lib/Cosmic.jar -COPY ./ ./ +FROM openjdk:16 + +# Host the server in a location that won't have permissions issues. +WORKDIR /opt/server +# Copy the wizet files first since they're so big and won't change often. +COPY wz ./wz +# Copy the JAR we build earlier. +COPY --from=jar /opt/cosmic/target/Cosmic.jar ./Server.jar +# Scripts are sourced on server startup, so you can mount over them for quicker redeploy. +COPY scripts ./scripts/ +# Config is read on server startup, so you can mount over it for quicker redeploy. +COPY config.yaml ./ +# Default exposure, although not required if using docker compose. +# This exposes the login server, and channels. +# Format for channels: WWCC, where WW is 75 plus the world number and CC is 75 plus the channel number (both zero indexed). EXPOSE 8484 7575 7576 7577 -ENTRYPOINT ["java", "-jar", "/usr/local/lib/Cosmic.jar"] +ENTRYPOINT ["java", "-jar", "./Server.jar"] diff --git a/README.md b/README.md index 8b6a54a099..bfd2b8a7c1 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Discord: https://discord.gg/JU5aQapVZK --- ## Tools -* **Java 8 SDK** - * Link: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html +* **Java 16 SDK** - Needed to compile and run Java code. Install manually or through IntelliJ depending on how you prefer to launch the server. Not required for launching with Docker. + * Link: https://jdk.java.net/16/ * **IntelliJ IDEA** - Java IDE and your main tool for working with the source code. Community edition is good enough. @@ -136,7 +136,7 @@ If you are using Docker (quick start): #### Configuring the project -The easiest way to set up your project is to load the repository directly into a new IntelliJ project. +The easiest way to set up your project is to clone the repository directly into a new IntelliJ project. 1. Install IntelliJ 2. Create a new "Project from Version Control..." @@ -147,19 +147,20 @@ The easiest way to set up your project is to load the repository directly into a 1. Install MySQL Server 8 and MySQL Workbench 8. 2. Using Workbench, create a new user with username "cosmic_server" and password "snailshell". - These are the defaults used in Cosmic. + This the default configuration in Cosmic. * (Optional) Restrict the Schema Privileges for this new user for improved security. Add a new entry with "Schemas matching pattern: cosmic" and only select "SELECT", "INSERT", "UPDATE", "DELETE" under "Object Rights" -3. Run the sql scripts in the "sql" directory of the project in the order indicated by their names. - * Make sure you are connected to the database with the "root" user. - * Run scripts through the menu: "File" -> "Run SQL Script" -> select the script file to run -> "Run" +3. Run the sql scripts in the "database/sql" directory of the project in the order indicated by their names. + * Make sure you are connected to the database with the "root" user to be able to run the scripts. + * Run scripts one by one through the menu: "File" -> "Run SQL Script" -> select the script file to run -> "Run" * The 3rd script "3-db_shopupdate" is optional. It adds custom shop items for certain NPCs. + * The 4th script "4-db_admin" is also optional, but recommended if you are new. It adds an admin account to simplify the setup. Use this info when you connect to MySQL Server for the first time: * Server Host: localhost * Port: 3306 * Username: root -* Password: whatever you entered in during the installation of MySQL Server +* Password: At the end of the execution of these sql scripts, you should have installed a database schema named "cosmic". REGISTER YOUR FIRST ACCOUNT to be used in-game by **manually creating** an entry in the table "accounts" in the database with a username and password. @@ -173,7 +174,7 @@ Alternatively, you can use the IP given by Hamachi to use on a Hamachi network, To launch the server, you may either: * Launch inside IntelliJ -* Launch a jar file +* Launch a built jar file * Launch with Docker #### Launch inside IntelliJ @@ -185,17 +186,25 @@ To launch the server, you may either: #### Launch a jar file 1. Create the jar file * The jar file is created by the Maven assembly plugin in the package lifecycle. - * If you have Maven installed on your computer, simply run the command "mvn clean install" to create the jar file. - * IntelliJ also comes with built in Maven support. Open a new terminal window inside IntelliJ, type "mvn clean install" (your command should be marked green), then Ctrl+Enter to create the jar file. + * If you already have Maven installed, simply run the command "mvn clean install" to create the jar file. + * IntelliJ also comes with built-in Maven support. Open a new terminal window inside IntelliJ, type "mvn clean install" (your command should now be marked green), then Ctrl+Enter to build the jar file. 2. Launch the jar file * Double click on "launch.bat" #### Launch with Docker -Run the command "docker compose up" at the root of the project. +1. Start Docker +2. Run the command "docker compose up" at the root of the project. + * If you make any changes to the code, make sure you append the "--build" option at the end of the command to force rebuild the server image. --- ### Creating an account and logging into the game +If you ran the admin sql script, there already exists an account in your database with an admin character on it. You don't need to change its GM level. Log in using these credentials: +* Username: "admin" +* Password: "admin" +* Pin: "0000" +* Pic: "000000" + By default, the server source is set to allow AUTO-REGISTERING. This means that, by simply typing in a "Login ID" and a "Password", you're able to create a new account. After creating a character, experiment typing in all-chat "@commands". @@ -260,10 +269,6 @@ Besides myself for maintaining this repository, credits are to be given to Wizet Regarding distributability and usage of the code presented here: like it was before, this MapleStory server is open-source. By that, it is meant that anyone is **free to install, use, modify and redistribute the contents**, as long as there is **no kind of commercial trading involved** and the **credits to the original creators are maintained** within the codes. -This server source should be built and run on Java 8 in order to run properly -- used to be ran in Java 7, thanks kolakcc (Familiar) for the Java 8 support! - -Consider using an IDE for setting up the server source into a project. Once mounted the project, build it on your machine and run the server using the "launch.bat" application. - In this project, many gameplay-wise issues generated from either the original WZ files and the server source have been partially or completely solved. Considering the use of the provided edited WZ's and server-side wz.xml files should be of the greatest importance when dealing with this instance of server source, in order to perceive it at it's full potential. My opinion, though! - In other case, as fallback from the provided ones, consider using **whole clean set**. Selecting part of the provided ones to play pretty much *may eventually* lead to unexpected issues. @@ -289,17 +294,6 @@ By taking the v83 MapleStory as the angular stone, incrementally look forward to --- -#### Preparing the ambient - -For Hamachi: - -* Try opening it. It's that simple. - -Hamachi is optional, though. You don't have to install Hamachi if you want to make the server just for use on your own machine. -However, if you want to let other players access your server, consider alternatively using port-forwarding methods. - ---- - #### The MobBookUpdate example As an example of client WZ editing, consider the MapleMobBookUpdate tool project I developed, it updates all reported drop data on the Monster Book with what is currently being hold on the database: @@ -350,12 +344,8 @@ Our Discord channel is still available on: https://discord.gg/Q7wKxHX -[//]: <> (If you REALLY liked what you have seen on this project, please feel free to donate a little something as a helping hand for my contributions towards Maple development. Also remember to **support Nexon**!) - ### Disclaimer -[//]: <> (* HeavenMS development is decisively __ONLY accepting donations__ from the Paypal link aforementioned, in the __ronancpl/HeavenMS__ repository readme \(no patreons or other revenue resources\).) - * HeavenMS staff has __no current intention__ to publicly open a server with this source, if that ever comes to happen this note will be lifted. __Don't be scammed!__ * This server source is __NOT intended to be stable__ as is. Proper deadlock review and other maintenance contributions are needed in order to make it steps ahead on viability. diff --git a/config.yaml b/config.yaml index 54d43f32bf..18eaa55d96 100644 --- a/config.yaml +++ b/config.yaml @@ -166,7 +166,7 @@ server: DB_HOST: "localhost" DB_USER: "cosmic_server" DB_PASS: "snailshell" - INIT_CONNECTION_POOL_TIMEOUT: 60 # Seconds + INIT_CONNECTION_POOL_TIMEOUT: 90 # Seconds #Login Configuration WORLDS: 1 #Initial number of worlds on the server. diff --git a/database/docker-db-data/.gitignore b/database/docker-db-data/.gitignore new file mode 100644 index 0000000000..e7a210ec7d --- /dev/null +++ b/database/docker-db-data/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore \ No newline at end of file diff --git a/sql/1-db_database.sql b/database/sql/1-db_database.sql similarity index 100% rename from sql/1-db_database.sql rename to database/sql/1-db_database.sql diff --git a/sql/2-db_drops.sql b/database/sql/2-db_drops.sql similarity index 99% rename from sql/2-db_drops.sql rename to database/sql/2-db_drops.sql index 98e29c3f9f..38cfc9351b 100644 --- a/sql/2-db_drops.sql +++ b/database/sql/2-db_drops.sql @@ -20299,8 +20299,6 @@ USE `cosmic`; (5130106, 2022001, 1, 1, 0, 20000), (6130102, 2022001, 1, 1, 0, 20000), (6130103, 2022001, 1, 1, 0, 20000), -(6130200, 2022001, 1, 1, 0, 20000), -(6130201, 2022001, 1, 1, 0, 20000), (2220000, 1322001, 1, 1, 0, 8000), (9400551, 4031447, 1, 1, 0, 999999); diff --git a/sql/3-db_shopupdate.sql b/database/sql/3-db_shopupdate.sql similarity index 100% rename from sql/3-db_shopupdate.sql rename to database/sql/3-db_shopupdate.sql diff --git a/database/sql/4-db-admin.sql b/database/sql/4-db-admin.sql new file mode 100644 index 0000000000..cd18ff31c1 --- /dev/null +++ b/database/sql/4-db-admin.sql @@ -0,0 +1,87 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: cosmic +-- ------------------------------------------------------ +-- Server version 8.0.19 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +USE `cosmic`; + +-- +-- Dumping data for table `accounts` +-- + +LOCK TABLES `accounts` WRITE; +/*!40000 ALTER TABLE `accounts` DISABLE KEYS */; +INSERT INTO `accounts` VALUES (1,'admin','$2y$12$aFD9BDeUocDMY1X4tDYDyeJw/HhkQwCQWs3KAY7gCaRG0cpqJcaL.','0000','000000',0,'2021-05-24 00:00:01','2021-05-24 00:00:02','2005-05-11',0,NULL,NULL,1000000,1000000,1000000,3,0,'2005-05-11 03:00:00',0,1,NULL,0,NULL,0,NULL,NULL,0,0,'1234-5678',2); +/*!40000 ALTER TABLE `accounts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `characters` +-- + +LOCK TABLES `characters` WRITE; +/*!40000 ALTER TABLE `characters` DISABLE KEYS */; +INSERT INTO `characters` VALUES (1,1,0,'Admin',1,0,0,12,5,4,4,50,5,50,5,0,0,0,0,0,0,0,30030,20000,0,'0,0,0,0,0,0,0,0,0,0',10000,2,6,-1,25,'2021-05-24 00:00:03',1,0,1,0,0,5,0,4,1,0,0,0,0,0,0,0,0,0,0,24,24,24,24,-1,0,5,0,0,0,0,0,0,0,0,0,0,0,'','2021-05-24 00:00:04','2015-01-01 05:00:00',1,0); +/*!40000 ALTER TABLE `characters` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `inventoryequipment` +-- + +LOCK TABLES `inventoryequipment` WRITE; +/*!40000 ALTER TABLE `inventoryequipment` DISABLE KEYS */; +INSERT INTO `inventoryequipment` VALUES (17,22,7,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,1,0,-1),(18,23,7,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,-1),(19,24,5,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,-1),(20,25,7,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,1,0,-1); +/*!40000 ALTER TABLE `inventoryequipment` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `inventoryitems` +-- + +LOCK TABLES `inventoryitems` WRITE; +/*!40000 ALTER TABLE `inventoryitems` DISABLE KEYS */; +INSERT INTO `inventoryitems` VALUES (21,1,1,NULL,4161001,4,1,1,'',-1,0,-1,''),(22,1,1,NULL,1040002,-1,-5,1,'',-1,0,-1,''),(23,1,1,NULL,1060002,-1,-6,1,'',-1,0,-1,''),(24,1,1,NULL,1072001,-1,-7,1,'',-1,0,-1,''),(25,1,1,NULL,1302000,-1,-11,1,'',-1,0,-1,''); +/*!40000 ALTER TABLE `inventoryitems` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `keymap` +-- + +LOCK TABLES `keymap` WRITE; +/*!40000 ALTER TABLE `keymap` DISABLE KEYS */; +INSERT INTO `keymap` VALUES (161,1,18,4,0),(162,1,65,6,106),(163,1,2,4,10),(164,1,23,4,1),(165,1,3,4,12),(166,1,4,4,13),(167,1,5,4,18),(168,1,6,4,24),(169,1,16,4,8),(170,1,17,4,5),(171,1,19,4,4),(172,1,25,4,19),(173,1,26,4,14),(174,1,27,4,15),(175,1,31,4,2),(176,1,34,4,17),(177,1,35,4,11),(178,1,37,4,3),(179,1,38,4,20),(180,1,40,4,16),(181,1,43,4,9),(182,1,44,5,50),(183,1,45,5,51),(184,1,46,4,6),(185,1,50,4,7),(186,1,56,5,53),(187,1,59,6,100),(188,1,60,6,101),(189,1,61,6,102),(190,1,62,6,103),(191,1,63,6,104),(192,1,64,6,105),(193,1,57,5,54),(194,1,48,4,22),(195,1,29,5,52),(196,1,7,4,21),(197,1,24,4,25),(198,1,33,4,26),(199,1,41,4,23),(200,1,39,4,27); +/*!40000 ALTER TABLE `keymap` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `storages` +-- + +LOCK TABLES `storages` WRITE; +/*!40000 ALTER TABLE `storages` DISABLE KEYS */; +INSERT INTO `storages` VALUES (1,1,0,4,0); +/*!40000 ALTER TABLE `storages` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; diff --git a/sql/errors.txt b/database/sql/errors.txt similarity index 100% rename from sql/errors.txt rename to database/sql/errors.txt diff --git a/database/sql/readme.txt b/database/sql/readme.txt new file mode 100644 index 0000000000..3f452914be --- /dev/null +++ b/database/sql/readme.txt @@ -0,0 +1,7 @@ +---- Cosmic MySQL Database ---- + +These SQL files must be executed IN ORDER to set up the database: + - 1-db_database.sql (Tables and some data) + - 2-db_drops.sql (Remaining data: monster drops, reactor drops) + - 3-db_shopupdate.sql (Custom shops - optional, requires provided WZs) + - 4-db_admin (Basic admin account - optional) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index fc7334dedd..e6861b0004 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,18 @@ services: depends_on: - db ports: + # Login server - "8484:8484" + # Channels. + # Format: WWCC, where WW is 75 plus the world number and CC is 75 plus the channel number (both zero indexed). + # In this case, world 1 channels 1-3. - "7575-7577:7575-7577" + volumes: + # Config changes can be reloaded without rebuilding the image. + # Still requires a redeployment as they're sourced on startup. + - ./config.yaml:/opt/server/config.yaml + - ./scripts:/opt/server/scripts + - ./wz:/opt/server/wz environment: DB_HOST: "db" @@ -18,5 +28,5 @@ services: MYSQL_USER: "cosmic_server" MYSQL_PASSWORD: "snailshell" volumes: - - ./docker-db-data:/var/lib/mysql - - ./sql:/docker-entrypoint-initdb.d + - ./database/docker-db-data:/var/lib/mysql + - ./database/sql:/docker-entrypoint-initdb.d diff --git a/pom.xml b/pom.xml index 629bf42035..7df287a87f 100644 --- a/pom.xml +++ b/pom.xml @@ -12,23 +12,25 @@ UTF-8 - 1.8 - 1.8 + 16 + ${java.version} + ${java.version} net.server.Server 2.14.1 + 21.1.0 com.zaxxer - HikariCP-java7 - 2.4.13 + HikariCP + 4.0.3 org.apache.mina mina-core - 2.0.19 + 2.1.3 mysql @@ -38,7 +40,12 @@ com.esotericsoftware.yamlbeans yamlbeans - 1.13 + 1.15 + + + net.jcip + jcip-annotations + 1.0 @@ -62,6 +69,18 @@ log4j-slf4j-impl ${log4j.version} + + + + org.graalvm.js + js + ${graalvm.version} + + + org.graalvm.js + js-scriptengine + ${graalvm.version} + diff --git a/scripts/event/0_EXAMPLE.js b/scripts/event/0_EXAMPLE.js index 3fe5535d65..b08814c392 100644 --- a/scripts/event/0_EXAMPLE.js +++ b/scripts/event/0_EXAMPLE.js @@ -12,14 +12,14 @@ var maxMapId; var eventTime; // Max time allotted for the event, in minutes. -var lobbyRange = [0, 0]; // Range of concurrent lobbies (min range is 0, max range is 7). +const maxLobbies = 7; // Max amount of concurrent active lobbies. function init() { // After loading, ChannelServer } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { diff --git a/scripts/event/2xEvent.js b/scripts/event/2xEvent.js index c24c548cab..c693514f47 100644 --- a/scripts/event/2xEvent.js +++ b/scripts/event/2xEvent.js @@ -31,8 +31,6 @@ var timer2; var timer3; var timer4; -importPackage(Packages.client); - function init() { /* if(em.getChannelServer().getId() == 1) { // Only run on channel 1. @@ -58,15 +56,19 @@ function cancelSchedule() { } function start() { - var world = Packages.net.server.Server.getInstance().getWorld(em.getChannelServer().getWorld()); - world.setExpRate(8); - world.broadcastPacket(Packages.tools.MaplePacketCreator.serverNotice(6, "The Bunny Onslaught Survival Scanner (BOSS) has detected an Easter Bunny onslaught soon! The GM team has activated the Emergency XP Pool (EXP) that doubles experience gained for the next two hours!")); + const Server = Java.type('net.server.Server'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + var world = Server.getInstance().getWorld(em.getChannelServer().getWorld()); + world.setExpRate(8); + world.broadcastPacket(MaplePacketCreator.serverNotice(6, "The Bunny Onslaught Survival Scanner (BOSS) has detected an Easter Bunny onslaught soon! The GM team has activated the Emergency XP Pool (EXP) that doubles experience gained for the next two hours!")); } function stop() { - var world = Packages.net.server.Server.getInstance().getWorld(em.getChannelServer().getWorld()); - world.setExpRate(4); - world.broadcastPacket(Packages.tools.MaplePacketCreator.serverNotice(6, "Unfortunately the Emergency XP Pool (EXP) has run out of juice for now and needs to recharge causing the EXP rate to go back to normal.")); + const Server = Java.type('net.server.Server'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + var world = Server.getInstance().getWorld(em.getChannelServer().getWorld()); + world.setExpRate(4); + world.broadcastPacket(MaplePacketCreator.serverNotice(6, "Unfortunately the Emergency XP Pool (EXP) has run out of juice for now and needs to recharge causing the EXP rate to go back to normal.")); } // ---------- FILLER FUNCTIONS ---------- diff --git a/scripts/event/3rdJob_bowman.js b/scripts/event/3rdJob_bowman.js index 4388b7a27a..0f21752d2b 100644 --- a/scripts/event/3rdJob_bowman.js +++ b/scripts/event/3rdJob_bowman.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Bowman **/ -importPackage(Packages.tools); var entryMap = 108010100; var exitMap = 105040305; @@ -31,10 +30,10 @@ var maxMapId = 108010101; var eventTime = 20; //20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -54,7 +53,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/3rdJob_magician.js b/scripts/event/3rdJob_magician.js index e7875bcea2..efa3818094 100644 --- a/scripts/event/3rdJob_magician.js +++ b/scripts/event/3rdJob_magician.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Magician **/ -importPackage(Packages.tools); var entryMap = 108010200; var exitMap = 100040106; @@ -31,10 +30,10 @@ var maxMapId = 108010201; var eventTime = 20; //20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -54,7 +53,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/3rdJob_mount.js b/scripts/event/3rdJob_mount.js index 094086c8ce..363f2e28f0 100644 --- a/scripts/event/3rdJob_mount.js +++ b/scripts/event/3rdJob_mount.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Kenta's Mount Quest **/ -importPackage(Packages.tools); var entryMap = 923010000; var exitMap = 923010100; @@ -33,10 +32,10 @@ var eventMaps = [923010000]; var eventTime = 5; //5 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -84,7 +83,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/3rdJob_pirate.js b/scripts/event/3rdJob_pirate.js index 2b0164ba8e..27ff8d4586 100644 --- a/scripts/event/3rdJob_pirate.js +++ b/scripts/event/3rdJob_pirate.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Pirate **/ -importPackage(Packages.tools); var entryMap = 108010500; var exitMap = 105070200; @@ -31,10 +30,10 @@ var maxMapId = 108010501; var eventTime = 20; //20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -46,7 +45,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/3rdJob_thief.js b/scripts/event/3rdJob_thief.js index 3da091fa42..37b5fefa60 100644 --- a/scripts/event/3rdJob_thief.js +++ b/scripts/event/3rdJob_thief.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Thief **/ -importPackage(Packages.tools); var entryMap = 108010400; var exitMap = 107000402; @@ -31,10 +30,10 @@ var maxMapId = 108010401; var eventTime = 20; //20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -54,7 +53,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/3rdJob_warrior.js b/scripts/event/3rdJob_warrior.js index f8c938d075..0ce3a86411 100644 --- a/scripts/event/3rdJob_warrior.js +++ b/scripts/event/3rdJob_warrior.js @@ -21,7 +21,6 @@ * @Author Ronan * 3rd Job Event - Warrior **/ -importPackage(Packages.tools); var entryMap = 108010300; var exitMap = 105070001; @@ -31,10 +30,10 @@ var maxMapId = 108010301; var eventTime = 20; //20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -54,7 +53,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/4jaerial.js b/scripts/event/4jaerial.js index d026a0fb09..a260999fa0 100644 --- a/scripts/event/4jaerial.js +++ b/scripts/event/4jaerial.js @@ -30,10 +30,10 @@ var maxMapId = 912020000; var eventTime = 2; //2 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { diff --git a/scripts/event/4jship.js b/scripts/event/4jship.js index ba58956743..b503d35058 100644 --- a/scripts/event/4jship.js +++ b/scripts/event/4jship.js @@ -30,10 +30,10 @@ var maxMapId = 912010200; var eventTime = 4; //4 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { diff --git a/scripts/event/4jsuper.js b/scripts/event/4jsuper.js index 322beef6d7..e225908a01 100644 --- a/scripts/event/4jsuper.js +++ b/scripts/event/4jsuper.js @@ -30,10 +30,10 @@ var maxMapId = 912010200; var eventTime = 4; //4 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { diff --git a/scripts/event/AirPlane.js b/scripts/event/AirPlane.js index a075c820e3..7ae92ce7e6 100644 --- a/scripts/event/AirPlane.js +++ b/scripts/event/AirPlane.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var KC_bfd; var Plane_to_CBD; var CBD_docked; diff --git a/scripts/event/AmoriaPQ.js b/scripts/event/AmoriaPQ.js index 6ad982a942..08683d08c0 100644 --- a/scripts/event/AmoriaPQ.js +++ b/scripts/event/AmoriaPQ.js @@ -37,14 +37,14 @@ var maxMapId = 670010800; var eventTime = 75; // 75 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -107,7 +107,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers && mask == 3)) eligible = []; if(onlyMarriedPlayers && hasNotMarried) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -147,8 +147,11 @@ function setup(level, lobbyid) { eim.getInstanceMap(670010800).shuffleReactors(); var mapObj = eim.getInstanceMap(670010700); - var mobObj = Packages.server.life.MapleLifeFactory.getMonster(9400536); - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(942, 478)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + var mobObj = MapleLifeFactory.getMonster(9400536); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(942, 478)); respawnStages(eim); diff --git a/scripts/event/Aran_2ndmount.js b/scripts/event/Aran_2ndmount.js index d9d064cc7f..27da92ba44 100644 --- a/scripts/event/Aran_2ndmount.js +++ b/scripts/event/Aran_2ndmount.js @@ -21,7 +21,6 @@ * @Author Ronan * Event - Scadur's Mount Quest **/ -importPackage(Packages.tools); var entryMap = 921110000; var exitMap = 211050000; @@ -31,10 +30,10 @@ var maxMapId = 921110000; var eventTime = 3; //3 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -60,7 +59,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 2); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/Aran_3rdmount.js b/scripts/event/Aran_3rdmount.js index 9c2a023622..93c9ee83c8 100644 --- a/scripts/event/Aran_3rdmount.js +++ b/scripts/event/Aran_3rdmount.js @@ -21,7 +21,6 @@ * @Author Ronan * Event - Wolves' Mount Quest **/ -importPackage(Packages.tools); var entryMap = 914030000; var exitMap = 140010210; @@ -31,10 +30,10 @@ var maxMapId = 914030000; var eventTime = 3; //3 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -61,7 +60,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 1); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/AreaBossBamboo.js b/scripts/event/AreaBossBamboo.js index 35d114c0a6..3a12c4ebf4 100644 --- a/scripts/event/AreaBossBamboo.js +++ b/scripts/event/AreaBossBamboo.js @@ -40,16 +40,19 @@ function cancelSchedule() { } function start() { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); var mapObj = em.getChannelServer().getMapFactory().getMap(800020120); // original mapid was 251010101 - var mobObj = Packages.server.life.MapleLifeFactory.getMonster(6090002); + var mobObj = MapleLifeFactory.getMonster(6090002); if(mapObj.getMonsterById(6090002) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(560, 50)); - mapObj.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "From amongst the ruins shrouded by the mists, Bamboo Warrior appears.")); + + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(560, 50)); + mapObj.broadcastMessage(MaplePacketCreator.serverNotice(6, "From amongst the ruins shrouded by the mists, Bamboo Warrior appears.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossCentipede.js b/scripts/event/AreaBossCentipede.js index 998ebddd08..b7e4b5653b 100644 --- a/scripts/event/AreaBossCentipede.js +++ b/scripts/event/AreaBossCentipede.js @@ -41,15 +41,19 @@ function cancelSchedule() { function start() { var herbGarden = em.getChannelServer().getMapFactory().getMap(251010102); - var gcent = Packages.server.life.MapleLifeFactory.getMonster(5220004); if(herbGarden.getMonsterById(5220004) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - herbGarden.spawnMonsterOnGroundBelow(gcent, new Packages.java.awt.Point(560, 50)); - herbGarden.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "From the mists surrounding the herb garden, the gargantuous Giant Centipede appears.")); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var gcent = MapleLifeFactory.getMonster(5220004); + herbGarden.spawnMonsterOnGroundBelow(gcent, new Point(560, 50)); + herbGarden.broadcastMessage(MaplePacketCreator.serverNotice(6, "From the mists surrounding the herb garden, the gargantuous Giant Centipede appears.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossDeo.js b/scripts/event/AreaBossDeo.js index 8c5328967b..64d13bb70e 100644 --- a/scripts/event/AreaBossDeo.js +++ b/scripts/event/AreaBossDeo.js @@ -41,15 +41,19 @@ function cancelSchedule() { function start() { var royalCatthusDesert = em.getChannelServer().getMapFactory().getMap(260010201); - var deo = Packages.server.life.MapleLifeFactory.getMonster(3220001); if(royalCatthusDesert.getMonsterById(3220001) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - royalCatthusDesert.spawnMonsterOnGroundBelow(deo, new Packages.java.awt.Point(645, 275)); - royalCatthusDesert.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Deo slowly appeared out of the sand dust.")); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var deo = MapleLifeFactory.getMonster(3220001); + royalCatthusDesert.spawnMonsterOnGroundBelow(deo, new Point(645, 275)); + royalCatthusDesert.broadcastMessage(MaplePacketCreator.serverNotice(6, "Deo slowly appeared out of the sand dust.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossDoor1.js b/scripts/event/AreaBossDoor1.js index e497823d06..68d447dbe4 100644 --- a/scripts/event/AreaBossDoor1.js +++ b/scripts/event/AreaBossDoor1.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400610; var bossMapid = 677000003; var bossMsg = "Amdusias has appeared!"; - var bossPos = new Packages.java.awt.Point(467, 0); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(467, 0); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDoor2.js b/scripts/event/AreaBossDoor2.js index 65bee99bc2..22380d50cf 100644 --- a/scripts/event/AreaBossDoor2.js +++ b/scripts/event/AreaBossDoor2.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400609; var bossMapid = 677000005; var bossMsg = "Andras has appeared!"; - var bossPos = new Packages.java.awt.Point(201, 80); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(201, 80); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDoor3.js b/scripts/event/AreaBossDoor3.js index 20969b76e9..f9dfa38f08 100644 --- a/scripts/event/AreaBossDoor3.js +++ b/scripts/event/AreaBossDoor3.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400613; var bossMapid = 677000009; var bossMsg = "Valefor has appeared!"; - var bossPos = new Packages.java.awt.Point(251, -841); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(251, -841); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDoor4.js b/scripts/event/AreaBossDoor4.js index e5965a9f3b..d58b2e7e0c 100644 --- a/scripts/event/AreaBossDoor4.js +++ b/scripts/event/AreaBossDoor4.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400633; var bossMapid = 677000012; var bossMsg = "Astaroth has appeared!"; - var bossPos = new Packages.java.awt.Point(842, 0); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(842, 0); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDoor5.js b/scripts/event/AreaBossDoor5.js index cae6b7cf90..a8b1095794 100644 --- a/scripts/event/AreaBossDoor5.js +++ b/scripts/event/AreaBossDoor5.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400612; var bossMapid = 677000001; var bossMsg = "Marbas has appeared!"; - var bossPos = new Packages.java.awt.Point(461, 61); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(461, 61); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDoor6.js b/scripts/event/AreaBossDoor6.js index 5576c7aa7f..3fdec07a5a 100644 --- a/scripts/event/AreaBossDoor6.js +++ b/scripts/event/AreaBossDoor6.js @@ -41,17 +41,21 @@ function start() { var bossMobid = 9400611; var bossMapid = 677000007; var bossMsg = "Crocell has appeared!"; - var bossPos = new Packages.java.awt.Point(171, 50); var map = em.getChannelServer().getMapFactory().getMap(bossMapid); if (map.getMonsterById(bossMobid) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - var boss = Packages.server.life.MapleLifeFactory.getMonster(bossMobid); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var boss = MapleLifeFactory.getMonster(bossMobid); + var bossPos = new Point(171, 50); map.spawnMonsterOnGroundBelow(boss, bossPos); - map.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, bossMsg)); + map.broadcastMessage(MaplePacketCreator.serverNotice(6, bossMsg)); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossDyle.js b/scripts/event/AreaBossDyle.js index f4c11549d2..084180a3c0 100644 --- a/scripts/event/AreaBossDyle.js +++ b/scripts/event/AreaBossDyle.js @@ -26,8 +26,6 @@ ThreeStep - based on xQuasar's King Clang spawner **/ -importPackage(Packages.server.life); -importPackage(Packages.tools); function init() { scheduleNew(); @@ -48,7 +46,12 @@ function start() { setupTask = em.schedule("start", 3 * 60 * 60 * 1000); return; } - dangeroudCroko1.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(6220000), new Packages.java.awt.Point(90, 119)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(90, 119); + dangeroudCroko1.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(6220000), spawnpoint); dangeroudCroko1.broadcastMessage(MaplePacketCreator.serverNotice(6, "The huge crocodile Dyle has come out from the swamp.")); setupTask = em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossEliza1.js b/scripts/event/AreaBossEliza1.js index 7a000355d7..ead84f636a 100644 --- a/scripts/event/AreaBossEliza1.js +++ b/scripts/event/AreaBossEliza1.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - var setupTask; function init() { @@ -45,16 +43,20 @@ function cancelSchedule() { } function start() { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var eliza = MapleLifeFactory.getMonster(8220000); var stairwayToTheSky2 = em.getChannelServer().getMapFactory().getMap(200010300); - var eliza = Packages.server.life.MapleLifeFactory.getMonster(8220000); - + if(stairwayToTheSky2.getMonsterById(8220000) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - stairwayToTheSky2.spawnMonsterOnGroundBelow(eliza, new Packages.java.awt.Point(208, 83)); - stairwayToTheSky2.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Eliza has appeared with a black whirlwind.")); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(208, 83); + stairwayToTheSky2.spawnMonsterOnGroundBelow(eliza, spawnpoint); + stairwayToTheSky2.broadcastMessage(MaplePacketCreator.serverNotice(6, "Eliza has appeared with a black whirlwind.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossFaust1.js b/scripts/event/AreaBossFaust1.js index 0d3de727a5..7219b6e422 100644 --- a/scripts/event/AreaBossFaust1.js +++ b/scripts/event/AreaBossFaust1.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,15 +42,19 @@ function cancelSchedule() { function start() { var theForestOfEvil1 = em.getChannelServer().getMapFactory().getMap(100040105); - var faust1 = Packages.server.life.MapleLifeFactory.getMonster(5220002); - if(theForestOfEvil1.getMonsterById(5220002) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - theForestOfEvil1.spawnMonsterOnGroundBelow(faust1, new Packages.java.awt.Point(456, 278)); - theForestOfEvil1.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Faust appeared amidst the blue fog.")); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + const Point = Java.type('java.awt.Point'); + + var faust1 = MapleLifeFactory.getMonster(5220002); + const spawnpoint = new Point(456, 278); + theForestOfEvil1.spawnMonsterOnGroundBelow(faust1, spawnpoint); + theForestOfEvil1.broadcastMessage(MaplePacketCreator.serverNotice(6, "Faust appeared amidst the blue fog.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossFaust2.js b/scripts/event/AreaBossFaust2.js index 610804655a..719da12138 100644 --- a/scripts/event/AreaBossFaust2.js +++ b/scripts/event/AreaBossFaust2.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -43,16 +41,21 @@ function cancelSchedule() { } function start() { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); var theForestOfEvil2 = em.getChannelServer().getMapFactory().getMap(100040106); - var faust2 = Packages.server.life.MapleLifeFactory.getMonster(5220002); + var faust2 = MapleLifeFactory.getMonster(5220002); if(theForestOfEvil2.getMonsterById(5220002) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; } - - theForestOfEvil2.spawnMonsterOnGroundBelow(faust2, new Packages.java.awt.Point(474, 278)); - theForestOfEvil2.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Faust appeared amidst the blue fog.")); + + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(474, 278); + theForestOfEvil2.spawnMonsterOnGroundBelow(faust2, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + theForestOfEvil2.broadcastMessage(MaplePacketCreator.serverNotice(6, "Faust appeared amidst the blue fog.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossKimera.js b/scripts/event/AreaBossKimera.js index 006e4e6ef4..c1e11a06a6 100644 --- a/scripts/event/AreaBossKimera.js +++ b/scripts/event/AreaBossKimera.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -43,8 +41,9 @@ function cancelSchedule() { } function start() { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); var labSecretBasementPath = em.getChannelServer().getMapFactory().getMap(261030000); - var chimera = Packages.server.life.MapleLifeFactory.getMonster(8220002); + var chimera = MapleLifeFactory.getMonster(8220002); if(labSecretBasementPath.getMonsterById(8220002) != null) { em.schedule("start", 3 * 60 *60 * 1000); @@ -54,8 +53,12 @@ function start() { var posX; var posY = 180; posX = (Math.floor(Math.random() * 900) - 900); - labSecretBasementPath.spawnMonsterOnGroundBelow(chimera, new Packages.java.awt.Point(posX, posY)); - labSecretBasementPath.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Kimera has appeared out of the darkness of the underground with a glitter in her eyes.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + labSecretBasementPath.spawnMonsterOnGroundBelow(chimera, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + labSecretBasementPath.broadcastMessage(MaplePacketCreator.serverNotice(6, "Kimera has appeared out of the darkness of the underground with a glitter in her eyes.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossKingClang.js b/scripts/event/AreaBossKingClang.js index 62e2871a5b..daad7c3346 100644 --- a/scripts/event/AreaBossKingClang.js +++ b/scripts/event/AreaBossKingClang.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - var hotSand; function init() { @@ -50,12 +48,18 @@ function start() { em.schedule("start", 3 * 60 *60 * 1000); return; } - var kingClang = Packages.server.life.MapleLifeFactory.getMonster(5220001); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var kingClang = MapleLifeFactory.getMonster(5220001); var posX; var posY = 140; posX = Math.floor((Math.random() * 2400) - 1600); - hotSand.spawnMonsterOnGroundBelow(kingClang, new Packages.java.awt.Point(posX, posY)); - hotSand.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "A strange turban shell has appeared on the beach.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + hotSand.spawnMonsterOnGroundBelow(kingClang, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + hotSand.broadcastMessage(MaplePacketCreator.serverNotice(6, "A strange turban shell has appeared on the beach.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossKingSageCat.js b/scripts/event/AreaBossKingSageCat.js index ffd42b4603..0e48183fb5 100644 --- a/scripts/event/AreaBossKingSageCat.js +++ b/scripts/event/AreaBossKingSageCat.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var goblinForest2 = em.getChannelServer().getMapFactory().getMap(250010504); - var kingSageCat = Packages.server.life.MapleLifeFactory.getMonster(7220002); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var kingSageCat = MapleLifeFactory.getMonster(7220002); if(goblinForest2.getMonsterById(7220002) != null) { em.schedule("start", 3 * 60 *60 * 1000); @@ -53,8 +52,12 @@ function start() { var posX; var posY = 540; posX = Math.floor((Math.random() * 1300) - 500); - goblinForest2.spawnMonsterOnGroundBelow(kingSageCat, new Packages.java.awt.Point(posX, posY)); - goblinForest2.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "The ghostly air around here has become stronger. The unpleasant sound of a cat crying can be heard.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + goblinForest2.spawnMonsterOnGroundBelow(kingSageCat, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + goblinForest2.broadcastMessage(MaplePacketCreator.serverNotice(6, "The ghostly air around here has become stronger. The unpleasant sound of a cat crying can be heard.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossLeviathan.js b/scripts/event/AreaBossLeviathan.js index 7a4ca827cf..4b53177f76 100644 --- a/scripts/event/AreaBossLeviathan.js +++ b/scripts/event/AreaBossLeviathan.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var leviathansCanyon = em.getChannelServer().getMapFactory().getMap(240040401); - var leviathan = Packages.server.life.MapleLifeFactory.getMonster(8220003); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var leviathan = MapleLifeFactory.getMonster(8220003); if(leviathansCanyon.getMonsterById(8220003) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; @@ -53,8 +52,12 @@ function start() { var posX; var posY = 1125; posX = Math.floor((Math.random() * 600) - 300); - leviathansCanyon.spawnMonsterOnGroundBelow(leviathan, new Packages.java.awt.Point(posX, posY)); - leviathansCanyon.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Leviathan emerges from the canyon and the cold icy wind blows.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + leviathansCanyon.spawnMonsterOnGroundBelow(leviathan, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + leviathansCanyon.broadcastMessage(MaplePacketCreator.serverNotice(6, "Leviathan emerges from the canyon and the cold icy wind blows.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossMano.js b/scripts/event/AreaBossMano.js index 861054278a..efd553f051 100644 --- a/scripts/event/AreaBossMano.js +++ b/scripts/event/AreaBossMano.js @@ -26,8 +26,6 @@ ThreeStep - based on xQuasar's King Clang spawner **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -43,14 +41,19 @@ function cancelSchedule() { function start() { var thicketAroundTheBeach3 = em.getChannelServer().getMapFactory().getMap(104000400); - var mano = Packages.server.life.MapleLifeFactory.getMonster(2220000); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var mano = MapleLifeFactory.getMonster(2220000); if(thicketAroundTheBeach3.getMonsterById(2220000) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - thicketAroundTheBeach3.spawnMonsterOnGroundBelow(mano, new Packages.java.awt.Point(279, -496)); - thicketAroundTheBeach3.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "A cool breeze was felt when Mano appeared.")); + + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(279, -496); + thicketAroundTheBeach3.spawnMonsterOnGroundBelow(mano, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + thicketAroundTheBeach3.broadcastMessage(MaplePacketCreator.serverNotice(6, "A cool breeze was felt when Mano appeared.")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossNineTailedFox.js b/scripts/event/AreaBossNineTailedFox.js index b49c71d549..9573170bde 100644 --- a/scripts/event/AreaBossNineTailedFox.js +++ b/scripts/event/AreaBossNineTailedFox.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var moonRidge = em.getChannelServer().getMapFactory().getMap(222010310); - var nineTailedFox = Packages.server.life.MapleLifeFactory.getMonster(7220001); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var nineTailedFox = MapleLifeFactory.getMonster(7220001); if(moonRidge.getMonsterById(7220001) != null) { em.schedule("start", 3 * 60 *60 * 1000); return; @@ -52,8 +51,12 @@ function start() { var posX; var posY = 33; posX = Math.floor((Math.random() * 1300) - 800); - moonRidge.spawnMonsterOnGroundBelow(nineTailedFox, new Packages.java.awt.Point(posX, posY)); - moonRidge.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "As the moon light dims, a long fox cry can be heard and the presence of the old fox can be felt")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + moonRidge.spawnMonsterOnGroundBelow(nineTailedFox, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + moonRidge.broadcastMessage(MaplePacketCreator.serverNotice(6, "As the moon light dims, a long fox cry can be heard and the presence of the old fox can be felt")); em.schedule("start", 3 * 60 *60 * 1000); } diff --git a/scripts/event/AreaBossSeruf.js b/scripts/event/AreaBossSeruf.js index 8ba8243b3d..d55e2da280 100644 --- a/scripts/event/AreaBossSeruf.js +++ b/scripts/event/AreaBossSeruf.js @@ -28,8 +28,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -45,7 +43,8 @@ function cancelSchedule() { function start() { var theSeaweedTower = em.getChannelServer().getMapFactory().getMap(230020100); - var seruf = Packages.server.life.MapleLifeFactory.getMonster(4220001); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var seruf = MapleLifeFactory.getMonster(4220001); if(theSeaweedTower.getMonsterById(4220001) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -55,8 +54,12 @@ function start() { var posX; var posY = 520; posX = Math.floor((Math.random() * 2300) - 1500); - theSeaweedTower.spawnMonsterOnGroundBelow(seruf, new Packages.java.awt.Point(posX, posY)); - theSeaweedTower.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "A strange shell has appeared from a grove of seaweed")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + theSeaweedTower.spawnMonsterOnGroundBelow(seruf, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + theSeaweedTower.broadcastMessage(MaplePacketCreator.serverNotice(6, "A strange shell has appeared from a grove of seaweed")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossSnackBar.js b/scripts/event/AreaBossSnackBar.js index 46d966c384..97388176d6 100644 --- a/scripts/event/AreaBossSnackBar.js +++ b/scripts/event/AreaBossSnackBar.js @@ -41,19 +41,23 @@ function cancelSchedule() { function start() { var snackBarMap = em.getChannelServer().getMapFactory().getMap(105090310); - var snackBar = Packages.server.life.MapleLifeFactory.getMonster(8220008); - - if(snackBarMap.getMonsterById(8220008) != null || snackBarMap.getMonsterById(8220009) != null) { - em.schedule("start", 3 * 60 * 60 * 1000); - return; - } - - var setPos = [[-626, -604], [735, -600]]; - var rndPos = setPos[Math.floor(Math.random() * setPos.length)]; - - snackBarMap.spawnMonsterOnGroundBelow(snackBar, new Packages.java.awt.Point(rndPos[0], rndPos[1])); - snackBarMap.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Slowly, a suspicious food stand opens up on a strangely remote place.")); - em.schedule("start", 3 * 60 *60 * 1000); + + if (snackBarMap.getMonsterById(8220008) != null || snackBarMap.getMonsterById(8220009) != null) { + em.schedule("start", 3 * 60 * 60 * 1000); + return; + } + + var setPos = [[-626, -604], [735, -600]]; + var rndPos = setPos[Math.floor(Math.random() * setPos.length)]; + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var snackBar = MapleLifeFactory.getMonster(8220008); + snackBarMap.spawnMonsterOnGroundBelow(snackBar, new Point(rndPos[0], rndPos[1])); + snackBarMap.broadcastMessage(MaplePacketCreator.serverNotice(6, "Slowly, a suspicious food stand opens up on a strangely remote place.")); + em.schedule("start", 3 * 60 * 60 * 1000); } // ---------- FILLER FUNCTIONS ---------- diff --git a/scripts/event/AreaBossStumpy.js b/scripts/event/AreaBossStumpy.js index 12354f9d4f..bb4cdf3b51 100644 --- a/scripts/event/AreaBossStumpy.js +++ b/scripts/event/AreaBossStumpy.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var eastRockyMountain5 = em.getChannelServer().getMapFactory().getMap(101030404); - var stumpy = Packages.server.life.MapleLifeFactory.getMonster(3220000); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var stumpy = MapleLifeFactory.getMonster(3220000); if(eastRockyMountain5.getMonsterById(3220000) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -54,8 +53,12 @@ function start() { var posX; var posY = 1280; posX = Math.floor((Math.random() * 800) + 400); - eastRockyMountain5.spawnMonsterOnGroundBelow(stumpy, new Packages.java.awt.Point(posX, posY)); - eastRockyMountain5.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Stumpy has appeared with a stumping sound that rings the Stone Mountain.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + eastRockyMountain5.spawnMonsterOnGroundBelow(stumpy, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + eastRockyMountain5.broadcastMessage(MaplePacketCreator.serverNotice(6, "Stumpy has appeared with a stumping sound that rings the Stone Mountain.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossTaeRoon.js b/scripts/event/AreaBossTaeRoon.js index 862fef4394..29532d19c2 100644 --- a/scripts/event/AreaBossTaeRoon.js +++ b/scripts/event/AreaBossTaeRoon.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var territoryOfWanderingBear = em.getChannelServer().getMapFactory().getMap(250010304); - var taeRoon = Packages.server.life.MapleLifeFactory.getMonster(7220000); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var taeRoon = MapleLifeFactory.getMonster(7220000); if(territoryOfWanderingBear.getMonsterById(7220000) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -54,8 +53,12 @@ function start() { var posX; var posY = 390; posX = Math.floor((Math.random() * 700) - 800); - territoryOfWanderingBear.spawnMonsterOnGroundBelow(taeRoon, new Packages.java.awt.Point(posX, posY)); - territoryOfWanderingBear.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Tae Roon has appeared with a soft whistling sound.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + territoryOfWanderingBear.spawnMonsterOnGroundBelow(taeRoon, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + territoryOfWanderingBear.broadcastMessage(MaplePacketCreator.serverNotice(6, "Tae Roon has appeared with a soft whistling sound.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossTimer1.js b/scripts/event/AreaBossTimer1.js index 0ba63a009f..2d76789b54 100644 --- a/scripts/event/AreaBossTimer1.js +++ b/scripts/event/AreaBossTimer1.js @@ -26,8 +26,6 @@ ThreeStep - based on xQuasar's King Clang spawner **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -43,7 +41,8 @@ function cancelSchedule() { function start() { var whirlpoolOfTime = em.getChannelServer().getMapFactory().getMap(220050100); - var timer1 = Packages.server.life.MapleLifeFactory.getMonster(5220003); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var timer1 = MapleLifeFactory.getMonster(5220003); if(whirlpoolOfTime.getMonsterById(5220003) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -53,8 +52,12 @@ function start() { var posX; var posY = 1030; posX = Math.floor((Math.random() * 770) - 770); - whirlpoolOfTime.spawnMonsterOnGroundBelow(timer1, new Packages.java.awt.Point(posX, posY)); - whirlpoolOfTime.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + whirlpoolOfTime.spawnMonsterOnGroundBelow(timer1, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + whirlpoolOfTime.broadcastMessage(MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossTimer2.js b/scripts/event/AreaBossTimer2.js index 0618e87b3e..51aa4efc23 100644 --- a/scripts/event/AreaBossTimer2.js +++ b/scripts/event/AreaBossTimer2.js @@ -27,8 +27,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -44,7 +42,8 @@ function cancelSchedule() { function start() { var lostTime1 = em.getChannelServer().getMapFactory().getMap(220050000); - var timer2 = Packages.server.life.MapleLifeFactory.getMonster(5220003); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var timer2 = MapleLifeFactory.getMonster(5220003); if(lostTime1.getMonsterById(5220003) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -54,8 +53,12 @@ function start() { var posX; var posY = 1030; posX = Math.floor((Math.random() * 1400) - 1000); - lostTime1.spawnMonsterOnGroundBelow(timer2, new Packages.java.awt.Point(posX, posY)); - lostTime1.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + lostTime1.spawnMonsterOnGroundBelow(timer2, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + lostTime1.broadcastMessage(MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossTimer3.js b/scripts/event/AreaBossTimer3.js index 6642cc05cf..cd5d9a73fb 100644 --- a/scripts/event/AreaBossTimer3.js +++ b/scripts/event/AreaBossTimer3.js @@ -28,8 +28,6 @@ **/ -importPackage(Packages.client); - function init() { scheduleNew(); } @@ -45,7 +43,8 @@ function cancelSchedule() { function start() { var lostTime2 = em.getChannelServer().getMapFactory().getMap(220050200); - var timer3 = Packages.server.life.MapleLifeFactory.getMonster(5220003); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var timer3 = MapleLifeFactory.getMonster(5220003); if(lostTime2.getMonsterById(5220003) != null) { em.schedule("start", 3 * 60 * 60 * 1000); @@ -55,8 +54,12 @@ function start() { var posX; var posY = 1030; posX = Math.floor((Math.random() * 1400) - 700); - lostTime2.spawnMonsterOnGroundBelow(timer3, new Packages.java.awt.Point(posX, posY)); - lostTime2.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); + const Point = Java.type('java.awt.Point'); + const spawnpoint = new Point(posX, posY); + lostTime2.spawnMonsterOnGroundBelow(timer3, spawnpoint); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + lostTime2.broadcastMessage(MaplePacketCreator.serverNotice(6, "Tick-Tock Tick-Tock! Timer makes it's presence known.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/AreaBossZeno.js b/scripts/event/AreaBossZeno.js index 9820efc538..348f03bce5 100644 --- a/scripts/event/AreaBossZeno.js +++ b/scripts/event/AreaBossZeno.js @@ -41,15 +41,19 @@ function cancelSchedule() { function start() { var graysPrairie = em.getChannelServer().getMapFactory().getMap(221040301); - var zeno = Packages.server.life.MapleLifeFactory.getMonster(6220001); if(graysPrairie.getMonsterById(6220001) != null) { em.schedule("start", 3 * 60 * 60 * 1000); return; } - - graysPrairie.spawnMonsterOnGroundBelow(zeno, new Packages.java.awt.Point(-4224, 776)); - graysPrairie.broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "Zeno has appeared with a heavy sound of machinery.")); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + + var zeno = MapleLifeFactory.getMonster(6220001); + graysPrairie.spawnMonsterOnGroundBelow(zeno, new Point(-4224, 776)); + graysPrairie.broadcastMessage(MaplePacketCreator.serverNotice(6, "Zeno has appeared with a heavy sound of machinery.")); em.schedule("start", 3 * 60 * 60 * 1000); } diff --git a/scripts/event/BalrogBattle.js b/scripts/event/BalrogBattle.js index 0517777dda..1ebd80265b 100644 --- a/scripts/event/BalrogBattle.js +++ b/scripts/event/BalrogBattle.js @@ -23,8 +23,6 @@ * @event: Vs Balrog */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 6, maxPlayers = 30; var minLevel = 50, maxLevel = 255; @@ -43,14 +41,14 @@ var bossMobId = 8830003; var eventTime = 60; // 60 minutes var releaseClawTime = 1; -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -105,7 +103,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -136,14 +134,17 @@ function releaseLeftClaw(eim) { function spawnBalrog(eim) { var mapObj = eim.getInstanceMap(entryMap); - - mapObj.spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830000), new Packages.java.awt.Point(412, 258)); - mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830002), new Packages.java.awt.Point(412, 258)); - mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830006), new Packages.java.awt.Point(412, 258)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + mapObj.spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830000), new Point(412, 258)); + mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830002), new Point(412, 258)); + mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830006), new Point(412, 258)); } function spawnSealedBalrog(eim) { - eim.getInstanceMap(entryMap).spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(bossMobId), new Packages.java.awt.Point(412, 258)); + const Point = Java.type('java.awt.Point'); + eim.getInstanceMap(entryMap).spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(bossMobId), new Point(412, 258)); } function playerEntry(eim, player) { diff --git a/scripts/event/BalrogBattle_Easy.js b/scripts/event/BalrogBattle_Easy.js index 1fa9b7da5f..e6efb9956b 100644 --- a/scripts/event/BalrogBattle_Easy.js +++ b/scripts/event/BalrogBattle_Easy.js @@ -23,8 +23,6 @@ * @event: Vs Balrog */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 3, maxPlayers = 30; var minLevel = 50, maxLevel = 255; @@ -43,14 +41,14 @@ var bossMobId = 8830010; var eventTime = 60; // 60 minutes var releaseClawTime = 1; -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -105,7 +103,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -136,14 +134,17 @@ function releaseLeftClaw(eim) { function spawnBalrog(eim) { var mapObj = eim.getInstanceMap(entryMap); - - mapObj.spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830007), new Packages.java.awt.Point(412, 258)); - mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830009), new Packages.java.awt.Point(412, 258)); - mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830013), new Packages.java.awt.Point(412, 258)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + mapObj.spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830007), new Point(412, 258)); + mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830009), new Point(412, 258)); + mapObj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8830013), new Point(412, 258)); } function spawnSealedBalrog(eim) { - eim.getInstanceMap(entryMap).spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(bossMobId), new Packages.java.awt.Point(412, 258)); + const Point = Java.type('java.awt.Point'); + eim.getInstanceMap(entryMap).spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(bossMobId), new Point(412, 258)); } function playerEntry(eim, player) { diff --git a/scripts/event/BalrogQuest.js b/scripts/event/BalrogQuest.js index c25725fc24..9a7be5607f 100644 --- a/scripts/event/BalrogQuest.js +++ b/scripts/event/BalrogQuest.js @@ -21,7 +21,6 @@ * @Author Ronan * Event - Balrog Quest **/ -importPackage(Packages.tools); var entryMap = 910520000; var exitMap = 105100100; @@ -31,10 +30,10 @@ var maxMapId = 910520000; var eventTime = 10; //10 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function init() { @@ -63,7 +62,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 1); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } @@ -96,7 +96,8 @@ function isBalrog(mob) { function monsterKilled(mob, eim) { if(isBalrog(mob)) { - eim.spawnNpc(1061015, new java.awt.Point(0, 115), mob.getMap()); + const Point = Java.type('java.awt.Point'); + eim.spawnNpc(1061015, new Point(0, 115), mob.getMap()); } } function monsterValue(eim, mobId) { diff --git a/scripts/event/Boats.js b/scripts/event/Boats.js index cea1f52ec6..69d75f7019 100644 --- a/scripts/event/Boats.js +++ b/scripts/event/Boats.js @@ -1,7 +1,3 @@ -importPackage(Packages.client); -importPackage(Packages.tools); -importPackage(Packages.server.life); - var Orbis_btf; var Boat_to_Orbis; var Orbis_Boat_Cabin; @@ -64,7 +60,9 @@ function takeoff() { em.setProperty("docked","false"); - if(Math.random() < 0.42) em.schedule("approach", (invasionStartTime + (Math.random() * invasionDelayTime))); + if (Math.random() < 0.42) { + em.schedule("approach", (invasionStartTime + Math.trunc((Math.random() * invasionDelayTime)))); + } em.schedule("arrived", rideTime); } @@ -88,6 +86,7 @@ function approach() { em.setProperty("haveBalrog","true"); Boat_to_Orbis.broadcastEnemyShip(true); Boat_to_Ellinia.broadcastEnemyShip(true); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); Boat_to_Orbis.broadcastMessage(MaplePacketCreator.musicChange("Bgm04/ArabPirate")); Boat_to_Ellinia.broadcastMessage(MaplePacketCreator.musicChange("Bgm04/ArabPirate")); @@ -96,6 +95,8 @@ function approach() { } function invasion() { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + var map1 = Boat_to_Ellinia; var pos1 = new java.awt.Point(-538, 143); map1.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8150000), pos1); diff --git a/scripts/event/BossRushPQ.js b/scripts/event/BossRushPQ.js index ad1bc34473..81cfd89f80 100644 --- a/scripts/event/BossRushPQ.js +++ b/scripts/event/BossRushPQ.js @@ -36,14 +36,14 @@ var maxMapId = 970042711; var eventTime = 5; //5 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -117,7 +117,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/CWKPQ.js b/scripts/event/CWKPQ.js index 4c7e41df21..c46404adf7 100644 --- a/scripts/event/CWKPQ.js +++ b/scripts/event/CWKPQ.js @@ -36,14 +36,14 @@ var maxMapId = 610030800; var eventTime = 2; // 2 minutes for first stg -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { diff --git a/scripts/event/Cabin.js b/scripts/event/Cabin.js index a793ad8851..cb602edc1a 100644 --- a/scripts/event/Cabin.js +++ b/scripts/event/Cabin.js @@ -39,8 +39,6 @@ --------------------------------------------------------------------------------------------------- **/ -importPackage(Packages.tools); - var Orbis_btf; var Leafre_btf; var Cabin_to_Orbis; diff --git a/scripts/event/CafePQ_1.js b/scripts/event/CafePQ_1.js index c0f3945d0a..f7c71bb70c 100644 --- a/scripts/event/CafePQ_1.js +++ b/scripts/event/CafePQ_1.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 1 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [190000000, 190000001, 190000002]; var eventTime = 45; // 45 minutes var couponsNeeded = 400; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, getDroppedQuantity(mob)); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/CafePQ_2.js b/scripts/event/CafePQ_2.js index 7f3108eb6b..6843fe1240 100644 --- a/scripts/event/CafePQ_2.js +++ b/scripts/event/CafePQ_2.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 2 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [191000000, 191000001]; var eventTime = 45; // 45 minutes var couponsNeeded = 350; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, getDroppedQuantity(mob)); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/CafePQ_3.js b/scripts/event/CafePQ_3.js index b9b11b3fff..82aefc9b42 100644 --- a/scripts/event/CafePQ_3.js +++ b/scripts/event/CafePQ_3.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 3 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [192000000, 192000001]; var eventTime = 45; // 45 minutes var couponsNeeded = 350; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, getDroppedQuantity(mob)); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/CafePQ_4.js b/scripts/event/CafePQ_4.js index 8802c50b38..2d4aca90f0 100644 --- a/scripts/event/CafePQ_4.js +++ b/scripts/event/CafePQ_4.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 4 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [195000000, 195010000, 195020000, 195030000]; var eventTime = 45; // 45 minutes var couponsNeeded = 450; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, getDroppedQuantity(mob)); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/CafePQ_5.js b/scripts/event/CafePQ_5.js index 9029263719..4e2f36a319 100644 --- a/scripts/event/CafePQ_5.js +++ b/scripts/event/CafePQ_5.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 5 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [196000000, 196010000]; var eventTime = 45; // 45 minutes var couponsNeeded = 500; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, getDroppedQuantity(mob)); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/CafePQ_6.js b/scripts/event/CafePQ_6.js index 00ecbd9956..50c1d4bc9c 100644 --- a/scripts/event/CafePQ_6.js +++ b/scripts/event/CafePQ_6.js @@ -23,8 +23,6 @@ * @event: Cafe PQ 6 */ -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 120; @@ -40,14 +38,14 @@ var eventMaps = [197000000, 197010000]; var eventTime = 45; // 45 minutes var couponsNeeded = 300; // total of coupons to complete the event -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -102,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -255,6 +253,7 @@ function monsterKilled(mob, eim) { if(eim.isEventCleared()) return; var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(4001007, 0, 1); var dropper = eim.getPlayers().get(0); diff --git a/scripts/event/DelliBattle.js b/scripts/event/DelliBattle.js index 327ab2778c..b21edef43d 100644 --- a/scripts/event/DelliBattle.js +++ b/scripts/event/DelliBattle.js @@ -35,14 +35,14 @@ var maxMapId = 925010300; var eventTime = 6; // 6 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -80,7 +80,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/DollHouse.js b/scripts/event/DollHouse.js index a01e6e072a..df5d482425 100644 --- a/scripts/event/DollHouse.js +++ b/scripts/event/DollHouse.js @@ -22,7 +22,6 @@ /** *Dollhouse Event **/ -importPackage(Packages.tools); var entryMap = 922000010; var exitMap = 221024400; @@ -46,7 +45,8 @@ function playerEntry(eim, player) { player.changeMap(entryMap, 0); em.setProperty("noEntry","true"); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(eventTime * 60)); eim.startEventTimer(eventTime * 60000); } diff --git a/scripts/event/ElementalBattle.js b/scripts/event/ElementalBattle.js index 17ee7b3a59..f286ae6564 100644 --- a/scripts/event/ElementalBattle.js +++ b/scripts/event/ElementalBattle.js @@ -36,14 +36,14 @@ var maxMapId = 922020100; var eventTime = 20; // 20 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/EllinPQ.js b/scripts/event/EllinPQ.js index 0ccda9903c..51501e6cb0 100644 --- a/scripts/event/EllinPQ.js +++ b/scripts/event/EllinPQ.js @@ -36,14 +36,14 @@ var maxMapId = 930000800; var eventTime = 30; // 30 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -90,7 +90,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/ElnathPQ.js b/scripts/event/ElnathPQ.js index fd4d56a424..082d16178b 100644 --- a/scripts/event/ElnathPQ.js +++ b/scripts/event/ElnathPQ.js @@ -35,14 +35,14 @@ var maxMapId = 921100300; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -80,7 +80,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/Genie.js b/scripts/event/Genie.js index 26f3ac5bfa..1894771858 100644 --- a/scripts/event/Genie.js +++ b/scripts/event/Genie.js @@ -19,7 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.tools); var Orbis_btf; var Genie_to_Orbis; diff --git a/scripts/event/GuildQuest.js b/scripts/event/GuildQuest.js index 4a942f1407..2e60a73214 100644 --- a/scripts/event/GuildQuest.js +++ b/scripts/event/GuildQuest.js @@ -38,14 +38,14 @@ var waitTime = 3; // 3 minutes var eventTime = 90; // 90 minutes var bonusTime = 0.5; // 30 seconds -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -112,7 +112,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/Hak.js b/scripts/event/Hak.js index 24e33279d9..536124e21d 100644 --- a/scripts/event/Hak.js +++ b/scripts/event/Hak.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var returnTo = new Array(200000141, 250000100); var rideTo = new Array(250000100, 200000141); var birdRide = new Array(200090300, 200090310); @@ -33,7 +31,8 @@ function playerEntry(eim, player) { returnMap = eim.getMapFactory().getMap(returnTo[myRide]); onRide = eim.getMapFactory().getMap(birdRide[myRide]); player.changeMap(onRide, onRide.getPortal(0)); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(rideTime / 1000)); eim.schedule("timeOut", rideTime); } diff --git a/scripts/event/HenesysPQ.js b/scripts/event/HenesysPQ.js index 2b44f2a4a5..84a6432819 100644 --- a/scripts/event/HenesysPQ.js +++ b/scripts/event/HenesysPQ.js @@ -36,14 +36,14 @@ var maxMapId = 910010400; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -249,8 +249,9 @@ function friendlyItemDrop(eim, mob) { if (mob.getId() == 9300061) { var cakes = eim.getIntProperty("bunnyCake") + 1; eim.setIntProperty("bunnyCake", cakes); - - mob.getMap().broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "The Moon Bunny made rice cake number " + cakes + ".")); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + mob.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny made rice cake number " + cakes + ".")); } } @@ -258,7 +259,8 @@ function friendlyDamaged(eim, mob) { if (mob.getId() == 9300061) { var bunnyDamage = eim.getIntProperty("bunnyDamaged") + 1; if (bunnyDamage > 5) { - broadcastMessage(Packages.tools.MaplePacketCreator.serverNotice(6, "The Moon Bunny is feeling sick. Please protect it so it can make delicious rice cakes.")); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny is feeling sick. Please protect it so it can make delicious rice cakes.")); eim.setIntProperty("bunnyDamaged", 0); } } diff --git a/scripts/event/HolidayPQ_1.js b/scripts/event/HolidayPQ_1.js index 56a8538067..68920209b6 100644 --- a/scripts/event/HolidayPQ_1.js +++ b/scripts/event/HolidayPQ_1.js @@ -25,9 +25,6 @@ // GMS-like event string data thanks to iHealForLove -importPackage(Packages.client.inventory); -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 21, maxLevel = 30; @@ -41,14 +38,14 @@ var maxMapId = 889100001; var eventTime = 15; // 15 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -113,7 +110,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -277,6 +274,7 @@ function monsterKilled(mob, eim) { } var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item((forceDrop || Math.random() < 0.77) ? 4032094 : 4032095, 0, 1); // 77% chance of not fake var dropper = eim.getPlayers().get(0); @@ -305,9 +303,11 @@ function snowmanEvolve(eim, curLevel) { eim.setIntProperty("snowmanLevel", curLevel + 2); // increment by 2 to decrement by 1 on friendlyKilled mapobj.killMonster(snowman, null, false, 2); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var snowman = MapleLifeFactory.getMonster(9400317 + (5 * difficulty) + curLevel); - mapobj.spawnMonsterOnGroundBelow(snowman, new java.awt.Point(-180, 15)); + mapobj.spawnMonsterOnGroundBelow(snowman, new Point(-180, 15)); if(curLevel >= 4) { mapobj.allowSummonState(false); diff --git a/scripts/event/HolidayPQ_2.js b/scripts/event/HolidayPQ_2.js index a01aa60782..954c677c0d 100644 --- a/scripts/event/HolidayPQ_2.js +++ b/scripts/event/HolidayPQ_2.js @@ -25,9 +25,6 @@ // GMS-like event string data thanks to iHealForLove -importPackage(Packages.client.inventory); -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 31, maxLevel = 40; @@ -41,14 +38,14 @@ var maxMapId = 889100011; var eventTime = 20; // 20 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -113,7 +110,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -277,6 +274,7 @@ function monsterKilled(mob, eim) { } var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item((forceDrop || Math.random() < 0.77) ? 4032094 : 4032095, 0, 1); // 77% chance of not fake var dropper = eim.getPlayers().get(0); @@ -305,9 +303,11 @@ function snowmanEvolve(eim, curLevel) { eim.setIntProperty("snowmanLevel", curLevel + 2); // increment by 2 to decrement by 1 on friendlyKilled mapobj.killMonster(snowman, null, false, 2); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var snowman = MapleLifeFactory.getMonster(9400317 + (5 * difficulty) + curLevel); - mapobj.spawnMonsterOnGroundBelow(snowman, new java.awt.Point(-180, 15)); + mapobj.spawnMonsterOnGroundBelow(snowman, new Point(-180, 15)); if(curLevel >= 4) { mapobj.allowSummonState(false); diff --git a/scripts/event/HolidayPQ_3.js b/scripts/event/HolidayPQ_3.js index afb2cc7459..e08173bd6a 100644 --- a/scripts/event/HolidayPQ_3.js +++ b/scripts/event/HolidayPQ_3.js @@ -25,9 +25,6 @@ // GMS-like event string data thanks to iHealForLove -importPackage(Packages.client.inventory); -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 3, maxPlayers = 6; var minLevel = 41, maxLevel = 50; @@ -41,14 +38,14 @@ var maxMapId = 889100021; var eventTime = 25; // 25 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -113,7 +110,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -277,6 +274,7 @@ function monsterKilled(mob, eim) { } var mapObj = mob.getMap(); + const Item = Java.type('client.inventory.Item'); var itemObj = new Item((forceDrop || Math.random() < 0.77) ? 4032094 : 4032095, 0, 1); // 77% chance of not fake var dropper = eim.getPlayers().get(0); @@ -305,9 +303,11 @@ function snowmanEvolve(eim, curLevel) { eim.setIntProperty("snowmanLevel", curLevel + 2); // increment by 2 to decrement by 1 on friendlyKilled mapobj.killMonster(snowman, null, false, 2); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var snowman = MapleLifeFactory.getMonster(9400317 + (5 * difficulty) + curLevel); - mapobj.spawnMonsterOnGroundBelow(snowman, new java.awt.Point(-180, 15)); + mapobj.spawnMonsterOnGroundBelow(snowman, new Point(-180, 15)); if(curLevel >= 4) { mapobj.allowSummonState(false); diff --git a/scripts/event/HorntailBattle.js b/scripts/event/HorntailBattle.js index a49801f525..cd2dc1d052 100644 --- a/scripts/event/HorntailBattle.js +++ b/scripts/event/HorntailBattle.js @@ -23,8 +23,6 @@ * @event: Horntail Battle */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 6, maxPlayers = 30; var minLevel = 100, maxLevel = 255; @@ -38,14 +36,14 @@ var maxMapId = 240060200; var eventTime = 120; // 120 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -97,15 +95,17 @@ function setup(channel) { eim.getInstanceMap(240060000).resetPQ(level); eim.getInstanceMap(240060100).resetPQ(level); eim.getInstanceMap(240060200).resetPQ(level); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var map, mob; map = eim.getInstanceMap(240060000); mob = MapleLifeFactory.getMonster(8810000); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(960, 120)); + map.spawnMonsterOnGroundBelow(mob, new Point(960, 120)); map = eim.getInstanceMap(240060100); mob = MapleLifeFactory.getMonster(8810001); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(-420, 120)); + map.spawnMonsterOnGroundBelow(mob, new Point(-420, 120)); eim.startEventTimer(eventTime * 60000); setEventRewards(eim); diff --git a/scripts/event/HorntailPQ.js b/scripts/event/HorntailPQ.js index 7dddb408f9..c7ae6d4f0d 100644 --- a/scripts/event/HorntailPQ.js +++ b/scripts/event/HorntailPQ.js @@ -36,14 +36,14 @@ var maxMapId = 240050310; var eventTime = 25; // 25 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/KerningPQ.js b/scripts/event/KerningPQ.js index 81837f319b..f0aefe454d 100644 --- a/scripts/event/KerningPQ.js +++ b/scripts/event/KerningPQ.js @@ -36,14 +36,14 @@ var maxMapId = 103000805; var eventTime = 30; // 30 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/KerningTrain.js b/scripts/event/KerningTrain.js index 516af052c5..09f707ee27 100644 --- a/scripts/event/KerningTrain.js +++ b/scripts/event/KerningTrain.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var returnTo = new Array(103000100, 103000310); var rideTo = new Array(103000310, 103000100); var trainRide = new Array(103000301, 103000302); @@ -34,7 +32,8 @@ function playerEntry(eim, player) { returnMap = eim.getMapFactory().getMap(returnTo[myRide]); onRide = eim.getMapFactory().getMap(trainRide[myRide]); player.changeMap(onRide, onRide.getPortal(0)); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getClient().announce(MaplePacketCreator.getClock(rideTime / 1000)); player.getClient().announce(MaplePacketCreator.earnTitleMessage("The next stop is at Kerning " + (myRide == 0 ? "Square" : "Subway") + " Station. The exit is to your left.")); eim.schedule("timeOut", rideTime); diff --git a/scripts/event/LatanicaBattle.js b/scripts/event/LatanicaBattle.js index f9d82b4df9..40a63c8c22 100644 --- a/scripts/event/LatanicaBattle.js +++ b/scripts/event/LatanicaBattle.js @@ -36,14 +36,14 @@ var maxMapId = 541010100; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/LudiMazePQ.js b/scripts/event/LudiMazePQ.js index 183e2d4cda..475c54f25f 100644 --- a/scripts/event/LudiMazePQ.js +++ b/scripts/event/LudiMazePQ.js @@ -36,14 +36,14 @@ var maxMapId = 809050016; var eventTime = 15; // 15 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/LudiPQ.js b/scripts/event/LudiPQ.js index 6e9e4577f5..eaea40f276 100644 --- a/scripts/event/LudiPQ.js +++ b/scripts/event/LudiPQ.js @@ -36,14 +36,14 @@ var maxMapId = 922011100; var eventTime = 45; // 45 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/MK_PrimeMinister.js b/scripts/event/MK_PrimeMinister.js index 0ef72ad21d..73202b1102 100644 --- a/scripts/event/MK_PrimeMinister.js +++ b/scripts/event/MK_PrimeMinister.js @@ -1,6 +1,3 @@ -importPackage(Packages.tools); -importPackage(Packages.server.life); - var eventTime = 10 * 60 * 1000; // 10 minutes var entryMap = 106021600; var exitMap = 106021402; @@ -34,7 +31,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(difficulty, lobbyId){ @@ -66,7 +63,9 @@ function respawn(eim){ var weddinghall = eim.getMapInstance(entryMap); weddinghall.getPortal(1).setPortalState(false); - weddinghall.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(292, 143)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + weddinghall.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(292, 143)); } else { eim.schedule("respawn", 10000); } diff --git a/scripts/event/MK_PrimeMinister2.js b/scripts/event/MK_PrimeMinister2.js index 32e2788366..e1539ba7d7 100644 --- a/scripts/event/MK_PrimeMinister2.js +++ b/scripts/event/MK_PrimeMinister2.js @@ -1,6 +1,3 @@ -importPackage(Packages.tools); -importPackage(Packages.server.life); - var eventTime = 10 * 60 * 1000; // 10 minutes var entryMap = 106021601; var exitMap = 106021402; @@ -34,7 +31,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(difficulty, lobbyId){ @@ -57,7 +54,9 @@ function respawn(eim){ var weddinghall = eim.getMapInstance(entryMap); weddinghall.getPortal(1).setPortalState(false); - weddinghall.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(292, 143)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + weddinghall.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(292, 143)); } else { eim.schedule("respawn", 10000); } diff --git a/scripts/event/MagatiaPQ_A.js b/scripts/event/MagatiaPQ_A.js index 663e0ef781..e4216b7446 100644 --- a/scripts/event/MagatiaPQ_A.js +++ b/scripts/event/MagatiaPQ_A.js @@ -23,8 +23,6 @@ * @event: Magatia PQ (Alcadno) */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 4, maxPlayers = 4; var minLevel = 71, maxLevel = 85; @@ -38,14 +36,14 @@ var maxMapId = 926110600; var eventTime = 45; // 45 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -144,11 +142,12 @@ function setup(level, lobbyid) { eim.getInstanceMap(926110201).shuffleReactors(2518000, 2612004); eim.getInstanceMap(926110202).shuffleReactors(2518000, 2612004); - - eim.spawnNpc(2112010, new java.awt.Point(252, 243), eim.getInstanceMap(926110203)); - eim.spawnNpc(2112010, new java.awt.Point(200, 100), eim.getInstanceMap(926110401)); - eim.spawnNpc(2112011, new java.awt.Point(200, 100), eim.getInstanceMap(926110500)); - eim.spawnNpc(2112018, new java.awt.Point(200, 100), eim.getInstanceMap(926110600)); + + const Point = Java.type('java.awt.Point'); + eim.spawnNpc(2112010, new Point(252, 243), eim.getInstanceMap(926110203)); + eim.spawnNpc(2112010, new Point(200, 100), eim.getInstanceMap(926110401)); + eim.spawnNpc(2112011, new Point(200, 100), eim.getInstanceMap(926110500)); + eim.spawnNpc(2112018, new Point(200, 100), eim.getInstanceMap(926110600)); respawnStages(eim); eim.startEventTimer(eventTime * 60000); @@ -245,15 +244,17 @@ function respawnStages(eim) { var mapobj = eim.getMapInstance(926110401); var mobcount = mapobj.countMonster(9300150); var mobobj; + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); if(mobcount == 0) { mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-278, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-278, -126)); mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-542, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-542, -126)); } else if(mobcount == 1) { mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-542, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-542, -126)); } } @@ -311,14 +312,16 @@ function yuleteAction(eim) { var mob1 = 9300143, mob2 = 9300144; mapobj.destroyNPC(2112010); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mobobj1, mobobj2; for(var i = 0; i < 5; i++) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(-455, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(-455, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(-455, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(-455, 135)); } @@ -326,8 +329,8 @@ function yuleteAction(eim) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(0, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(0, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(0, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(0, 135)); } @@ -335,8 +338,8 @@ function yuleteAction(eim) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(360, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(360, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(360, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(360, 135)); } } diff --git a/scripts/event/MagatiaPQ_Z.js b/scripts/event/MagatiaPQ_Z.js index 3dea1423b2..ec12baa753 100644 --- a/scripts/event/MagatiaPQ_Z.js +++ b/scripts/event/MagatiaPQ_Z.js @@ -23,8 +23,6 @@ * @event: Magatia PQ (Zenumist) */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 4, maxPlayers = 4; var minLevel = 71, maxLevel = 85; @@ -38,14 +36,14 @@ var maxMapId = 926100600; var eventTime = 45; // 45 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -144,11 +142,12 @@ function setup(level, lobbyid) { eim.getInstanceMap(926100201).shuffleReactors(2518000, 2612004); eim.getInstanceMap(926100202).shuffleReactors(2518000, 2612004); - - eim.spawnNpc(2112000, new java.awt.Point(252, 243), eim.getInstanceMap(926100203)); - eim.spawnNpc(2112000, new java.awt.Point(200, 100), eim.getInstanceMap(926100401)); - eim.spawnNpc(2112001, new java.awt.Point(200, 100), eim.getInstanceMap(926100500)); - eim.spawnNpc(2112018, new java.awt.Point(200, 100), eim.getInstanceMap(926100600)); + + const Point = Java.type('java.awt.Point'); + eim.spawnNpc(2112000, new Point(252, 243), eim.getInstanceMap(926100203)); + eim.spawnNpc(2112000, new Point(200, 100), eim.getInstanceMap(926100401)); + eim.spawnNpc(2112001, new Point(200, 100), eim.getInstanceMap(926100500)); + eim.spawnNpc(2112018, new Point(200, 100), eim.getInstanceMap(926100600)); respawnStages(eim); eim.startEventTimer(eventTime * 60000); @@ -245,15 +244,17 @@ function respawnStages(eim) { var mapobj = eim.getMapInstance(926100401); var mobcount = mapobj.countMonster(9300150); var mobobj; + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); if(mobcount == 0) { mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-278, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-278, -126)); mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-542, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-542, -126)); } else if(mobcount == 1) { mobobj = MapleLifeFactory.getMonster(9300150); - mapobj.spawnMonsterOnGroundBelow(mobobj, new Packages.java.awt.Point(-542, -126)); + mapobj.spawnMonsterOnGroundBelow(mobobj, new Point(-542, -126)); } } @@ -311,14 +312,16 @@ function yuleteAction(eim) { var mob1 = 9300143, mob2 = 9300144; mapobj.destroyNPC(2112000); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mobobj1, mobobj2; for(var i = 0; i < 5; i++) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(-455, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(-455, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(-455, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(-455, 135)); } @@ -326,8 +329,8 @@ function yuleteAction(eim) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(0, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(0, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(0, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(0, 135)); } @@ -335,8 +338,8 @@ function yuleteAction(eim) { mobobj1 = MapleLifeFactory.getMonster(mob1); mobobj2 = MapleLifeFactory.getMonster(mob2); - mapobj.spawnMonsterOnGroundBelow(mobobj1, new Packages.java.awt.Point(360, 135)); - mapobj.spawnMonsterOnGroundBelow(mobobj2, new Packages.java.awt.Point(360, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj1, new Point(360, 135)); + mapobj.spawnMonsterOnGroundBelow(mobobj2, new Point(360, 135)); } } diff --git a/scripts/event/MahaBattle.js b/scripts/event/MahaBattle.js index 6791f678ad..da67bdef82 100644 --- a/scripts/event/MahaBattle.js +++ b/scripts/event/MahaBattle.js @@ -33,7 +33,7 @@ var maxMapId = 914020000; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 7]; +const maxLobbies = 7; function init() {} diff --git a/scripts/event/OrbisPQ.js b/scripts/event/OrbisPQ.js index 326ce442f9..8d71fd512b 100644 --- a/scripts/event/OrbisPQ.js +++ b/scripts/event/OrbisPQ.js @@ -36,14 +36,14 @@ var maxMapId = 920011300; var eventTime = 45; // 45 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/PapulatusBattle.js b/scripts/event/PapulatusBattle.js index 6ff9c0dfd6..f75d082f30 100644 --- a/scripts/event/PapulatusBattle.js +++ b/scripts/event/PapulatusBattle.js @@ -36,14 +36,14 @@ var maxMapId = 220080001; var eventTime = 45; // 45 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/PinkBeanBattle.js b/scripts/event/PinkBeanBattle.js index 71f178f023..e9574c775c 100644 --- a/scripts/event/PinkBeanBattle.js +++ b/scripts/event/PinkBeanBattle.js @@ -23,9 +23,6 @@ * @event: Pink Bean Battle */ -importPackage(Packages.server.life); -importPackage(Packages.client.inventory); - var isPq = true; var minPlayers = 6, maxPlayers = 30; var minLevel = 120, maxLevel = 255; @@ -39,14 +36,14 @@ var maxMapId = 270050300; var eventTime = 140; // 140 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -104,10 +101,12 @@ function setup(channel) { eim.getInstanceMap(270050100).resetPQ(level); eim.getInstanceMap(270050200).resetPQ(level); eim.getInstanceMap(270050300).resetPQ(level); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(8820000); mob.disableDrops(); - eim.getInstanceMap(270050100).spawnMonsterOnGroundBelow(mob, new java.awt.Point(0, -42)); + eim.getInstanceMap(270050100).spawnMonsterOnGroundBelow(mob, new Point(0, -42)); eim.startEventTimer(eventTime * 60000); setEventRewards(eim); @@ -234,7 +233,8 @@ function spawnJrBoss(mobObj, gotKilled) { mobObj.getMap().killMonster(mobObj.getId()); spawnid = mobObj.getId() - 17; } - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); var mob = MapleLifeFactory.getMonster(spawnid); mobObj.getMap().spawnMonsterOnGroundBelow(mob, mobObj.getPosition()); } @@ -254,6 +254,7 @@ function monsterKilled(mob, eim) { if(stage == 5) { var iid = 4001193; + const Item = Java.type('client.inventory.Item'); var itemObj = new Item(iid, 0, 1); var mapObj = eim.getMapFactory().getMap(270050100); var reactObj = mapObj.getReactorById(2708000); diff --git a/scripts/event/PiratePQ.js b/scripts/event/PiratePQ.js index 89e857b9bb..8fdd9c0664 100644 --- a/scripts/event/PiratePQ.js +++ b/scripts/event/PiratePQ.js @@ -38,14 +38,14 @@ var maxMapId = 925100500; var eventTime = 4; // 4 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -90,7 +90,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/RescueGaga.js b/scripts/event/RescueGaga.js index dc9dd6b7c7..b1dbe077e6 100644 --- a/scripts/event/RescueGaga.js +++ b/scripts/event/RescueGaga.js @@ -3,8 +3,6 @@ * @author: Ronan */ -importPackage(Packages.tools); - var isPq = true; var minPlayers = 1, maxPlayers = 1; var minLevel = 12, maxLevel = 255; @@ -17,14 +15,14 @@ var maxMapId = 922240100; var eventTime = 3; // 3 minutes -var lobbyRange = [0, 19]; +const maxLobbies = 20; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -79,7 +77,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { @@ -102,7 +100,8 @@ function respawnStages(eim) {} function playerEntry(eim, player) { var map = eim.getMapInstance(entryMap); player.changeMap(map, map.getPortal(0)); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.announce(MaplePacketCreator.showEffect("event/space/start")); player.startMapEffect("Please rescue Gaga within the time limit.", 5120027); } @@ -199,7 +198,8 @@ function clearPQ(eim) { } function spawnGrandpaBunny(eim) { - eim.spawnNpc(9001105, new java.awt.Point(175, -20), eim.getInstanceMap(maxMapId)); + const Point = Java.type('java.awt.Point'); + eim.spawnNpc(9001105, new Point(175, -20), eim.getInstanceMap(maxMapId)); } function monsterKilled(mob, eim) {} diff --git a/scripts/event/RockSpirit.js b/scripts/event/RockSpirit.js index 9bd0726582..d7a8970269 100644 --- a/scripts/event/RockSpirit.js +++ b/scripts/event/RockSpirit.js @@ -19,8 +19,6 @@ along with this program. If not, see . */ -importPackage(Packages.tools); - var entryMap; var exitMap; var otherMap; diff --git a/scripts/event/RockSpiritVIP.js b/scripts/event/RockSpiritVIP.js index 60085fb57d..58cf3e9b72 100644 --- a/scripts/event/RockSpiritVIP.js +++ b/scripts/event/RockSpiritVIP.js @@ -19,8 +19,6 @@ along with this program. If not, see . */ -importPackage(Packages.tools); - var entryMap; var exitMap; var otherMap; diff --git a/scripts/event/ScargaBattle.js b/scripts/event/ScargaBattle.js index 450b794f49..13ebb023b9 100644 --- a/scripts/event/ScargaBattle.js +++ b/scripts/event/ScargaBattle.js @@ -36,14 +36,14 @@ var maxMapId = 551030200; var eventTime = 60; // 60 minutes for boss stg -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { diff --git a/scripts/event/ShowaBattle.js b/scripts/event/ShowaBattle.js index 789cb0b8ec..df316f8afc 100644 --- a/scripts/event/ShowaBattle.js +++ b/scripts/event/ShowaBattle.js @@ -36,14 +36,14 @@ var maxMapId = 801040101; var eventTime = 60; // 60 minutes for boss stg -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { diff --git a/scripts/event/Subway.js b/scripts/event/Subway.js index 0ddc29268f..9cd8d68ddd 100644 --- a/scripts/event/Subway.js +++ b/scripts/event/Subway.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var KC_Waiting; var Subway_to_KC; var KC_docked; @@ -38,6 +36,8 @@ function stopEntry() { } function takeoff() { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + //sound src: https://www.soundjay.com/transportation/metro-door-close-01.mp3 KC_docked.broadcastMessage(MaplePacketCreator.playSound("subway/whistle")); NLC_docked.broadcastMessage(MaplePacketCreator.playSound("subway/whistle")); @@ -52,7 +52,8 @@ function arrived() { Subway_to_KC.warpEveryone(KC_docked.getId(), 0); Subway_to_NLC.warpEveryone(NLC_docked.getId(), 0); scheduleNew(); - + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); KC_docked.broadcastMessage(MaplePacketCreator.playSound("subway/whistle")); NLC_docked.broadcastMessage(MaplePacketCreator.playSound("subway/whistle")); } diff --git a/scripts/event/TD_Battle1.js b/scripts/event/TD_Battle1.js index 8a315f875c..3ca55f6b37 100644 --- a/scripts/event/TD_Battle1.js +++ b/scripts/event/TD_Battle1.js @@ -38,14 +38,14 @@ var tdBossId = 7220005; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/TD_Battle2.js b/scripts/event/TD_Battle2.js index 288af85fe5..b893fe4949 100644 --- a/scripts/event/TD_Battle2.js +++ b/scripts/event/TD_Battle2.js @@ -38,14 +38,14 @@ var tdBossId = 8220010; var eventTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/TD_Battle3.js b/scripts/event/TD_Battle3.js index 6589961695..175deb3925 100644 --- a/scripts/event/TD_Battle3.js +++ b/scripts/event/TD_Battle3.js @@ -38,14 +38,14 @@ var tdBossId = 8220011; var eventTime = 15; // 15 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/TD_Battle4.js b/scripts/event/TD_Battle4.js index 6f8dee69d4..e7e3b15bd6 100644 --- a/scripts/event/TD_Battle4.js +++ b/scripts/event/TD_Battle4.js @@ -38,14 +38,14 @@ var tdBossId = 8220012; var eventTime = 15; // 15 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/TD_Battle5.js b/scripts/event/TD_Battle5.js index 53f0f2b88d..b5ecaf12d3 100644 --- a/scripts/event/TD_Battle5.js +++ b/scripts/event/TD_Battle5.js @@ -38,14 +38,14 @@ var tdBossId = 8220015; var eventTime = 20; // 20 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -100,7 +100,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/Trains.js b/scripts/event/Trains.js index 63a41ee2af..ae27b326fb 100644 --- a/scripts/event/Trains.js +++ b/scripts/event/Trains.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var Orbis_btf; var Train_to_Orbis; var Orbis_docked; diff --git a/scripts/event/TreasurePQ.js b/scripts/event/TreasurePQ.js index 5624044b7e..10c89e8757 100644 --- a/scripts/event/TreasurePQ.js +++ b/scripts/event/TreasurePQ.js @@ -37,14 +37,14 @@ var maxMapId = 674030300; var eventTime = 45; // 45 minutes var bonusTime = 10; // 10 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -99,7 +99,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/WeddingCathedral.js b/scripts/event/WeddingCathedral.js index 3bc5eacdf9..d052d9bb88 100644 --- a/scripts/event/WeddingCathedral.js +++ b/scripts/event/WeddingCathedral.js @@ -44,12 +44,12 @@ var forceHideMsgTime = 10; // unfortunately, EIM weddings don't send wedding ta var eventBoss = true; // spawns a Cake boss at the hunting ground var isCathedral = true; -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() {} -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventExclusives(eim) { @@ -71,9 +71,11 @@ function setEventRewards(eim) { function spawnCakeBoss(eim) { var mapObj = eim.getMapInstance(680000400); - var mobObj = Packages.server.life.MapleLifeFactory.getMonster(9400606); - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(777, -177)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + var mobObj = MapleLifeFactory.getMonster(9400606); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(777, -177)); } function setup(level, lobbyid) { @@ -125,10 +127,11 @@ function stopBlessings(eim) { function sendWeddingAction(eim, type) { var chr = eim.getLeader(); + const Wedding = Java.type('tools.packets.Wedding'); if(chr.getGender() == 0) { - chr.getMap().broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("groomId"), eim.getIntProperty("brideId"), type + 1)); + chr.getMap().broadcastMessage(Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("groomId"), eim.getIntProperty("brideId"), type + 1)); } else { - chr.getMap().broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("brideId"), eim.getIntProperty("groomId"), type + 1)); + chr.getMap().broadcastMessage(Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("brideId"), eim.getIntProperty("groomId"), type + 1)); } } @@ -137,12 +140,14 @@ function hidePriestMsg(eim) { } function showStartMsg(eim) { - eim.getMapInstance(entryMap + 10).broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(false, 0, 0, 0)); + const Wedding = Java.type('tools.packets.Wedding'); + eim.getMapInstance(entryMap + 10).broadcastMessage(Wedding.OnWeddingProgress(false, 0, 0, 0)); eim.schedule("hidePriestMsg", forceHideMsgTime * 1000); } function showBlessMsg(eim) { - eim.getMapInstance(entryMap + 10).broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(false, 0, 0, 1)); + const Wedding = Java.type('tools.packets.Wedding'); + eim.getMapInstance(entryMap + 10).broadcastMessage(Wedding.OnWeddingProgress(false, 0, 0, 1)); eim.setIntProperty("guestBlessings", 1); eim.schedule("hidePriestMsg", forceHideMsgTime * 1000); } diff --git a/scripts/event/WeddingChapel.js b/scripts/event/WeddingChapel.js index 4b53b39df6..0cd6b8407f 100644 --- a/scripts/event/WeddingChapel.js +++ b/scripts/event/WeddingChapel.js @@ -44,12 +44,12 @@ var forceHideMsgTime = 10; // unfortunately, EIM weddings don't send wedding ta var eventBoss = true; // spawns a Cake boss at the hunting ground var isCathedral = false; -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() {} -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventExclusives(eim) { @@ -71,9 +71,11 @@ function setEventRewards(eim) { function spawnCakeBoss(eim) { var mapObj = eim.getMapInstance(680000400); - var mobObj = Packages.server.life.MapleLifeFactory.getMonster(9400606); - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(777, -177)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + var mobObj = MapleLifeFactory.getMonster(9400606); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(777, -177)); } function setup(level, lobbyid) { @@ -125,10 +127,12 @@ function stopBlessings(eim) { function sendWeddingAction(eim, type) { var chr = eim.getLeader(); + + const Wedding = Java.type('tools.packets.Wedding'); if(chr.getGender() == 0) { - chr.getMap().broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("groomId"), eim.getIntProperty("brideId"), type + 1)); + chr.getMap().broadcastMessage(Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("groomId"), eim.getIntProperty("brideId"), type + 1)); } else { - chr.getMap().broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("brideId"), eim.getIntProperty("groomId"), type + 1)); + chr.getMap().broadcastMessage(Wedding.OnWeddingProgress(type == 2, eim.getIntProperty("brideId"), eim.getIntProperty("groomId"), type + 1)); } } @@ -137,12 +141,14 @@ function hidePriestMsg(eim) { } function showStartMsg(eim) { - eim.getMapInstance(entryMap + 10).broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(false, 0, 0, 0)); + const Wedding = Java.type('tools.packets.Wedding'); + eim.getMapInstance(entryMap + 10).broadcastMessage(Wedding.OnWeddingProgress(false, 0, 0, 0)); eim.schedule("hidePriestMsg", forceHideMsgTime * 1000); } function showBlessMsg(eim) { - eim.getMapInstance(entryMap + 10).broadcastMessage(Packages.tools.packets.Wedding.OnWeddingProgress(false, 0, 0, 1)); + const Wedding = Java.type('tools.packets.Wedding'); + eim.getMapInstance(entryMap + 10).broadcastMessage(Wedding.OnWeddingProgress(false, 0, 0, 1)); eim.setIntProperty("guestBlessings", 1); eim.schedule("hidePriestMsg", forceHideMsgTime * 1000); } diff --git a/scripts/event/ZakumBattle.js b/scripts/event/ZakumBattle.js index 0df9871263..0f370faf3a 100644 --- a/scripts/event/ZakumBattle.js +++ b/scripts/event/ZakumBattle.js @@ -23,8 +23,6 @@ * @event: Zakum Battle */ -importPackage(Packages.server.life); - var isPq = true; var minPlayers = 6, maxPlayers = 30; var minLevel = 50, maxLevel = 255; @@ -38,14 +36,14 @@ var maxMapId = 280030000; var eventTime = 120; // 120 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { diff --git a/scripts/event/ZakumPQ.js b/scripts/event/ZakumPQ.js index 9f69ca4476..a823ab16cf 100644 --- a/scripts/event/ZakumPQ.js +++ b/scripts/event/ZakumPQ.js @@ -36,14 +36,14 @@ var maxMapId = 280011006; var eventTime = 30; // 30 minutes -var lobbyRange = [0, 0]; +const maxLobbies = 1; function init() { setEventRequirements(); } -function setLobbyRange() { - return lobbyRange; +function getMaxLobbies() { + return maxLobbies; } function setEventRequirements() { @@ -98,7 +98,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers && eligible.length <= maxPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/event/s4aWorld.js b/scripts/event/s4aWorld.js index 24867aaa3b..d14de547c7 100644 --- a/scripts/event/s4aWorld.js +++ b/scripts/event/s4aWorld.js @@ -30,7 +30,7 @@ function getEligibleParty(party) { //selects, from the given party, the tea } if(!(hasLeader && eligible.length >= minPlayers)) eligible = []; - return eligible; + return Java.to(eligible, Java.type('net.server.world.MaplePartyCharacter[]')); } function setup(level, lobbyid) { diff --git a/scripts/map/onUserEnter/100000006.js b/scripts/map/onUserEnter/100000006.js index 0c7e9cb355..b518cd8c62 100644 --- a/scripts/map/onUserEnter/100000006.js +++ b/scripts/map/onUserEnter/100000006.js @@ -1,5 +1,3 @@ -importPackage(Packages.server.life); - function start(ms){ if(ms.getQuestStatus(2175) == 1){ @@ -11,6 +9,8 @@ function start(ms){ return; } - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(-1027, 216)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(-1027, 216)); } } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010101.js b/scripts/map/onUserEnter/108010101.js index b6192327ac..f4d843eb71 100644 --- a/scripts/map/onUserEnter/108010101.js +++ b/scripts/map/onUserEnter/108010101.js @@ -1,6 +1,4 @@ -importPackage(Packages.server.life); - -function start(ms) { +function start(ms) { if(ms.getMapId() == 108010101) { // Archer spawnMob(188, 20, 9001002, ms.getPlayer().getMap()); } else if(ms.getMapId() == 108010301) { // Warrior @@ -17,7 +15,9 @@ function start(ms) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010201.js b/scripts/map/onUserEnter/108010201.js index b6192327ac..f4d843eb71 100644 --- a/scripts/map/onUserEnter/108010201.js +++ b/scripts/map/onUserEnter/108010201.js @@ -1,6 +1,4 @@ -importPackage(Packages.server.life); - -function start(ms) { +function start(ms) { if(ms.getMapId() == 108010101) { // Archer spawnMob(188, 20, 9001002, ms.getPlayer().getMap()); } else if(ms.getMapId() == 108010301) { // Warrior @@ -17,7 +15,9 @@ function start(ms) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010301.js b/scripts/map/onUserEnter/108010301.js index b6192327ac..f4d843eb71 100644 --- a/scripts/map/onUserEnter/108010301.js +++ b/scripts/map/onUserEnter/108010301.js @@ -1,6 +1,4 @@ -importPackage(Packages.server.life); - -function start(ms) { +function start(ms) { if(ms.getMapId() == 108010101) { // Archer spawnMob(188, 20, 9001002, ms.getPlayer().getMap()); } else if(ms.getMapId() == 108010301) { // Warrior @@ -17,7 +15,9 @@ function start(ms) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010401.js b/scripts/map/onUserEnter/108010401.js index b6192327ac..f4d843eb71 100644 --- a/scripts/map/onUserEnter/108010401.js +++ b/scripts/map/onUserEnter/108010401.js @@ -1,6 +1,4 @@ -importPackage(Packages.server.life); - -function start(ms) { +function start(ms) { if(ms.getMapId() == 108010101) { // Archer spawnMob(188, 20, 9001002, ms.getPlayer().getMap()); } else if(ms.getMapId() == 108010301) { // Warrior @@ -17,7 +15,9 @@ function start(ms) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010501.js b/scripts/map/onUserEnter/108010501.js index b6192327ac..f4d843eb71 100644 --- a/scripts/map/onUserEnter/108010501.js +++ b/scripts/map/onUserEnter/108010501.js @@ -1,6 +1,4 @@ -importPackage(Packages.server.life); - -function start(ms) { +function start(ms) { if(ms.getMapId() == 108010101) { // Archer spawnMob(188, 20, 9001002, ms.getPlayer().getMap()); } else if(ms.getMapId() == 108010301) { // Warrior @@ -17,7 +15,9 @@ function start(ms) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/108010600.js b/scripts/map/onUserEnter/108010600.js index 6d052cbc76..960ae7fe10 100644 --- a/scripts/map/onUserEnter/108010600.js +++ b/scripts/map/onUserEnter/108010600.js @@ -19,7 +19,8 @@ */ var npcid = 1104100; -var spawnPos = new Packages.java.awt.Point(2830, 78); +const Point = Java.type('java.awt.Point'); +var spawnPos = new Point(2830, 78); function start(ms) { var mapobj = ms.getMap(); diff --git a/scripts/map/onUserEnter/108010610.js b/scripts/map/onUserEnter/108010610.js index 2ec610e06c..e33a76dc87 100644 --- a/scripts/map/onUserEnter/108010610.js +++ b/scripts/map/onUserEnter/108010610.js @@ -19,7 +19,8 @@ */ var npcid = 1104101; -var spawnPos = new Packages.java.awt.Point(3395, -322); +const Point = Java.type('java.awt.Point'); +var spawnPos = new Point(3395, -322); function start(ms) { var mapobj = ms.getMap(); diff --git a/scripts/map/onUserEnter/108010620.js b/scripts/map/onUserEnter/108010620.js index 1857cb2d51..db35223e49 100644 --- a/scripts/map/onUserEnter/108010620.js +++ b/scripts/map/onUserEnter/108010620.js @@ -19,7 +19,8 @@ */ var npcid = 1104102; -var spawnPos = new Packages.java.awt.Point(500, -522); +const Point = Java.type('java.awt.Point'); +var spawnPos = new Point(500, -522); function start(ms) { var mapobj = ms.getMap(); diff --git a/scripts/map/onUserEnter/108010630.js b/scripts/map/onUserEnter/108010630.js index 9fa161fb75..325c893061 100644 --- a/scripts/map/onUserEnter/108010630.js +++ b/scripts/map/onUserEnter/108010630.js @@ -19,7 +19,8 @@ */ var npcid = 1104103; -var spawnPos = new Packages.java.awt.Point(-2263, -582); +const Point = Java.type('java.awt.Point'); +var spawnPos = new Point(-2263, -582); function start(ms) { var mapobj = ms.getMap(); diff --git a/scripts/map/onUserEnter/108010640.js b/scripts/map/onUserEnter/108010640.js index 3fc2fbb334..b57b1715ff 100644 --- a/scripts/map/onUserEnter/108010640.js +++ b/scripts/map/onUserEnter/108010640.js @@ -19,7 +19,8 @@ */ var npcid = 1104104; -var spawnPos = new Packages.java.awt.Point(372, 70); +const Point = Java.type('java.awt.Point'); +var spawnPos = new Point(372, 70); function start(ms) { var mapobj = ms.getMap(); diff --git a/scripts/map/onUserEnter/200090000.js b/scripts/map/onUserEnter/200090000.js index 0a346311d3..22fd6156a5 100644 --- a/scripts/map/onUserEnter/200090000.js +++ b/scripts/map/onUserEnter/200090000.js @@ -1,15 +1,14 @@ // Author: Ronan -importPackage(Packages.tools); - var mapId = 200090000; function start(ms) { var map = ms.getClient().getChannelServer().getMapFactory().getMap(mapId); if(map.getDocked()) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); ms.getClient().announce(MaplePacketCreator.musicChange("Bgm04/ArabPirate")); ms.getClient().announce(MaplePacketCreator.crogBoatPacket(true)); } - return(true); + return true; } \ No newline at end of file diff --git a/scripts/map/onUserEnter/200090010.js b/scripts/map/onUserEnter/200090010.js index bf114d894f..b72a54b86f 100644 --- a/scripts/map/onUserEnter/200090010.js +++ b/scripts/map/onUserEnter/200090010.js @@ -1,15 +1,14 @@ // Author: Ronan -importPackage(Packages.tools); - var mapId = 200090010; function start(ms) { var map = ms.getClient().getChannelServer().getMapFactory().getMap(mapId); if(map.getDocked()) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); ms.getClient().announce(MaplePacketCreator.musicChange("Bgm04/ArabPirate")); ms.getClient().announce(MaplePacketCreator.crogBoatPacket(true)); } - return(true); + return true; } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000001.js b/scripts/map/onUserEnter/677000001.js index 4e04309277..d8f70ac43f 100644 --- a/scripts/map/onUserEnter/677000001.js +++ b/scripts/map/onUserEnter/677000001.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(461, 61); + const Point = Java.type('java.awt.Point'); + var pos = new Point(461, 61); var mobId = 9400612; - var mobName = "Marbas"; + var mobName = "Marbas"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000003.js b/scripts/map/onUserEnter/677000003.js index f4f036aece..706dcb82e3 100644 --- a/scripts/map/onUserEnter/677000003.js +++ b/scripts/map/onUserEnter/677000003.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(467, 0); + const Point = Java.type('java.awt.Point'); + var pos = new Point(467, 0); var mobId = 9400610; - var mobName = "Amdusias"; + var mobName = "Amdusias"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000005.js b/scripts/map/onUserEnter/677000005.js index 81ce286bb8..1c2bf6e8ab 100644 --- a/scripts/map/onUserEnter/677000005.js +++ b/scripts/map/onUserEnter/677000005.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(201, 80); + const Point = Java.type('java.awt.Point'); + var pos = new Point(201, 80); var mobId = 9400609; - var mobName = "Andras"; + var mobName = "Andras"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000007.js b/scripts/map/onUserEnter/677000007.js index d52195b309..82201272d2 100644 --- a/scripts/map/onUserEnter/677000007.js +++ b/scripts/map/onUserEnter/677000007.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(171, 50); + const Point = Java.type('java.awt.Point'); + var pos = new Point(171, 50); var mobId = 9400611; - var mobName = "Crocell"; + var mobName = "Crocell"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000009.js b/scripts/map/onUserEnter/677000009.js index 23969e4b4b..10b8d80202 100644 --- a/scripts/map/onUserEnter/677000009.js +++ b/scripts/map/onUserEnter/677000009.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(251, -841); + const Point = Java.type('java.awt.Point'); + var pos = new Point(251, -841); var mobId = 9400613; - var mobName = "Valefor"; + var mobName = "Valefor"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000012.js b/scripts/map/onUserEnter/677000012.js index 06180624c9..8e02c37a80 100644 --- a/scripts/map/onUserEnter/677000012.js +++ b/scripts/map/onUserEnter/677000012.js @@ -1,9 +1,8 @@ -importPackage(Packages.server.life); - function start(ms) { - var pos = new java.awt.Point(842, 0); + const Point = Java.type('java.awt.Point'); + var pos = new Point(842, 0); var mobId = 9400633; - var mobName = "Astaroth"; + var mobName = "Astaroth"; var player = ms.getPlayer(); var map = player.getMap(); @@ -12,6 +11,7 @@ function start(ms) { return; } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/910510000.js b/scripts/map/onUserEnter/910510000.js index 51e18daa4b..a3373b5dd8 100644 --- a/scripts/map/onUserEnter/910510000.js +++ b/scripts/map/onUserEnter/910510000.js @@ -1,16 +1,16 @@ -importPackage(Packages.server.life); +function start(ms) { + var player = ms.getPlayer(); + var map = player.getMap(); -function start(ms){ - var player = ms.getPlayer(); - var map = player.getMap(); - - if(player.isCygnus()) { - if(ms.isQuestStarted(20730) && ms.getQuestProgressInt(20730, 9300285) == 0) { - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300285), new java.awt.Point(680, 258)); - } - } else { - if(ms.isQuestStarted(21731) && ms.getQuestProgressInt(21731, 9300344) == 0) { - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300344), new java.awt.Point(680, 258)); - } + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + if (player.isCygnus()) { + if (ms.isQuestStarted(20730) && ms.getQuestProgressInt(20730, 9300285) == 0) { + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300285), new Point(680, 258)); } + } else { + if (ms.isQuestStarted(21731) && ms.getQuestProgressInt(21731, 9300344) == 0) { + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300344), new Point(680, 258)); + } + } } \ No newline at end of file diff --git a/scripts/map/onUserEnter/925040100.js b/scripts/map/onUserEnter/925040100.js index 738b9c75ac..1ac603c642 100644 --- a/scripts/map/onUserEnter/925040100.js +++ b/scripts/map/onUserEnter/925040100.js @@ -1,10 +1,10 @@ -importPackage(Packages.server.life); - function start(ms){ var player = ms.getPlayer(); var map = player.getMap(); if(ms.isQuestStarted(21747) && ms.getQuestProgressInt(21747, 9300351) == 0) { - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300351), new java.awt.Point(897, 51)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300351), new Point(897, 51)); } } \ No newline at end of file diff --git a/scripts/map/onUserEnter/pepeking_effect.js b/scripts/map/onUserEnter/pepeking_effect.js index 5fd8439196..78df65aa76 100644 --- a/scripts/map/onUserEnter/pepeking_effect.js +++ b/scripts/map/onUserEnter/pepeking_effect.js @@ -1,9 +1,9 @@ -importPackage(Packages.server.life); - function start(ms){ var mobId = 3300000 + (Math.floor(Math.random() * 3) + 5); var player = ms.getPlayer(); var map = player.getMap(); - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(-28, -67)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(-28, -67)); } \ No newline at end of file diff --git a/scripts/npc/1012100.js b/scripts/npc/1012100.js index 5d44d1e5f1..698ba0031f 100644 --- a/scripts/npc/1012100.js +++ b/scripts/npc/1012100.js @@ -34,7 +34,8 @@ spawnPnpcFee = 7000000; jobType = 3; function start() { - if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -92,8 +93,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/1022000.js b/scripts/npc/1022000.js index ccea9025d8..8e0ad6d308 100644 --- a/scripts/npc/1022000.js +++ b/scripts/npc/1022000.js @@ -35,7 +35,8 @@ spawnPnpcFee = 7000000; jobType = 1; function start() { - if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -93,8 +94,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/1022101_old.js b/scripts/npc/1022101_old.js index e4cbe1975e..63a593d8c8 100644 --- a/scripts/npc/1022101_old.js +++ b/scripts/npc/1022101_old.js @@ -115,7 +115,8 @@ function action(mode, type, selection) { var useVP = false; if(!cm.hasItem(itemToUse) && vp > 0) useVP = true; - + + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); if(choice == 0) { // VP Exchange if(!cm.canHold(itemToUse)) { @@ -135,11 +136,12 @@ function action(mode, type, selection) { cm.gainItem(itemToUse, -1); cm.getPlayer().getCashShop().gainCash(1, nxAmount); - cm.getPlayer().announce(Packages.tools.MaplePacketCreator.earnTitleMessage("You have earned " + nxAmount + " NX")); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + cm.getPlayer().announce(MaplePacketCreator.earnTitleMessage("You have earned " + nxAmount + " NX")); cm.logLeaf(nxAmount + " NX"); cm.dispose(); } else if(choice == 2) { - if(!cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.SETUP).isFull(chairAmount)) { + if(!cm.getPlayer().getInventory(MapleInventoryType.SETUP).isFull(chairAmount)) { var chairStr = ""; for(var i = 0; i < chairAmount; i++) { @@ -159,7 +161,7 @@ function action(mode, type, selection) { cm.sendOk("Please make sure you have enough space to hold the items!"); } } else if(choice == 3) { - if(!cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.EQUIP).isFull(weaponAmount)) { + if(!cm.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull(weaponAmount)) { var weaponStr = ""; for(var i = 0; i < weaponAmount; i++) { @@ -179,7 +181,7 @@ function action(mode, type, selection) { cm.sendOk("Please make sure you have enough space to hold the items!"); } } else if(choice == 4) { - if(!cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).isFull(2)) { + if(!cm.getPlayer().getInventory(MapleInventoryType.USE).isFull(2)) { cm.gainItem(buff1ID, buffAmount, true); cm.gainItem(buff2ID, buffAmount, true); cm.gainItem(itemToUse, -1); @@ -190,7 +192,7 @@ function action(mode, type, selection) { } } else if(choice == 5) { if(!cm.haveItem(5030000, 1)) { - if(!cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.CASH).isFull(1)){ + if(!cm.getPlayer().getInventory(MapleInventoryType.CASH).isFull(1)){ cm.gainItem(5030000, 1, false, true, 1000 * 60 * 60 * 24 * hiredMerchantLength); if(useVP) diff --git a/scripts/npc/1032001.js b/scripts/npc/1032001.js index c10656286c..2aad6ef6b4 100644 --- a/scripts/npc/1032001.js +++ b/scripts/npc/1032001.js @@ -35,7 +35,8 @@ spawnPnpcFee = 7000000; jobType = 2; function start() { - if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -93,8 +94,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/1032102.js b/scripts/npc/1032102.js index f21adf1da7..d63a19f77e 100644 --- a/scripts/npc/1032102.js +++ b/scripts/npc/1032102.js @@ -9,10 +9,6 @@ Dragon Evolver */ -importPackage(Packages.client.inventory); -importPackage(Packages.client.inventory.manipulator); -importPackage(Packages.server); - var status; function start() { @@ -105,6 +101,8 @@ function action(mode, type, selection) { } } else if (status == 2) { if (selection == 0) { + const MapleInventoryManipulator = Java.type('client.inventory.manipulator.MapleInventoryManipulator'); + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); MapleInventoryManipulator.removeFromSlot(cm.getClient(), MapleInventoryType.CASH, 1, 1, true); cm.sendOk("Your cash first slot is removed."); } else if (selection == 1) { diff --git a/scripts/npc/1032109.js b/scripts/npc/1032109.js index a21274ad52..450b9f56f8 100644 --- a/scripts/npc/1032109.js +++ b/scripts/npc/1032109.js @@ -3,7 +3,6 @@ MAP: Hidden Street - Magic Library (910110000) QUEST: Maybe it's Grendel! (20718) */ -importPackage(Packages.server.life); var status; var mobId = 2220100; //Blue Mushroom @@ -36,12 +35,14 @@ function action(mode, type, selection){ var player = cm.getPlayer(); var map = player.getMap(); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); for(var i = 0; i < 10; i++) - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(117, 183)); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(117, 183)); for(var i = 0; i < 10; i++) - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(4, 183)); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(4, 183)); for(var i = 0; i < 10; i++) - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(-109, 183)); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new Point(-109, 183)); cm.completeQuest(20718, 1103003); cm.gainExp(4000 * cm.getPlayer().getExpRate()); diff --git a/scripts/npc/1052001.js b/scripts/npc/1052001.js index 9ab5b9f37d..090f7ebc02 100644 --- a/scripts/npc/1052001.js +++ b/scripts/npc/1052001.js @@ -34,7 +34,8 @@ spawnPnpcFee = 7000000; jobType = 4; function start() { - if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -94,8 +95,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/1052115.js b/scripts/npc/1052115.js index 43cc74e55d..43644d2d90 100644 --- a/scripts/npc/1052115.js +++ b/scripts/npc/1052115.js @@ -1,6 +1,5 @@ var status = 0; var section = 0; -importPackage(java.lang); //questid 29931, infoquest 7662 function start() { diff --git a/scripts/npc/1061014.js b/scripts/npc/1061014.js index d5fb6da0f1..0ac0837bc1 100644 --- a/scripts/npc/1061014.js +++ b/scripts/npc/1061014.js @@ -23,16 +23,13 @@ *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); - var status = 0; var expedition; var expedMembers; var player; var em; -var exped = MapleExpeditionType.BALROG_NORMAL; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); +const exped = MapleExpeditionType.BALROG_NORMAL; var expedName = "Balrog"; var expedBoss = "Balrog"; var expedMap = "Balrog's Tomb"; @@ -159,6 +156,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #b" + expedMap + "#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/1063000.js b/scripts/npc/1063000.js index ba1248310b..8fe5582c07 100644 --- a/scripts/npc/1063000.js +++ b/scripts/npc/1063000.js @@ -34,7 +34,8 @@ function start() { cm.gainItem(4031025,10); } else { - if(cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(cm.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() < 1) { cm.sendNext("Check for a available slot on your ETC inventory."); cm.dispose(); return; diff --git a/scripts/npc/1063001.js b/scripts/npc/1063001.js index 2d4f3fad09..f5b3d1ca3f 100644 --- a/scripts/npc/1063001.js +++ b/scripts/npc/1063001.js @@ -34,7 +34,8 @@ function start() { cm.gainItem(4031026,20); } else { - if(cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(cm.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() < 1) { cm.sendNext("Check for a available slot on your ETC inventory."); cm.dispose(); return; diff --git a/scripts/npc/1063002.js b/scripts/npc/1063002.js index 4b27a9bcd1..18aaf916ce 100644 --- a/scripts/npc/1063002.js +++ b/scripts/npc/1063002.js @@ -34,7 +34,8 @@ function start() { cm.gainItem(4031028,30); } else { - if(cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(cm.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() < 1) { cm.sendNext("Check for a available slot on your ETC inventory."); cm.dispose(); return; diff --git a/scripts/npc/1063017.js b/scripts/npc/1063017.js index f31b772a52..1597b528ad 100644 --- a/scripts/npc/1063017.js +++ b/scripts/npc/1063017.js @@ -29,8 +29,10 @@ function action(mode, type, selection) { if(cm.getClient().getChannelServer().getMapFactory().getMap(925020010).getCharacters().size() > 0) { cm.sendOk("Someone is already challenging the Master. Try again later."); } else { - cm.getWarpMap(910510202).spawnMonsterOnGroundBelow(Packages.server.life.MapleLifeFactory.getMonster(9300346), new java.awt.Point(95, 200)); - cm.warp(910510202, 0); + const MapleLifeFactoroy = Java.type('server.life.MapleLifeFactoroy'); + const Point = Java.type('java.awt.Point'); + cm.getWarpMap(910510202).spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300346), new Point(95, 200)); + cm.warp(910510202, 0); } cm.dispose(); diff --git a/scripts/npc/1090000.js b/scripts/npc/1090000.js index 9ddce6bbbd..bb12416503 100644 --- a/scripts/npc/1090000.js +++ b/scripts/npc/1090000.js @@ -35,6 +35,7 @@ jobType = 5; var advQuest = 0; function start() { + const GameConstants = Java.type('constants.game.GameConstants'); if (cm.isQuestStarted(6330)) { if (cm.getEventInstance() != null) { // missing script for skill test found thanks to Jade™ advQuest = 5; // string visibility thanks to iPunchEm & Glvelturall @@ -63,7 +64,7 @@ function start() { cm.sendNext("Congratulations. You have managed to pass my test. I'll teach you a new skill called \"Battleship\".\r\n\r\n #s5221006# #b#q5221006##k"); } - } else if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + } else if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -141,8 +142,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/11000.js b/scripts/npc/11000.js index 36f780f994..a787830c55 100644 --- a/scripts/npc/11000.js +++ b/scripts/npc/11000.js @@ -19,6 +19,7 @@ */ function start() { - Packages.server.MapleShopFactory.getInstance().getShop(11000).sendShop(cm.getClient()); + const MapleShopFactory = Java.type('server.MapleShopFactory'); + MapleShopFactory.getInstance().getShop(11000).sendShop(cm.getClient()); cm.dispose(); } diff --git a/scripts/npc/1101001.js b/scripts/npc/1101001.js index 138d871853..c9947c92f5 100644 --- a/scripts/npc/1101001.js +++ b/scripts/npc/1101001.js @@ -3,9 +3,9 @@ Map(s): Erev Description: 3rd job KoC Buff */ -importPackage(Packages.constants.game); function start() { + const GameConstants = Java.type('constants.game.GameConstants'); if (cm.getPlayer().isCygnus() && GameConstants.getJobBranch(cm.getJob()) > 2) { cm.useItem(2022458); cm.sendOk("Let me cast you my blessings, my Knight. Please protect the world of Maple...."); diff --git a/scripts/npc/1102003.js b/scripts/npc/1102003.js index eb9c59c847..f1fe369d80 100644 --- a/scripts/npc/1102003.js +++ b/scripts/npc/1102003.js @@ -33,7 +33,8 @@ var maxJobType = 15; function start() { var jobType = parseInt(cm.getJobId() / 100); - if (jobType >= minJobType && jobType <= maxJobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (jobType >= minJobType && jobType <= maxJobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -63,8 +64,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/1104002.js b/scripts/npc/1104002.js index 6c486cb10f..52134cb4cc 100644 --- a/scripts/npc/1104002.js +++ b/scripts/npc/1104002.js @@ -33,8 +33,10 @@ function action(mode, type, selection) { if (mode == 0 && type > 0) { cm.getPlayer().dropMessage(5, "Eleanor: Oh, lost the Empress and still challenging us? Now you've done it! Prepare yourself!!!"); - - mapobj.spawnMonsterOnGroundBelow(Packages.server.life.MapleLifeFactory.getMonster(9001010), new Packages.java.awt.Point(850, 0)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + mapobj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9001010), new Point(850, 0)); mapobj.destroyNPC(1104002); cm.dispose(); diff --git a/scripts/npc/1104100.js b/scripts/npc/1104100.js index c06a406909..4a0a663049 100644 --- a/scripts/npc/1104100.js +++ b/scripts/npc/1104100.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - var npcid = 1104100; var baseJob = 11; var status; @@ -64,7 +62,9 @@ function action(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/1104101.js b/scripts/npc/1104101.js index 5f5583723b..b6be6958fe 100644 --- a/scripts/npc/1104101.js +++ b/scripts/npc/1104101.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - var npcid = 1104101; var baseJob = 12; var status; @@ -64,7 +62,9 @@ function action(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/1104102.js b/scripts/npc/1104102.js index 1cfb03eabc..c78f05607e 100644 --- a/scripts/npc/1104102.js +++ b/scripts/npc/1104102.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - var npcid = 1104102; var baseJob = 13; var status; @@ -64,7 +62,9 @@ function action(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/1104103.js b/scripts/npc/1104103.js index c714175c66..1ad5d6543a 100644 --- a/scripts/npc/1104103.js +++ b/scripts/npc/1104103.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - var npcid = 1104103; var baseJob = 14; var status; @@ -64,7 +62,9 @@ function action(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/1104104.js b/scripts/npc/1104104.js index aa95603b72..5ee093086f 100644 --- a/scripts/npc/1104104.js +++ b/scripts/npc/1104104.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - var npcid = 1104104; var baseJob = 15; var status; @@ -64,7 +62,9 @@ function action(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/1202010.js b/scripts/npc/1202010.js index 0978526cdf..f8d05c995c 100644 --- a/scripts/npc/1202010.js +++ b/scripts/npc/1202010.js @@ -5,7 +5,8 @@ var spawnPnpcFee = 7000000; var jobType = 21; function start() { - if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()))) { + const GameConstants = Java.type('constants.game.GameConstants'); + if (parseInt(cm.getJobId() / 100) == jobType && cm.canSpawnPlayerNpc(GameConstants.getHallOfFameMapid(cm.getJob()))) { spawnPnpc = true; var sendStr = "You have walked a long way to reach the power, wisdom and courage you hold today, haven't you? What do you say about having right now #ra NPC on the Hall of Fame holding the current image of your character#k? Do you like it?"; @@ -35,8 +36,10 @@ function action(mode, type, selection) { cm.dispose(); return; } - - if(Packages.server.life.MaplePlayerNPC.spawnPlayerNPC(Packages.constants.game.GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { + + const MaplePlayerNPC = Java.type('server.life.MaplePlayerNPC'); + const GameConstants = Java.type('constants.game.GameConstants'); + if(MaplePlayerNPC.spawnPlayerNPC(GameConstants.getHallOfFameMapid(cm.getJob()), cm.getPlayer())) { cm.sendOk("There you go! Hope you will like it."); cm.gainMeso(-spawnPnpcFee); } else { diff --git a/scripts/npc/2012027.js b/scripts/npc/2012027.js index 9c32b31421..6d78795cd2 100644 --- a/scripts/npc/2012027.js +++ b/scripts/npc/2012027.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'C'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { @@ -54,7 +53,7 @@ function action(mode, type, selection) { if(idx > -1) { var nextNote = harpSong[idx]; - + if(harpNote != nextNote) { cm.setQuestProgress(3114, 0); diff --git a/scripts/npc/2012028.js b/scripts/npc/2012028.js index 960dad19f9..43627b8b8a 100644 --- a/scripts/npc/2012028.js +++ b/scripts/npc/2012028.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'D'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -45,8 +43,9 @@ function action(mode, type, selection) { status++; else status--; - + if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2012029.js b/scripts/npc/2012029.js index 3a242c3659..9b5a7ab270 100644 --- a/scripts/npc/2012029.js +++ b/scripts/npc/2012029.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'E'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2012030.js b/scripts/npc/2012030.js index 05a7120a4f..c7a6590218 100644 --- a/scripts/npc/2012030.js +++ b/scripts/npc/2012030.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'F'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2012031.js b/scripts/npc/2012031.js index 71af8dd7db..3420643eaf 100644 --- a/scripts/npc/2012031.js +++ b/scripts/npc/2012031.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'G'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2012032.js b/scripts/npc/2012032.js index d0d33d06ee..3c39a2493b 100644 --- a/scripts/npc/2012032.js +++ b/scripts/npc/2012032.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'A'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2012033.js b/scripts/npc/2012033.js index a70af27e4f..35499c3a28 100644 --- a/scripts/npc/2012033.js +++ b/scripts/npc/2012033.js @@ -21,8 +21,6 @@ Hidden Street - Eliza’s Garden (200010303) */ -importPackage(Packages.tools); - var status; var harpNote = 'B'; var harpSounds = ["do", "re", "mi", "pa", "sol", "la", "si"]; // musical order detected thanks to Arufonsu @@ -47,6 +45,7 @@ function action(mode, type, selection) { status--; if(status == 0) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getMap().broadcastMessage(MaplePacketCreator.playSound("orbis/" + harpSounds[cm.getNpc() - 2012027])); if(cm.isQuestStarted(3114)) { diff --git a/scripts/npc/2020008.js b/scripts/npc/2020008.js index dcaec7b027..58e8e81a94 100644 --- a/scripts/npc/2020008.js +++ b/scripts/npc/2020008.js @@ -142,7 +142,8 @@ function action(mode, type, selection){ if (cm.getPlayer().getLevel() >= 50){ cm.sendOk("The Chief's Residence Council grants you #bconcession#k to make part of the #rcounteroffensive team against Zakum#k. Good luck on your journey ahead."); if(!(cm.isQuestStarted(100200) || cm.isQuestCompleted(100200))) cm.startQuest(100200); - if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); + const YamlConfig = Java.type('config.YamlConfig'); + if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); }else cm.sendOk("You're way too weak to make part of the #rcounteroffensive team against Zakum#k. Reach at least #blevel 50#k, then talk to me."); cm.dispose(); diff --git a/scripts/npc/2020009.js b/scripts/npc/2020009.js index 17273222ae..ba0310fbcd 100644 --- a/scripts/npc/2020009.js +++ b/scripts/npc/2020009.js @@ -114,7 +114,8 @@ function action(mode, type, selection){ if (cm.getPlayer().getLevel() >= 50){ cm.sendOk("The Chief's Residence Council grants you #bconcession#k to make part of the #rcounteroffensive team against Zakum#k. Good luck on your journey ahead."); if(!(cm.isQuestStarted(100200) || cm.isQuestCompleted(100200))) cm.startQuest(100200); - if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); + const YamlConfig = Java.type('config.YamlConfig'); + if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); }else cm.sendOk("You're way too weak to make part of the #rcounteroffensive team against Zakum#k. Reach at least #blevel 50#k, then talk to me."); cm.dispose(); diff --git a/scripts/npc/2020010.js b/scripts/npc/2020010.js index 7716da2276..fbfa3def39 100644 --- a/scripts/npc/2020010.js +++ b/scripts/npc/2020010.js @@ -115,7 +115,8 @@ function action(mode, type, selection){ if (cm.getPlayer().getLevel() >= 50){ cm.sendOk("The Chief's Residence Council grants you #bconcession#k to make part of the #rcounteroffensive team against Zakum#k. Good luck on your journey ahead."); if(!(cm.isQuestStarted(100200) || cm.isQuestCompleted(100200))) cm.startQuest(100200); - if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); + const YamlConfig = Java.type('config.YamlConfig'); + if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); }else cm.sendOk("You're way too weak to make part of the #rcounteroffensive team against Zakum#k. Reach at least #blevel 50#k, then talk to me."); cm.dispose(); diff --git a/scripts/npc/2020011.js b/scripts/npc/2020011.js index 670f76d8f6..558ca4ab64 100644 --- a/scripts/npc/2020011.js +++ b/scripts/npc/2020011.js @@ -114,7 +114,8 @@ function action(mode, type, selection){ if (cm.getPlayer().getLevel() >= 50){ cm.sendOk("The Chief's Residence Council grants you #bconcession#k to make part of the #rcounteroffensive team against Zakum#k. Good luck on your journey ahead."); if(!(cm.isQuestStarted(100200) || cm.isQuestCompleted(100200))) cm.startQuest(100200); - if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); + const YamlConfig = Java.type('config.YamlConfig'); + if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); }else cm.sendOk("You're way too weak to make part of the #rcounteroffensive team against Zakum#k. Reach at least #blevel 50#k, then talk to me."); cm.dispose(); diff --git a/scripts/npc/2020013.js b/scripts/npc/2020013.js index 8e593311d4..209e650f49 100644 --- a/scripts/npc/2020013.js +++ b/scripts/npc/2020013.js @@ -113,7 +113,8 @@ function action(mode, type, selection){ if (cm.getPlayer().getLevel() >= 50){ cm.sendOk("The Chief's Residence Council grants you #bconcession#k to make part of the #rcounteroffensive team against Zakum#k. Good luck on your journey ahead."); if(!(cm.isQuestStarted(100200) || cm.isQuestCompleted(100200))) cm.startQuest(100200); - if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); + const YamlConfig = Java.type('config.YamlConfig'); + if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS && !cm.isQuestCompleted(100201)) cm.completeQuest(100201); }else cm.sendOk("You're way too weak to make part of the #rcounteroffensive team against Zakum#k. Reach at least #blevel 50#k, then talk to me."); cm.dispose(); diff --git a/scripts/npc/2030010.js b/scripts/npc/2030010.js index 20fde5ea3e..d4e3f97860 100644 --- a/scripts/npc/2030010.js +++ b/scripts/npc/2030010.js @@ -28,7 +28,6 @@ * Zakum Quest NPC * Helps players leave the map */ - importPackage(Packages.server.expeditions); function start() { if(cm.getMapId() == 280030000) { diff --git a/scripts/npc/2030013.js b/scripts/npc/2030013.js index 43d6876bd0..0c204d4d02 100644 --- a/scripts/npc/2030013.js +++ b/scripts/npc/2030013.js @@ -23,16 +23,14 @@ *@author Alan (SharpAceX) *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; -var exped = MapleExpeditionType.ZAKUM; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); +const exped = MapleExpeditionType.ZAKUM; var expedName = "Zakum"; var expedBoss = "Zakum"; var expedMap = "Zakum's Altar"; @@ -161,6 +159,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #b" + expedMap + "#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/2040042.js b/scripts/npc/2040042.js index 772e9e7818..66a43f7256 100644 --- a/scripts/npc/2040042.js +++ b/scripts/npc/2040042.js @@ -31,8 +31,6 @@ @ Description: You need a ranged person here. The ranged person must kill the three Ratz, and they'll trigger something. What's next is for you to find out! Get me 3 passes! */ -importPackage(Packages.server.life); - var status = 0; var curMap, stage; diff --git a/scripts/npc/2042000.js b/scripts/npc/2042000.js index 1b20c94ed7..7d0bc50950 100644 --- a/scripts/npc/2042000.js +++ b/scripts/npc/2042000.js @@ -29,9 +29,10 @@ var feeMultiplier = 7.0; function start() { status = -1; - - if (!Packages.config.YamlConfig.config.server.USE_CPQ) { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_CPQ) { + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { status = 0; action(1, 0, 4); } else { @@ -57,7 +58,8 @@ function action(mode, type, selection) { status++; else status--; - + + const YamlConfig = Java.type('config.YamlConfig'); if (cm.getPlayer().getMapId() == 980000010) { if (status == 0) { cm.sendNext("I hope you had fun at the Monster Carnival!"); @@ -221,9 +223,9 @@ function action(mode, type, selection) { } } else { var party = cm.getParty().getMembers(); - if ((selection >= 0 && selection <= 3) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { + if ((selection >= 0 && selection <= 3) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { cm.sendOk("You need at least 2 players to participate in the battle!"); - } else if ((selection >= 4 && selection <= 5) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { + } else if ((selection >= 4 && selection <= 5) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { cm.sendOk("You need at least 3 players to participate in the battle!"); } else { cm.cpqLobby(selection); @@ -236,7 +238,7 @@ function action(mode, type, selection) { } else { if (status == 0) { var talk = "What would you like to do? If you have never participate in the Monster Carnival, you will need to know a few things before participating! \r\n#b#L0# Go to the Monster Carnival 1.#l \r\n#L3# Go to the Monster Carnival 2.#l \r\n#L1# Learn about the Monster Carnival.#l\r\n#L2# Trade #t4001129#.#l"; - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { talk += "\r\n#L4# ... Can I just refine my ores?#l"; } cm.sendSimple(talk); @@ -497,8 +499,9 @@ function refineItems(refineType) { var refineFees = [[300,300,300,500,500,500,800,270],[500,500,500,500,500,500,500,1000,3000],[5000,5000,5000,5000,1000000]]; var itemCount = {}; - - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); @@ -551,7 +554,8 @@ function refineRockItems() { var rockItems = [4011007, 4021009]; var rockFees = [10000, 15000]; - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); diff --git a/scripts/npc/2042001.js b/scripts/npc/2042001.js index 7d57140f9e..c2b850a181 100644 --- a/scripts/npc/2042001.js +++ b/scripts/npc/2042001.js @@ -28,9 +28,10 @@ var feeMultiplier = 7.0; function start() { status = -1; - - if (!Packages.config.YamlConfig.config.server.USE_CPQ) { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_CPQ) { + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { status = 0; action(1, 0, 4); } else { @@ -56,7 +57,8 @@ function action(mode, type, selection) { status++; else status--; - + + const YamlConfig = Java.type('config.YamlConfig'); if (cm.getPlayer().getMapId() == 980000010) { if (status == 0) { cm.sendNext("I hope you had fun at the Monster Carnival!"); @@ -220,9 +222,9 @@ function action(mode, type, selection) { } } else { var party = cm.getParty().getMembers(); - if ((selection >= 0 && selection <= 3) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { + if ((selection >= 0 && selection <= 3) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { cm.sendOk("You need at least 2 players to participate in the battle!"); - } else if ((selection >= 4 && selection <= 5) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { + } else if ((selection >= 4 && selection <= 5) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { cm.sendOk("You need at least 3 players to participate in the battle!"); } else { cm.cpqLobby(selection); @@ -235,7 +237,7 @@ function action(mode, type, selection) { } else { if (status == 0) { var talk = "What would you like to do? If you have never participate in the Monster Carnival, you will need to know a few things before participating! \r\n#b#L0# Go to the Monster Carnival 1.#l \r\n#L3# Go to the Monster Carnival 2.#l \r\n#L1# Learn about the Monster Carnival.#l\r\n#L2# Trade #t4001129#.#l"; - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { talk += "\r\n#L4# ... Can I just refine my ores?#l"; } cm.sendSimple(talk); @@ -496,8 +498,9 @@ function refineItems(refineType) { var refineFees = [[300,300,300,500,500,500,800,270],[500,500,500,500,500,500,500,1000,3000],[5000,5000,5000,5000,1000000]]; var itemCount = {}; - - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); @@ -550,7 +553,8 @@ function refineRockItems() { var rockItems = [4011007, 4021009]; var rockFees = [10000, 15000]; - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); diff --git a/scripts/npc/2042002.js b/scripts/npc/2042002.js index 8ffd18763d..64416da13d 100644 --- a/scripts/npc/2042002.js +++ b/scripts/npc/2042002.js @@ -29,8 +29,9 @@ var feeMultiplier = 7.0; function start() { status = -1; - if (!Packages.config.YamlConfig.config.server.USE_CPQ) { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_CPQ) { + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { status = 0; action(1, 0, 4); } else { @@ -235,7 +236,9 @@ function action(mode, type, selection) { } else { if (status == 0) { var talk = "What would you like to do? If you have never participate in the Monster Carnival, you will need to know a few things before participating! \r\n#b#L0# Go to the Monster Carnival 1.#l \r\n#L3# Go to the Monster Carnival 2.#l \r\n#L1# Learn about the Monster Carnival.#l\r\n#L2# Trade #t4001129#.#l"; - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + + const YamlConfig = Java.type('config.YamlConfig'); + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { talk += "\r\n#L4# ... Can I just refine my ores?#l"; } cm.sendSimple(talk); @@ -496,8 +499,9 @@ function refineItems(refineType) { var refineFees = [[300,300,300,500,500,500,800,270],[500,500,500,500,500,500,500,1000,3000],[5000,5000,5000,5000,1000000]]; var itemCount = {}; - - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); @@ -550,7 +554,8 @@ function refineRockItems() { var rockItems = [4011007, 4021009]; var rockFees = [10000, 15000]; - var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator(); + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + var iter = cm.getPlayer().getInventory(MapleInventoryType.ETC).iterator(); while (iter.hasNext()) { var it = iter.next(); var itemid = it.getItemId(); diff --git a/scripts/npc/2042005.js b/scripts/npc/2042005.js index efb085c16a..61ea554dd1 100644 --- a/scripts/npc/2042005.js +++ b/scripts/npc/2042005.js @@ -77,9 +77,10 @@ function action(mode, type, selection) { } } else { var party = cm.getParty().getMembers(); - if ((selection === 0 || selection === 1 ) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { + const YamlConfig = Java.type('config.YamlConfig'); + if ((selection === 0 || selection === 1 ) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 2)) { cm.sendOk("You need at least 2 players to participate in the battle!"); - } else if ((selection === 2 ) && party.size() < (Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { + } else if ((selection === 2 ) && party.size() < (YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS ? 1 : 3)) { cm.sendOk("You need at least 3 players to participate in the battle!"); } else { cm.cpqLobby2(selection); diff --git a/scripts/npc/2081005.js b/scripts/npc/2081005.js index d709f1787e..84f4be4467 100644 --- a/scripts/npc/2081005.js +++ b/scripts/npc/2081005.js @@ -22,13 +22,12 @@ //@Author Moogra, Ronan //Fixed grammar, javascript syntax -importPackage(Packages.client); - var status = 0; var price = 100000; function isTransformed(ch) { - return ch.getBuffSource(MapleBuffStat.MORPH) == 2210003; + const MapleBuffStat = Java.type('client.MapleBuffStat'); + return ch.getBuffSource(MapleBuffStat.MORPH) == 2210003; } function start() { diff --git a/scripts/npc/2082014.js b/scripts/npc/2082014.js index 6b0eac71fd..291e0b3ded 100644 --- a/scripts/npc/2082014.js +++ b/scripts/npc/2082014.js @@ -39,7 +39,8 @@ function action(mode, type, selection) { status--; if(status == 0) { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.openShopNPC(2082014); } else if (cm.isQuestStarted(3749)) { cm.sendOk("We've already located the enemy's ultimate weapon! Follow along the ship's bow area ahead and you will find my sister #b#p2082013##k. Report to her for futher instructions on the mission."); diff --git a/scripts/npc/2083000.js b/scripts/npc/2083000.js index ee3b07b2f6..96622940da 100644 --- a/scripts/npc/2083000.js +++ b/scripts/npc/2083000.js @@ -43,9 +43,10 @@ function action(mode, type, selection) { else status--; if (status == 0) { + const YamlConfig = Java.type('config.YamlConfig'); if(cm.haveItem(4001086)) { cm.sendYesNo("Do you want to access #b#m240050400##k right now?"); - } else if(Packages.config.YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS) { + } else if(YamlConfig.config.server.USE_ENABLE_SOLO_EXPEDITIONS) { if(canBypassHTPQ()) { cm.sendYesNo("Do you want to access #b#m240050400##k right now?"); } else { diff --git a/scripts/npc/2083004.js b/scripts/npc/2083004.js index f13fc27bcf..55691bec0e 100644 --- a/scripts/npc/2083004.js +++ b/scripts/npc/2083004.js @@ -23,16 +23,14 @@ *@author Alan (SharpAceX) *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; -var exped = MapleExpeditionType.HORNTAIL; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); +const exped = MapleExpeditionType.HORNTAIL; var expedName = "Horntail"; var expedBoss = "mighty Horntail"; @@ -153,6 +151,7 @@ function action(mode, type, selection) { cm.sendOk("Good luck! All of Leafre is counting on you."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/2090004.js b/scripts/npc/2090004.js index c4fd175836..4c720bdf03 100644 --- a/scripts/npc/2090004.js +++ b/scripts/npc/2090004.js @@ -4,7 +4,6 @@ Map(s): Mu Lung: Mu Lung(2500000000) Description: Potion Creator */ -importPackage(Packages.client); var status = 0; var selectedType = -1; diff --git a/scripts/npc/2091005.js b/scripts/npc/2091005.js index bde9d339dd..4b1bb7e713 100644 --- a/scripts/npc/2091005.js +++ b/scripts/npc/2091005.js @@ -25,9 +25,6 @@ * @Map(s): Dojo Hall */ -importPackage(Packages.config); -importPackage(Packages.constants.game); - var disabled = false; var belts = Array(1132000, 1132001, 1132002, 1132003, 1132004); var belt_level = Array(25, 35, 45, 60, 75); @@ -44,7 +41,8 @@ function start() { cm.dispose(); return; } - + + const YamlConfig = Java.type('config.YamlConfig'); belt_points = YamlConfig.config.server.USE_FAST_DOJO_UPGRADE ? Array(10, 90, 200, 460, 850) : Array(200, 1800, 4000, 9200, 17000); belt_on_inventory = new Array(); @@ -70,6 +68,8 @@ function action(mode, type, selection) { if(status == 0) { if (isRestingSpot(cm.getPlayer().getMap().getId())) { var text = "I'm surprised you made it this far! But it won't be easy from here on out. You still want the challenge?\r\n\r\n#b#L0#I want to continue#l\r\n#L1#I want to leave#l\r\n"; + + const GameConstants = Java.type('constants.game.GameConstants'); if (!GameConstants.isDojoPartyArea(cm.getPlayer().getMapId())) { text += "#L2#I want to record my score up to this point#l"; } diff --git a/scripts/npc/2091005_old.js b/scripts/npc/2091005_old.js index d5b543ee88..ad73703e70 100644 --- a/scripts/npc/2091005_old.js +++ b/scripts/npc/2091005_old.js @@ -26,8 +26,6 @@ * @Map(s): Dojo Hall */ -importPackage(Packages.constants.game); - var disabled = false; var belts = Array(1132000, 1132001, 1132002, 1132003, 1132004); var belt_level = Array(25, 35, 45, 60, 75); @@ -47,6 +45,8 @@ function start() { if (isRestingSpot(cm.getPlayer().getMap().getId())) { var text = "I'm surprised you made it this far! But it won't be easy from here on out. You still want the challenge?\r\n\r\n#b#L0#I want to continue#l\r\n#L1#I want to leave#l\r\n"; + + const GameConstants = Java.type('constants.game.GameConstants'); if (!GameConstants.isDojoPartyArea(cm.getPlayer().getMapId())) { text += "#L2#I want to record my score up to this point#l"; } diff --git a/scripts/npc/2101014.js b/scripts/npc/2101014.js index 3058076035..cf2588b614 100644 --- a/scripts/npc/2101014.js +++ b/scripts/npc/2101014.js @@ -3,8 +3,6 @@ * For Jvlaple's AriantPQ */ -importPackage(Packages.server.expeditions); - var status = 0; var toBan = -1; var choice; @@ -13,6 +11,7 @@ var arena; var arenaName; var type; var map; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var exped = MapleExpeditionType.ARIANT; var exped1 = MapleExpeditionType.ARIANT1; var exped2 = MapleExpeditionType.ARIANT2; diff --git a/scripts/npc/2101015.js b/scripts/npc/2101015.js index edaf1f311b..5ef0793b69 100644 --- a/scripts/npc/2101015.js +++ b/scripts/npc/2101015.js @@ -1,8 +1,6 @@ var arena; var status = 0; -importPackage(Packages.client); - function start() { arena = cm.getPlayer().getAriantColiseum(); if (arena == null) { diff --git a/scripts/npc/2101016.js b/scripts/npc/2101016.js index 8a483d907d..324846c156 100644 --- a/scripts/npc/2101016.js +++ b/scripts/npc/2101016.js @@ -1,8 +1,6 @@ var arena; var status = 0; -importPackage(Packages.client); - function start() { arena = cm.getPlayer().getAriantColiseum(); if (arena == null) { diff --git a/scripts/npc/2101017.js b/scripts/npc/2101017.js index 035e2e0b94..27302f3aa6 100644 --- a/scripts/npc/2101017.js +++ b/scripts/npc/2101017.js @@ -3,9 +3,6 @@ *@author Jvlaple */ -importPackage(Packages.server.expeditions); - - var status = 0; var toBan = -1; var choice; @@ -13,6 +10,7 @@ var arena; var arenaName; var type; var map; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var exped; var expedicao; var expedMembers; @@ -31,6 +29,7 @@ function action(mode, type, selection) { return; } + const GameConstants = Java.type('constants.game.GameConstants'); if (cm.getPlayer().getMapId() == 980010100 || cm.getPlayer().getMapId() == 980010200 || cm.getPlayer().getMapId() == 980010300) { if (cm.getPlayer().getMapId() == 980010100) { exped = MapleExpeditionType.ARIANT; @@ -115,7 +114,7 @@ function action(mode, type, selection) { status = 2; } } - } else if (Packages.constants.game.GameConstants.isAriantColiseumArena(cm.getPlayer().getMapId())) { + } else if (GameConstants.isAriantColiseumArena(cm.getPlayer().getMapId())) { if (cm.getPlayer().getMapId() == 980010101) { exped = MapleExpeditionType.ARIANT; expedicao = cm.getExpedition(exped); diff --git a/scripts/npc/2103000.js b/scripts/npc/2103000.js index ae5cd41956..3e386bcce7 100644 --- a/scripts/npc/2103000.js +++ b/scripts/npc/2103000.js @@ -20,10 +20,10 @@ /* Oasis near Ariant Castle */ -importPackage(Packages.client); function isTigunMorphed(ch) { - return ch.getBuffSource(MapleBuffStat.MORPH) == 2210005; + const MapleBuffStat = Java.type('client.MapleBuffStat'); + return ch.getBuffSource(MapleBuffStat.MORPH) == 2210005; } function start() { diff --git a/scripts/npc/2111015.js b/scripts/npc/2111015.js index ca329ad95f..c6d54ae0ce 100644 --- a/scripts/npc/2111015.js +++ b/scripts/npc/2111015.js @@ -18,11 +18,10 @@ along with this program. If not, see . */ -importPackage(Packages.client); - var status; function isPillUsed(ch) { + const MapleBuffStat = Java.type('client.MapleBuffStat'); return ch.getBuffSource(MapleBuffStat.HPREC) == 2022198; } diff --git a/scripts/npc/2112000.js b/scripts/npc/2112000.js index 71a0f0755a..44054dc213 100644 --- a/scripts/npc/2112000.js +++ b/scripts/npc/2112000.js @@ -25,9 +25,7 @@ */ var status; - -importPackage(Packages.server.life); - + function start() { status = -1; action(1, 0, 0); @@ -92,6 +90,8 @@ function action(mode, type, selection) { } else { var state = eim.getIntProperty("yuletePassed"); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); if(state == -1) { cm.sendOk("Behold! The pinnacle of Magatia's alchemy studies! Hahahahahahaha..."); } else if(state == 0) { @@ -102,7 +102,7 @@ function action(mode, type, selection) { var bossobj = MapleLifeFactory.getMonster(9300139); //mapobj.spawnMonsterWithEffect(bossobj, 13, new Packages.java.awt.Point(250, 100)); - mapobj.spawnMonsterOnGroundBelow(bossobj, new Packages.java.awt.Point(250, 100)); + mapobj.spawnMonsterOnGroundBelow(bossobj, new Point(250, 100)); eim.setIntProperty("statusStg7", 1); eim.setIntProperty("yuletePassed", -1); @@ -114,7 +114,7 @@ function action(mode, type, selection) { var bossobj = MapleLifeFactory.getMonster(9300140); //mapobj.spawnMonsterWithEffect(bossobj, 14, new Packages.java.awt.Point(250, 100)); - mapobj.spawnMonsterOnGroundBelow(bossobj, new Packages.java.awt.Point(250, 100)); + mapobj.spawnMonsterOnGroundBelow(bossobj, new Point(250, 100)); eim.setIntProperty("statusStg7", 2); eim.setIntProperty("yuletePassed", -1); diff --git a/scripts/npc/2112010.js b/scripts/npc/2112010.js index 3d6d4cb895..bbde5fcd92 100644 --- a/scripts/npc/2112010.js +++ b/scripts/npc/2112010.js @@ -25,9 +25,7 @@ */ var status; - -importPackage(Packages.server.life); - + function start() { status = -1; action(1, 0, 0); @@ -92,6 +90,8 @@ function action(mode, type, selection) { } else { var state = eim.getIntProperty("yuletePassed"); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); if(state == -1) { cm.sendOk("Behold! The pinnacle of Magatia's alchemy studies! Hahahahahahaha..."); } else if(state == 0) { @@ -100,7 +100,7 @@ function action(mode, type, selection) { var mapobj = eim.getMapInstance(926110401); var bossobj = MapleLifeFactory.getMonster(9300151); - mapobj.spawnMonsterOnGroundBelow(bossobj, new Packages.java.awt.Point(250, 100)); + mapobj.spawnMonsterOnGroundBelow(bossobj, new Point(250, 100)); eim.setIntProperty("statusStg7", 1); eim.setIntProperty("yuletePassed", -1); @@ -110,7 +110,7 @@ function action(mode, type, selection) { var mapobj = eim.getMapInstance(926110401); var bossobj = MapleLifeFactory.getMonster(9300152); - mapobj.spawnMonsterOnGroundBelow(bossobj, new Packages.java.awt.Point(250, 100)); + mapobj.spawnMonsterOnGroundBelow(bossobj, new Point(250, 100)); eim.setIntProperty("statusStg7", 2); eim.setIntProperty("yuletePassed", -1); diff --git a/scripts/npc/2141001.js b/scripts/npc/2141001.js index 1c41cf337b..6d92c75daf 100644 --- a/scripts/npc/2141001.js +++ b/scripts/npc/2141001.js @@ -25,15 +25,13 @@ * * @author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var exped = MapleExpeditionType.PINKBEAN; var expedName = "Twilight of the Gods"; var expedBoss = "Pink Bean"; @@ -156,6 +154,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #b" + expedMap + "#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/9000017.js b/scripts/npc/9000017.js index 7ec1630216..c001a09481 100644 --- a/scripts/npc/9000017.js +++ b/scripts/npc/9000017.js @@ -51,7 +51,8 @@ function action(mode, type, selection) { } if (status == 0) { - if (!Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.sendOk("Hi, I'm #b#p" + cm.getNpc() + "##k."); cm.dispose(); return; diff --git a/scripts/npc/9000019.js b/scripts/npc/9000019.js index c5c20ae161..7dac2aa966 100644 --- a/scripts/npc/9000019.js +++ b/scripts/npc/9000019.js @@ -17,15 +17,17 @@ function action(mode, type, selection) { status++; else status--; - + if(status == 0) { - if(cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(cm.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() < 1) { cm.sendNext("Check for a available slot on your ETC inventory."); cm.dispose(); return; } - - cm.getClient().announce(Packages.tools.MaplePacketCreator.openRPSNPC()); + + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + cm.getClient().announce(MaplePacketCreator.openRPSNPC()); cm.dispose(); } } diff --git a/scripts/npc/9000036.js b/scripts/npc/9000036.js index 247353a8a4..73c6e933e9 100644 --- a/scripts/npc/9000036.js +++ b/scripts/npc/9000036.js @@ -39,7 +39,8 @@ var equip; var maxEqp = 0; function start() { - if (!Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.sendOk("Hi, I'm #b#p" + cm.getNpc() + "##k."); cm.dispose(); return; diff --git a/scripts/npc/9000040.js b/scripts/npc/9000040.js index 75650242b9..5f5c4bcf5e 100644 --- a/scripts/npc/9000040.js +++ b/scripts/npc/9000040.js @@ -24,9 +24,6 @@ * @author Ronan Lana */ -importPackage(Packages.client.processor.action); -importPackage(Packages.config); - var status; var mergeFee = 50000; var name; @@ -50,7 +47,8 @@ function action(mode, type, selection) { status--; if(status == 0) { - if (!Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.sendOk("The medal ranking system is currently unavailable..."); cm.dispose(); return; @@ -58,7 +56,8 @@ function action(mode, type, selection) { var levelLimit = !cm.getPlayer().isCygnus() ? 160 : 110; var selStr = "The medal ranking system is currently unavailable... Therefore, I am providing the #bEquipment Merge#k service! "; - + + const MakerProcessor = Java.type('client.processor.action.MakerProcessor'); if (!YamlConfig.config.server.USE_STARTER_MERGE && (cm.getPlayer().getLevel() < levelLimit || MakerProcessor.getMakerSkillLevel(cm.getPlayer()) < 3)) { selStr += "However, you must have #rMaker level 3#k and at least #rlevel 110#k (Cygnus Knight), #rlevel 160#k (other classes) and a fund of #r" + cm.numberWithCommas(mergeFee) + " mesos#k to use the service."; cm.sendOk(selStr); diff --git a/scripts/npc/9000041.js b/scripts/npc/9000041.js index 45d4b1aeac..6437f55ebd 100644 --- a/scripts/npc/9000041.js +++ b/scripts/npc/9000041.js @@ -42,7 +42,8 @@ function action(mode, type, selection) { } if (status == 0) { - if (!Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.sendOk("The medal ranking system is currently unavailable..."); cm.dispose(); return; diff --git a/scripts/npc/9020001.js b/scripts/npc/9020001.js index f6e590d54a..78ebb34276 100644 --- a/scripts/npc/9020001.js +++ b/scripts/npc/9020001.js @@ -27,9 +27,6 @@ * @func: Kerning PQ */ -importPackage(Packages.tools); -importPackage(java.awt); - var stage1Questions = Array( "Here's the question. Collect the same number of coupons as the minimum level required to make the first job advancement as warrior.", "Here's the question. Collect the same number of coupons as the minimum amount of STR needed to make the first job advancement as a warrior.", @@ -40,6 +37,7 @@ var stage1Questions = Array( "Here's the question. Collect the same number of coupons as the minimum level required to make the first job advancement as a magician."); var stage1Answers = Array(10, 35, 20, 25, 25, 30, 8); +const Rectangle = Java.type('java.awt.Rectangle'); var stage2Rects = Array(new Rectangle(-755,-132,4,218),new Rectangle(-721,-340,4,166),new Rectangle(-586,-326,4,150),new Rectangle(-483,-181,4,222)); var stage3Rects = Array(new Rectangle(608,-180,140,50),new Rectangle(791,-117,140,45), new Rectangle(958,-180,140,50),new Rectangle(876,-238,140,45), diff --git a/scripts/npc/9040006.js b/scripts/npc/9040006.js index 5d18e68346..8ddaff03ec 100644 --- a/scripts/npc/9040006.js +++ b/scripts/npc/9040006.js @@ -6,8 +6,6 @@ * Guild Quest Stage 3 */ -importPackage(Packages.tools); - function clearStage(stage, eim) { eim.setProperty("stage" + stage + "clear", "true"); eim.showClearEffect(true); @@ -213,6 +211,8 @@ function randX() { } function spawnMob(id, x, y, map) { - var mob = Packages.server.life.MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new Packages.java.awt.Point(x, y)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + var mob = MapleLifeFactory.getMonster(id); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/npc/9105004.js b/scripts/npc/9105004.js index 5fe3edd1ff..a5acf4577f 100644 --- a/scripts/npc/9105004.js +++ b/scripts/npc/9105004.js @@ -24,8 +24,6 @@ Maplemas PQ coordinator */ -importPackage(Packages.server.life); - var prizeTree = [[[2000002, 1002850], [20, 1]], [[2000006, 1012011], [20, 1]]]; var state; @@ -131,6 +129,9 @@ function insidePqAction(mode, type, selection) { } } } else if(status == 1) { + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + if(stg == -1) { if(!cm.isEventLeader()) { cm.sendOk("Please let your party leader talk to me for further details on the mission."); @@ -140,7 +141,7 @@ function insidePqAction(mode, type, selection) { mapobj.allowSummonState(true); var snowman = MapleLifeFactory.getMonster(9400317 + (5 * difficulty)); - mapobj.spawnMonsterOnGroundBelow(snowman, new java.awt.Point(-180, 15)); + mapobj.spawnMonsterOnGroundBelow(snowman, new Point(-180, 15)); eim.setIntProperty("snowmanLevel", 1); eim.dropMessage(5, "The snowman appeared on the field! Protect it using all means necessary!"); @@ -158,7 +159,7 @@ function insidePqAction(mode, type, selection) { eim.getEm().getIv().invokeFunction("snowmanHeal", eim); var boss = MapleLifeFactory.getMonster(9400318 + difficulty); - mapobj.spawnMonsterOnGroundBelow(boss, new java.awt.Point(-180, 15)); + mapobj.spawnMonsterOnGroundBelow(boss, new Point(-180, 15)); eim.setProperty("spawnedBoss", "true"); eim.setIntProperty("statusStg1", 1); diff --git a/scripts/npc/9120201.js b/scripts/npc/9120201.js index 13be378b5a..98a0d7984f 100644 --- a/scripts/npc/9120201.js +++ b/scripts/npc/9120201.js @@ -22,15 +22,13 @@ * *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var exped = MapleExpeditionType.SHOWA; var expedName = "Showa Gang"; var expedBoss = "The Boss"; @@ -160,6 +158,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #b" + expedMap + "#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/9201002.js b/scripts/npc/9201002.js index 40faa47cff..5aac705356 100644 --- a/scripts/npc/9201002.js +++ b/scripts/npc/9201002.js @@ -21,17 +21,13 @@ Marriage NPC */ -importPackage(Packages.config); -importPackage(Packages.net.server.channel.handlers); -importPackage(Packages.tools); -importPackage(Packages.tools.packets); - var status; var state; var eim; var weddingEventName = "WeddingCathedral"; var cathedralWedding = true; var weddingIndoors; +const YamlConfig = Java.type('config.YamlConfig'); var weddingBlessingExp = YamlConfig.config.server.WEDDING_BLESS_EXP; function isWeddingIndoors(mapid) { @@ -304,6 +300,7 @@ function action(mode, type, selection) { if (state == 0) { // give player blessings eim.gridInsert(cm.getPlayer(), 1); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); if (YamlConfig.config.server.WEDDING_BLESSER_SHOWFX) { var target = cm.getPlayer(); target.announce(MaplePacketCreator.showSpecialEffect(9)); @@ -354,6 +351,7 @@ function action(mode, type, selection) { cm.gainItem(playerItemId, -1); cmPartner.gainItem(partnerItemId, -1); + const RingActionHandler = Java.type('net.server.channel.handlers.RingActionHandler'); RingActionHandler.giveMarriageRings(player, partner, marriageRingId); player.setMarriageItemId(marriageRingId); partner.setMarriageItemId(marriageRingId); diff --git a/scripts/npc/9201004.js b/scripts/npc/9201004.js index f306a913cf..0a1f05002a 100644 --- a/scripts/npc/9201004.js +++ b/scripts/npc/9201004.js @@ -22,8 +22,6 @@ Wedding info. */ -importPackage(Packages.net.server.channel.handlers); - var status; var rings = [1112806, 1112803, 1112807, 1112809]; @@ -125,6 +123,7 @@ function action(mode, type, selection) { } cm.gainMeso(-divorceFee); + const RingActionHandler = Java.type('net.server.channel.handlers.RingActionHandler'); RingActionHandler.breakMarriageRing(cm.getPlayer(), ringObj.getItemId()); cm.gainItem(ringObj.getItemId(), -1); diff --git a/scripts/npc/9201005.js b/scripts/npc/9201005.js index 7e4006775b..d81ab704fa 100644 --- a/scripts/npc/9201005.js +++ b/scripts/npc/9201005.js @@ -21,8 +21,6 @@ Marriage NPC */ -importPackage(Packages.net.server.channel); - var status; var wid; var isMarrying; @@ -178,6 +176,7 @@ function action(mode, type, selection) { if(resStatus > 0) { cm.gainItem((weddingType) ? weddingEntryTicketPremium : weddingEntryTicketCommon, -1); + const Channel = Java.type('net.server.channel.Channel'); var expirationTime = Channel.getRelativeWeddingTicketExpireTime(resStatus); cm.gainItem(weddingSendTicket,15,false,true,expirationTime); partner.getAbstractPlayerInteraction().gainItem(weddingSendTicket,15,false,true,expirationTime); @@ -253,6 +252,7 @@ function action(mode, type, selection) { if(cm.canHold(weddingSendTicket, 3)) { cm.gainItem(5251100, -1); + const Channel = Java.type('net.server.channel.Channel'); var expirationTime = Channel.getRelativeWeddingTicketExpireTime(resStatus); cm.gainItem(weddingSendTicket,3,false,true,expirationTime); } else { diff --git a/scripts/npc/9201008.js b/scripts/npc/9201008.js index 8d1813e23b..348d1ac555 100644 --- a/scripts/npc/9201008.js +++ b/scripts/npc/9201008.js @@ -21,8 +21,6 @@ Marriage NPC */ -importPackage(Packages.net.server.channel); - var status; var wid; var isMarrying; @@ -253,6 +251,7 @@ function action(mode, type, selection) { if(cm.canHold(weddingSendTicket, 3)) { cm.gainItem(5251100, -1); + const Channel = Java.type('net.server.channel.Channel'); var expirationTime = Channel.getRelativeWeddingTicketExpireTime(resStatus); cm.gainItem(weddingSendTicket,3,false,true,expirationTime); } else { diff --git a/scripts/npc/9201011.js b/scripts/npc/9201011.js index 0cb2c189b3..e61b923927 100644 --- a/scripts/npc/9201011.js +++ b/scripts/npc/9201011.js @@ -21,17 +21,13 @@ Marriage NPC */ -importPackage(Packages.config); -importPackage(Packages.net.server.channel.handlers); -importPackage(Packages.tools); -importPackage(Packages.tools.packets); - var status; var state; var eim; var weddingEventName = "WeddingChapel"; var cathedralWedding = false; var weddingIndoors; +const YamlConfig = Java.type('config.YamlConfig'); var weddingBlessingExp = YamlConfig.config.server.WEDDING_BLESS_EXP; function detectPlayerItemid(player) { @@ -174,6 +170,7 @@ function action(mode, type, selection) { if(state == 0) { // give player blessings eim.gridInsert(cm.getPlayer(), 1); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); if(YamlConfig.config.server.WEDDING_BLESSER_SHOWFX) { var target = cm.getPlayer(); target.announce(MaplePacketCreator.showSpecialEffect(9)); @@ -224,6 +221,7 @@ function action(mode, type, selection) { cm.gainItem(playerItemId, -1); cmPartner.gainItem(partnerItemId, -1); + const RingActionHandler = Java.type('net.server.channel.handlers.RingActionHandler'); RingActionHandler.giveMarriageRings(player, partner, marriageRingId); player.setMarriageItemId(marriageRingId); partner.setMarriageItemId(marriageRingId); diff --git a/scripts/npc/9201044.js b/scripts/npc/9201044.js index 13a402420c..2c2b724312 100644 --- a/scripts/npc/9201044.js +++ b/scripts/npc/9201044.js @@ -29,8 +29,6 @@ @ Description: Used to find the combo to unlock the next door. Players stand on 5 different crates to guess the combo. */ -importPackage(Packages.server.life); - var debug = false; var autopass = false; @@ -39,6 +37,8 @@ function spawnMobs(maxSpawn) { var spawnPosY; var mapObj = cm.getMap(); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); if (stage == 2) { spawnPosX = [619, 299, 47, -140, -471]; spawnPosY = [-840, -840, -840, -840, -840]; @@ -49,9 +49,9 @@ function spawnMobs(maxSpawn) { var mobObj2 = MapleLifeFactory.getMonster(9400516); var mobObj3 = MapleLifeFactory.getMonster(9400517); - mapObj.spawnMonsterOnGroundBelow(mobObj1, new Packages.java.awt.Point(spawnPosX[i], spawnPosY[i])); - mapObj.spawnMonsterOnGroundBelow(mobObj2, new Packages.java.awt.Point(spawnPosX[i], spawnPosY[i])); - mapObj.spawnMonsterOnGroundBelow(mobObj3, new Packages.java.awt.Point(spawnPosX[i], spawnPosY[i])); + mapObj.spawnMonsterOnGroundBelow(mobObj1, new Point(spawnPosX[i], spawnPosY[i])); + mapObj.spawnMonsterOnGroundBelow(mobObj2, new Point(spawnPosX[i], spawnPosY[i])); + mapObj.spawnMonsterOnGroundBelow(mobObj3, new Point(spawnPosX[i], spawnPosY[i])); } } } else { @@ -63,7 +63,7 @@ function spawnMobs(maxSpawn) { var rndPos = Math.floor(Math.random() * 5); var mobObj = MapleLifeFactory.getMonster(rndMob); - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(spawnPosX[rndPos], spawnPosY[rndPos])); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(spawnPosX[rndPos], spawnPosY[rndPos])); } } } diff --git a/scripts/npc/9201047.js b/scripts/npc/9201047.js index 1c28526bee..faa4730731 100644 --- a/scripts/npc/9201047.js +++ b/scripts/npc/9201047.js @@ -65,9 +65,11 @@ function action(mode, type, selection) { var mapObj = cm.getMap(); mapObj.toggleDrops(); - - var mobObj = Packages.server.life.MapleLifeFactory.getMonster(9400518); - mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(-245, 810)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + var mobObj = MapleLifeFactory.getMonster(9400518); + mapObj.spawnMonsterOnGroundBelow(mobObj, new Point(-245, 810)); cm.sendOk("The fierry appeared! Defeat it to get the #b#t4031596##k!"); } else { diff --git a/scripts/npc/9201101.js b/scripts/npc/9201101.js index c424e7dcd9..4232739755 100644 --- a/scripts/npc/9201101.js +++ b/scripts/npc/9201101.js @@ -4,7 +4,8 @@ */ function start() { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.openShopNPC(9201101); } else { //cm.sendOk("The patrol in New Leaf City is always ready. No creatures are able to break through to the city."); diff --git a/scripts/npc/9201113.js b/scripts/npc/9201113.js index 766cae86de..539fef544e 100644 --- a/scripts/npc/9201113.js +++ b/scripts/npc/9201113.js @@ -23,15 +23,13 @@ *@author Alan (SharpAceX) *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var cwkpq = MapleExpeditionType.CWKPQ; var list = "What would you like to do?#b\r\n\r\n#L1#View current Expedition members#l\r\n#L2#Start the fight!#l\r\n#L3#Stop the expedition.#l"; @@ -143,6 +141,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #bEntrance to CWKPQ Altar#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/9270047.js b/scripts/npc/9270047.js index b77399be54..bafaa03ae3 100644 --- a/scripts/npc/9270047.js +++ b/scripts/npc/9270047.js @@ -23,15 +23,13 @@ *@author Alan (SharpAceX) *@author Ronan */ -importPackage(Packages.server.expeditions); -importPackage(Packages.tools); -importPackage(Packages.scripting.event); var status = 0; var expedition; var expedMembers; var player; var em; +const MapleExpeditionType = Java.type('server.expeditions.MapleExpeditionType'); var exped = MapleExpeditionType.SCARGA; var expedName = "Scarga"; var expedBoss = "Scarlion and Targa"; @@ -160,6 +158,7 @@ function action(mode, type, selection) { cm.sendOk("The expedition will begin and you will now be escorted to the #b" + expedMap + "#k."); status = 4; } else if (selection == 3) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, expedition.getLeader().getName() + " has ended the expedition.")); cm.endExpedition(expedition); cm.sendOk("The expedition has now ended. Sometimes the best strategy is to run away."); diff --git a/scripts/npc/9977777.js b/scripts/npc/9977777.js index 26b5fcdf43..31605dc4ac 100644 --- a/scripts/npc/9977777.js +++ b/scripts/npc/9977777.js @@ -22,8 +22,6 @@ HeavenMS developer info. */ -importPackage(Packages.tools); - var status; var anthemSong = "Field/anthem/brazil"; // sound src: https://c7.rbxcdn.com/f91060652a6e9fbfbf92cb1418435448 @@ -310,6 +308,7 @@ function writeAllFeatures() { } function start() { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); cm.getPlayer().announce(MaplePacketCreator.musicChange(anthemSong)); status = -1; writeAllFeatures(); @@ -317,6 +316,7 @@ function start() { } function action(mode, type, selection) { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); if (mode == -1) { cm.getPlayer().announce(MaplePacketCreator.musicChange(ambientSong)); cm.dispose(); diff --git a/scripts/npc/MagatiaPassword.js b/scripts/npc/MagatiaPassword.js index eaab5b7a19..340e7b52cb 100644 --- a/scripts/npc/MagatiaPassword.js +++ b/scripts/npc/MagatiaPassword.js @@ -21,7 +21,8 @@ function action(mode, type, selection){ else if(status == 1){ if(cm.getText() == cm.getQuestProgress(3360)){ cm.setQuestProgress(3360, 1); - cm.getPlayer().announce(Packages.tools.MaplePacketCreator.playPortalSound()); + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); + cm.getPlayer().announce(MaplePacketCreator.playPortalSound()); cm.warp(261030000, "sp_" + ((cm.getMapId() == 261010000) ? "jenu" : "alca")); } else { diff --git a/scripts/npc/changeName.js b/scripts/npc/changeName.js index b0b81f2b20..a684dc9b1e 100644 --- a/scripts/npc/changeName.js +++ b/scripts/npc/changeName.js @@ -46,7 +46,9 @@ function action(mode, type, selection) { cm.sendGetText("Please input your desired name below."); } else if(status == 2) { var text = cm.getText(); - var canCreate = Packages.client.MapleCharacter.canCreateChar(text); + + const MapleCharacter = Java.type('client.MapleCharacter'); + var canCreate = MapleCharacter.canCreateChar(text); if(canCreate) { cm.getPlayer().setName(text); cm.sendOk("Your name has been changed to #b" + text + "#k. You will have to login again for this to take effect.", 1); diff --git a/scripts/npc/commands.js b/scripts/npc/commands.js index b90af5eae3..37f7252671 100644 --- a/scripts/npc/commands.js +++ b/scripts/npc/commands.js @@ -6,8 +6,6 @@ Script: commands.js */ -importPackage(Packages.client.command); - var status; var common_heading = "@"; @@ -17,6 +15,7 @@ var levels = ["Common", "Donator", "JrGM", "GM", "SuperGM", "Developer", "Admin" var commands; function writeHeavenMSCommands() { + const CommandsExecutor = Java.type('client.command.CommandsExecutor'); commands = CommandsExecutor.getInstance().getGmCommands(); } diff --git a/scripts/npc/cpqchallenge.js b/scripts/npc/cpqchallenge.js index c55c990717..5da9bedf6e 100644 --- a/scripts/npc/cpqchallenge.js +++ b/scripts/npc/cpqchallenge.js @@ -5,8 +5,6 @@ --------------------------------------------------------------------------------------------------- **/ -importPackage(Packages.constants.game); - var status = 0; var party; @@ -36,10 +34,12 @@ function action(mode, type, selection) { status++; else status--; - + if (status == 0) { if (cm.getParty().getMembers().size() == party.size()) { cm.getPlayer().setChallenged(true); + + const GameConstants = Java.type('constants.game.GameConstants'); var snd = ""; for (var i = 0; i < party.size(); i++) snd += "#bName: " + party.get(i).getName() + " / (Level: " + party.get(i).getLevel() + ") / " + GameConstants.getJobName(party.get(i).getJobId()) + "#k\r\n\r\n"; diff --git a/scripts/npc/cpqchallenge2.js b/scripts/npc/cpqchallenge2.js index c55c990717..d6c79c733b 100644 --- a/scripts/npc/cpqchallenge2.js +++ b/scripts/npc/cpqchallenge2.js @@ -5,8 +5,6 @@ --------------------------------------------------------------------------------------------------- **/ -importPackage(Packages.constants.game); - var status = 0; var party; @@ -40,6 +38,8 @@ function action(mode, type, selection) { if (status == 0) { if (cm.getParty().getMembers().size() == party.size()) { cm.getPlayer().setChallenged(true); + + const GameConstants = Java.type('constants.game.GameConstants'); var snd = ""; for (var i = 0; i < party.size(); i++) snd += "#bName: " + party.get(i).getName() + " / (Level: " + party.get(i).getLevel() + ") / " + GameConstants.getJobName(party.get(i).getJobId()) + "#k\r\n\r\n"; diff --git a/scripts/npc/gachaponInfo.js b/scripts/npc/gachaponInfo.js index 2a63279a1b..68dad89a8d 100644 --- a/scripts/npc/gachaponInfo.js +++ b/scripts/npc/gachaponInfo.js @@ -27,8 +27,9 @@ var status; var gachaMessages; function start() { - gachaMessages = Packages.server.gachapon.MapleGachapon.Gachapon.getLootInfo(); - gachas = Packages.server.gachapon.MapleGachapon.Gachapon.values(); + const MapleGachapon = Java.type('server.gachapon.MapleGachapon'); + gachaMessages = MapleGachapon.Gachapon.getLootInfo(); + gachas = MapleGachapon.Gachapon.values(); status = -1; action(1, 0, 0); diff --git a/scripts/npc/mapleTV.js b/scripts/npc/mapleTV.js index 93c58b5d66..5a66c176d9 100644 --- a/scripts/npc/mapleTV.js +++ b/scripts/npc/mapleTV.js @@ -24,7 +24,8 @@ var status; function start() { - if (Packages.config.YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { + const YamlConfig = Java.type('config.YamlConfig'); + if (YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) { cm.dispose(); cm.openNpc(9201088, "scroll_generator"); return; diff --git a/scripts/npc/rank_user.js b/scripts/npc/rank_user.js index bbe07c49da..e99b63f908 100644 --- a/scripts/npc/rank_user.js +++ b/scripts/npc/rank_user.js @@ -21,8 +21,6 @@ * @Author Ronan * Player NPC Ranking System */ -importPackage(Packages.constants.game); - var status; function start() { @@ -47,6 +45,7 @@ function action(mode, type, selection) { var pnpc = cm.getPlayerNPCByScriptid(cm.getNpc()); if(pnpc != null) { + const GameConstants = Java.type('constants.game.GameConstants'); var branchJobName = GameConstants.getJobName(pnpc.getJob()); var rankStr = "Hi, I am #b" + pnpc.getName() + "#k, #r" + GameConstants.ordinal(pnpc.getWorldJobRank()) + "#k in the #r" + branchJobName + "#k class to reach the max level and obtain a statue on " + GameConstants.WORLD_NAMES[cm.getPlayer().getWorld()] + ".\r\n"; diff --git a/scripts/npc/scroll_generator.js b/scripts/npc/scroll_generator.js index 1fa746d067..eeeaa5014b 100644 --- a/scripts/npc/scroll_generator.js +++ b/scripts/npc/scroll_generator.js @@ -25,12 +25,6 @@ * @author Ronan Lana */ -importPackage(Packages.client); -importPackage(Packages.config); -importPackage(Packages.constants.game); -importPackage(Packages.server); -importPackage(Packages.server.life); - var status; var jobWeaponRestricted = [[[2043000, 2043100, 2044000, 2044100, 2043200, 2044200]], [[2043000, 2043100, 2044000, 2044100], [2043000, 2043200, 2044000, 2044200], [2044300, 2044400]], [[2043700, 2043800], [2043700, 2043800], [2043700, 2043800]], [[2044500], [2044600]], [[2044700], [2043300]], [[2044800], [2044900]]]; @@ -150,7 +144,8 @@ function getJobTierScrolls() { var job = cm.getPlayer().getJob(); var jobScrolls = jobWeaponRestricted[Math.floor(cm.getPlayer().getJobStyle().getId() / 100)]; - + + const GameConstants = Java.type('constants.game.GameConstants'); var jobBranch = GameConstants.getJobBranch(job); if (jobBranch >= 2) { Array.prototype.push.apply(scrolls, jobScrolls[Math.floor((job.getId() / 10) % 10) - 1]); @@ -200,6 +195,7 @@ function getScrollTier(scrollStats) { function getScrollSuccessTier(scrollStats) { var prop = scrollStats.get("success"); + const YamlConfig = Java.type('config.YamlConfig'); if (prop > 90) { return 3; } else if (prop < 50) { @@ -211,6 +207,7 @@ function getScrollSuccessTier(scrollStats) { function getAvailableScrollsPool(baseScrolls, rewardTier, successTier) { var scrolls = []; + const MapleItemInformationProvider = Java.type('server.MapleItemInformationProvider'); var ii = MapleItemInformationProvider.getInstance(); for (var i = 0; i < baseScrolls.length; i++) { @@ -247,6 +244,8 @@ function getPlayerCardTierPower() { countTier[ceTier] += ce.getValue(); if (ceTier >= 8) { // is special card + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const MapleItemInformationProvider = Java.type('server.MapleItemInformationProvider'); var mobLevel = MapleLifeFactory.getMonsterLevel(MapleItemInformationProvider.getInstance().getCardMobId(cardid)); var mobTier = getLevelTier(mobLevel) - 1; @@ -280,6 +279,7 @@ function calculateMobBookBuckets() { playerLevelTier = 8; } + const MonsterBook = Java.type('client.MonsterBook'); var tierSize = MonsterBook.getCardTierSize(); var playerCards = getPlayerCardTierPower(); @@ -421,7 +421,8 @@ function performExchange(sgItemid, sgCount) { } function generateRandomScroll() { - if (cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() >= 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if (cm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) { var itemid = getRandomScroll(calculateScrollTiers()); if (itemid != -1) { if (performExchange(itemid, 1)) { diff --git a/scripts/npc/waterOfLife.js b/scripts/npc/waterOfLife.js index b687e9ead0..42209c9206 100644 --- a/scripts/npc/waterOfLife.js +++ b/scripts/npc/waterOfLife.js @@ -23,9 +23,6 @@ Handles Water of Life */ -importPackage(Packages.client.inventory); -importPackage(Packages.server); - var status; var dList; @@ -79,7 +76,8 @@ function action(mode, type, selection) { if(sPet != null) { cm.sendNext("Your doll has now reawaken as your pet! However, my magic isn't perfect, so I can't promise an eternal life for your pet... Please take care of that pet before the Water of Life dries. Well then, good bye..."); - + + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); var it = cm.getPlayer().getInventory(MapleInventoryType.CASH).getItem(sPet.getPosition()); it.setExpiration(Date.now() + (1000 * 60 * 60 * 24 * 90)); cm.getPlayer().forceUpdateItem(it); diff --git a/scripts/portal/ariant_queens.js b/scripts/portal/ariant_queens.js index d12a8f5283..67a0deb58c 100644 --- a/scripts/portal/ariant_queens.js +++ b/scripts/portal/ariant_queens.js @@ -18,9 +18,8 @@ along with this program. If not, see . */ -importPackage(Packages.client); - function isTigunMorphed(ch) { + const MapleBuffStat = Java.type('client.MapleBuffStat'); return ch.getBuffSource(MapleBuffStat.MORPH) == 2210005; } diff --git a/scripts/portal/davy_next4.js b/scripts/portal/davy_next4.js index 6cc7ad2a4e..a7cfc46440 100644 --- a/scripts/portal/davy_next4.js +++ b/scripts/portal/davy_next4.js @@ -1,5 +1,3 @@ -importPackage(Packages.server.life); - function enter(pi) { if (pi.getMap().getReactorByName("sMob1").getState() >= 1 && pi.getMap().getReactorByName("sMob2").getState() >= 1 && pi.getMap().getReactorByName("sMob3").getState() >= 1 && pi.getMap().getReactorByName("sMob4").getState() >= 1 && pi.getMap().getMonsters().size() == 0) { var eim = pi.getEventInstance(); @@ -9,13 +7,15 @@ function enter(pi) { var chests = parseInt(eim.getProperty("openedChests")); var boss; + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); if(chests == 0) boss = MapleLifeFactory.getMonster(9300119); //lord pirate else if(chests == 1) boss = MapleLifeFactory.getMonster(9300105); //angry lord pirate else boss = MapleLifeFactory.getMonster(9300106); //enraged lord pirate boss.changeDifficulty(level, true); - pi.getMap(925100500).spawnMonsterOnGroundBelow(boss, new java.awt.Point(777, 140)); + const Point = Java.type('java.awt.Point'); + pi.getMap(925100500).spawnMonsterOnGroundBelow(boss, new Point(777, 140)); eim.setProperty("spawnedBoss", "true"); } diff --git a/scripts/portal/dojang_up.js b/scripts/portal/dojang_up.js index e3f60ef36f..1a6b7eee53 100644 --- a/scripts/portal/dojang_up.js +++ b/scripts/portal/dojang_up.js @@ -25,14 +25,13 @@ * @maps: All Dojo fighting maps */ -importPackage(Packages.constants.game); - function enter(pi) { try { if (pi.getPlayer().getMap().getMonsterById(9300216) != null) { pi.goDojoUp(); pi.getPlayer().getMap().setReactorState(); var stage = Math.floor(pi.getPlayer().getMapId() / 100) % 100; + const GameConstants = Java.type('constants.game.GameConstants'); if ((stage - (stage / 6) | 0) == pi.getPlayer().getVanquisherStage() && !GameConstants.isDojoPartyArea(pi.getPlayer().getMapId())) // we can also try 5 * stage / 6 | 0 + 1 pi.getPlayer().setVanquisherKills(pi.getPlayer().getVanquisherKills() + 1); } else { diff --git a/scripts/portal/enterInfo.js b/scripts/portal/enterInfo.js index 466f53f0cd..aedd9c1f75 100644 --- a/scripts/portal/enterInfo.js +++ b/scripts/portal/enterInfo.js @@ -1,7 +1,9 @@ function enter(pi) { var mapobj = pi.getWarpMap(104000004); if(pi.isQuestActive(21733) && pi.getQuestProgressInt(21733, 9300345) == 0 && mapobj.countMonsters() == 0) { - mapobj.spawnMonsterOnGroundBelow(Packages.server.life.MapleLifeFactory.getMonster(9300345), new java.awt.Point(0, 0)); + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + mapobj.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300345), new Point(0, 0)); pi.setQuestProgress(21733, 21762, 2); } diff --git a/scripts/portal/enterMCave.js b/scripts/portal/enterMCave.js index e121cc1b5f..34d720b36f 100644 --- a/scripts/portal/enterMCave.js +++ b/scripts/portal/enterMCave.js @@ -1,6 +1,3 @@ -importPackage(Packages.server.quest); -importPackage(Packages.server.life); - function enter(pi) { if(pi.isQuestStarted(21201)) { // Second Job for (var i = 108000700; i < 108000709; i++){ @@ -36,7 +33,9 @@ function enter(pi) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/portal/enterNepenthes.js b/scripts/portal/enterNepenthes.js index 9963a6fb2f..7a5f1393b2 100644 --- a/scripts/portal/enterNepenthes.js +++ b/scripts/portal/enterNepenthes.js @@ -6,8 +6,10 @@ function enter(pi) { if(mapobj1.countPlayers() == 0 && mapobj2.countPlayers() == 0) { mapobj1.resetPQ(1); mapobj2.resetPQ(1); - - mapobj2.spawnMonsterOnGroundBelow(Packages.server.life.MapleLifeFactory.getMonster(9300348), new Packages.java.awt.Point(591, -34)); + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); + mapobj2.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300348), new Point(591, -34)); pi.playPortalSound(); pi.warp(920030000,2); return true; diff --git a/scripts/portal/enterPort.js b/scripts/portal/enterPort.js index e79056d85c..d162cc1529 100644 --- a/scripts/portal/enterPort.js +++ b/scripts/portal/enterPort.js @@ -19,7 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.server.life); function enter(pi) { if(pi.isQuestStarted(21301) && pi.getQuestProgressInt(21301, 9001013) == 0) { @@ -42,7 +41,9 @@ function enter(pi) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/portal/party3_jailin.js b/scripts/portal/party3_jailin.js index 64847fd211..2ccdeac4ed 100644 --- a/scripts/portal/party3_jailin.js +++ b/scripts/portal/party3_jailin.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var leverSequenceExit = false; function enterLeverSequence(pi) { @@ -30,6 +28,7 @@ function enterLeverSequence(pi) { } } + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); if(countMiss > 0) { map.broadcastMessage(MaplePacketCreator.showEffect("quest/party/wrong_kor")); map.broadcastMessage(MaplePacketCreator.playSound("Party1/Failed")); diff --git a/scripts/portal/rankDeveloperRoom.js b/scripts/portal/rankDeveloperRoom.js index 4b6e3c6987..2ec93fc548 100644 --- a/scripts/portal/rankDeveloperRoom.js +++ b/scripts/portal/rankDeveloperRoom.js @@ -1,6 +1,7 @@ function enter(pi) { if (pi.getPlayer().getMapId() != 777777777) { - if(!Packages.net.server.Server.getInstance().canEnterDeveloperRoom()) { + const Server = Java.type('net.server.Server'); + if(!Server.getInstance().canEnterDeveloperRoom()) { pi.message("The next room is currently unavailable."); return false; } diff --git a/scripts/quest/1021.js b/scripts/quest/1021.js index 7d10f5d8f6..afe6becca9 100644 --- a/scripts/quest/1021.js +++ b/scripts/quest/1021.js @@ -26,8 +26,6 @@ Map(s): Maple Road : Lower level of the Training Camp (2) Description: Quest - Roger's Apple */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2001.js b/scripts/quest/2001.js index 79ed3f0c85..1eaf42574a 100644 --- a/scripts/quest/2001.js +++ b/scripts/quest/2001.js @@ -1,5 +1,3 @@ -importPackage(Packages.client); - var item; var stance; var status = -1; @@ -17,7 +15,8 @@ function end(mode, type, selection) { } else if(status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() < 1) { qm.getPlayer().dropMessage(1, "USE inventory full."); qm.dispose(); return; @@ -25,11 +24,12 @@ function end(mode, type, selection) { var talkStr = "Okay, now choose the scroll of your liking ... The odds of winning are 10% each. \r\n\r\n#rSELECT A ITEM\r\n#b"; stance = qm.getPlayer().getJobStyle(); - - if(stance == Packages.client.MapleJob.WARRIOR || stance == Packages.client.MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); - else if(stance == Packages.client.MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); - else if(stance == Packages.client.MapleJob.BOWMAN || stance == Packages.client.MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); - else if(stance == Packages.client.MapleJob.THIEF) vecItem = new Array(2043302, 2044702); + + const MapleJob = Java.type('client.MapleJob'); + if(stance == MapleJob.WARRIOR || stance == MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); + else if(stance == MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); + else if(stance == MapleJob.BOWMAN || stance == MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); + else if(stance == MapleJob.THIEF) vecItem = new Array(2043302, 2044702); else vecItem = new Array(2044802, 2044902); for (var i = 0; i < vecItem.length; i++) diff --git a/scripts/quest/20101.js b/scripts/quest/20101.js index a53b48f168..0a77f931d2 100644 --- a/scripts/quest/20101.js +++ b/scripts/quest/20101.js @@ -2,8 +2,6 @@ * Cygnus 1st Job advancement - Dawn Warrior */ -importPackage(Packages.client); - var status = -1; var jobType = 1; var canTryFirstJob = true; @@ -39,6 +37,7 @@ function end(mode, type, selection) { qm.gainItem(1302077, 1); qm.gainItem(1142066, 1); + const MapleJob = Java.type('client.MapleJob'); qm.changeJob(MapleJob.DAWNWARRIOR1); qm.getPlayer().resetStats(); } diff --git a/scripts/quest/20102.js b/scripts/quest/20102.js index fec8015c50..0435dacb0f 100644 --- a/scripts/quest/20102.js +++ b/scripts/quest/20102.js @@ -2,8 +2,6 @@ * Cygnus 1st Job advancement - Blaze Wizard */ -importPackage(Packages.client); - var status = -1; var jobType = 2; var canTryFirstJob = true; @@ -39,6 +37,7 @@ function end(mode, type, selection) { qm.gainItem(1372043, 1); qm.gainItem(1142066, 1); + const MapleJob = Java.type('client.MapleJob'); qm.changeJob(MapleJob.BLAZEWIZARD1); qm.getPlayer().resetStats(); } diff --git a/scripts/quest/20103.js b/scripts/quest/20103.js index 8aadf16618..6fc2b0e5b0 100644 --- a/scripts/quest/20103.js +++ b/scripts/quest/20103.js @@ -2,8 +2,6 @@ * Cygnus 1st Job advancement - Wind Archer */ -importPackage(Packages.client); - var status = -1; var jobType = 3; var canTryFirstJob = true; @@ -40,6 +38,7 @@ function end(mode, type, selection) { qm.gainItem(2060000, 2000); qm.gainItem(1452051, 1); qm.gainItem(1142066, 1); + const MapleJob = Java.type('client.MapleJob'); qm.changeJob(MapleJob.WINDARCHER1); qm.getPlayer().resetStats(); } diff --git a/scripts/quest/20104.js b/scripts/quest/20104.js index 2f4ee320c7..8e84d797bd 100644 --- a/scripts/quest/20104.js +++ b/scripts/quest/20104.js @@ -2,8 +2,6 @@ * Cygnus 1st Job advancement - Night Walker */ -importPackage(Packages.client); - var status = -1; var jobType = 4; var canTryFirstJob = true; @@ -40,6 +38,7 @@ function end(mode, type, selection) { qm.gainItem(1472061, 1); qm.gainItem(2070000, 800); qm.gainItem(1142066, 1); + const MapleJob = Java.type('client.MapleJob'); qm.changeJob(MapleJob.NIGHTWALKER1); qm.getPlayer().resetStats(); } diff --git a/scripts/quest/20105.js b/scripts/quest/20105.js index 03e933f019..3d9ee17190 100644 --- a/scripts/quest/20105.js +++ b/scripts/quest/20105.js @@ -2,8 +2,6 @@ * Cygnus 1st Job advancement - Thunder Breaker */ -importPackage(Packages.client); - var status = -1; var jobType = 5; var canTryFirstJob = true; @@ -39,6 +37,7 @@ function end(mode, type, selection) { qm.gainItem(1482014, 1); qm.gainItem(1142066, 1); + const MapleJob = Java.type('client.MapleJob'); qm.getPlayer().changeJob(MapleJob.THUNDERBREAKER1); qm.getPlayer().resetStats(); } diff --git a/scripts/quest/20201.js b/scripts/quest/20201.js index 3a19a62fdb..32be42207f 100644 --- a/scripts/quest/20201.js +++ b/scripts/quest/20201.js @@ -54,7 +54,8 @@ function end(mode, type, selection) { } qm.gainItem(4032096, -30); qm.gainItem(1142067, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.DAWNWARRIOR2); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.DAWNWARRIOR2); qm.completeQuest(); } qm.sendNext("You are a Knight-in-Training no more. You are now an official knight of the Cygnus Knights."); diff --git a/scripts/quest/20202.js b/scripts/quest/20202.js index 81f667696d..818e6d44df 100644 --- a/scripts/quest/20202.js +++ b/scripts/quest/20202.js @@ -54,7 +54,8 @@ function end(mode, type, selection) { } qm.gainItem(4032097, -30); qm.gainItem(1142067, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.BLAZEWIZARD2); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.BLAZEWIZARD2); qm.completeQuest(); } qm.sendNext("You are no longer a Knight-in-Training. You are now an official Cygnus Knight!"); diff --git a/scripts/quest/20203.js b/scripts/quest/20203.js index ab3a264cd4..e39be7bd65 100644 --- a/scripts/quest/20203.js +++ b/scripts/quest/20203.js @@ -54,7 +54,8 @@ function end(mode, type, selection) { } qm.gainItem(4032098, -30); qm.gainItem(1142067, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.WINDARCHER2); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.WINDARCHER2); qm.completeQuest(); } qm.sendNext("You are no longer a Knight-in-Training. You are now officially a Cygnus Knight."); diff --git a/scripts/quest/20204.js b/scripts/quest/20204.js index 496abb1d95..58a995c9df 100644 --- a/scripts/quest/20204.js +++ b/scripts/quest/20204.js @@ -54,7 +54,8 @@ function end(mode, type, selection) { } qm.gainItem(4032099, -30); qm.gainItem(1142067, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.NIGHTWALKER2); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.NIGHTWALKER2); qm.completeQuest(); } qm.sendNext("You are no longer a Knight-in-Training. You have officially become a Cygnus Knight."); diff --git a/scripts/quest/20205.js b/scripts/quest/20205.js index d842fb9e5f..c9c5cc94be 100644 --- a/scripts/quest/20205.js +++ b/scripts/quest/20205.js @@ -54,7 +54,8 @@ function end(mode, type, selection) { } qm.gainItem(4032100, -30); qm.gainItem(1142067, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.THUNDERBREAKER2); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.THUNDERBREAKER2); qm.completeQuest(); } qm.sendNext("You are now no longer a Knight-in-Training. You have now officially become a Cygnus Knight."); diff --git a/scripts/quest/20311.js b/scripts/quest/20311.js index 4075738092..5a7723caef 100644 --- a/scripts/quest/20311.js +++ b/scripts/quest/20311.js @@ -54,7 +54,8 @@ function start(mode, type, selection) { } else { qm.completeQuest(); qm.gainItem(1142068, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.DAWNWARRIOR3); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.DAWNWARRIOR3); qm.sendOk("#h #, as of this moment, you are an Advanced Knight. From this moment on, you shall carry yourself with dignity and respect befitting your new title, an Advanced Knight of Cygnus Knights. May your glory continue to shine as bright as this moment."); } } diff --git a/scripts/quest/20312.js b/scripts/quest/20312.js index b562dea87e..1f5fcdbe21 100644 --- a/scripts/quest/20312.js +++ b/scripts/quest/20312.js @@ -54,7 +54,8 @@ function start(mode, type, selection) { } else { qm.completeQuest(); qm.gainItem(1142068, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.BLAZEWIZARD3); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.BLAZEWIZARD3); qm.sendOk("#h #, as of this moment, you are an Advanced Knight. From this moment on, you will train yourself with fervor as you will lead your group of Knights for the safety of this world. That fervor will provide you with plenty of courage."); } } diff --git a/scripts/quest/20313.js b/scripts/quest/20313.js index 58e7a89064..8f87176ee8 100644 --- a/scripts/quest/20313.js +++ b/scripts/quest/20313.js @@ -54,7 +54,8 @@ function start(mode, type, selection) { } else { qm.completeQuest(); qm.gainItem(1142068, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.WINDARCHER3); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.WINDARCHER3); qm.sendOk("#h #, as of this moment, you are an Advanced Knight. From this moment on, you will be carrying a while lot of responsibility befitting your new title as an Advanced Knight of Cygnus Knights. You may view the world in a carefree mode, but please remember what your mission is."); } } diff --git a/scripts/quest/20314.js b/scripts/quest/20314.js index be6c955c90..785fbbda4b 100644 --- a/scripts/quest/20314.js +++ b/scripts/quest/20314.js @@ -53,7 +53,8 @@ function start(mode, type, selection) { qm.sendNext("If you wish to receive the medal befitting the title, you may want to make some room in your equipment inventory."); } else { qm.gainItem(1142068, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.NIGHTWALKER3); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.NIGHTWALKER3); qm.completeQuest(); qm.sendOk("#h #, from here on out, you are an Advanced Knight of Cygnus Knights. The title comes with a newfound broad view on everything. You may encounter temptations here and there, but I want you to keep your faith and beliefs intact and do not succumb to the darkness."); } diff --git a/scripts/quest/20315.js b/scripts/quest/20315.js index 073fc6da8b..bccbc89910 100644 --- a/scripts/quest/20315.js +++ b/scripts/quest/20315.js @@ -53,7 +53,8 @@ function start(mode, type, selection) { qm.sendNext("If you wish to receive the medal befitting the title, you may want to make some room in your equipment inventory."); } else { qm.gainItem(1142068, 1); - qm.getPlayer().changeJob(Packages.client.MapleJob.THUNDERBREAKER3); + const MapleJob = Java.type('client.MapleJob'); + qm.getPlayer().changeJob(MapleJob.THUNDERBREAKER3); qm.completeQuest(); qm.sendOk("#h #, from here on out, you will become an Advanced Knight of the Knights of Cygnus! As your standing rises, so does the difficulty of the tasks you will be receiving. But challenge is good, right? You have to enjoy life. Enjoy what's given to you!"); } diff --git a/scripts/quest/2034.js b/scripts/quest/2034.js index 37105e5b12..49d013c6b0 100644 --- a/scripts/quest/2034.js +++ b/scripts/quest/2034.js @@ -1,5 +1,3 @@ -importPackage(Packages.client); - var item; var status = -1; var item; @@ -16,29 +14,32 @@ function end(mode, type, selection) { } else if(status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.EQUIP).getNumFreeSlot() < 1) { - qm.sendOk("Please free a EQUIP inventory slot to receive the reward."); - qm.dispose(); - return; + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.EQUIP).getNumFreeSlot() < 1) { + qm.sendOk("Please free a EQUIP inventory slot to receive the reward."); + qm.dispose(); + return; } - var stance = qm.getPlayer().getJobStyle(); - if(stance == Packages.client.MapleJob.WARRIOR) item = 1072003; - else if(stance == Packages.client.MapleJob.MAGICIAN) item = 1072077; - else if(stance == Packages.client.MapleJob.BOWMAN || stance == Packages.client.MapleJob.CROSSBOWMAN) item = 1072081; - else if(stance == Packages.client.MapleJob.THIEF) item = 1072035; - else if(stance == Packages.client.MapleJob.BRAWLER || stance == Packages.client.MapleJob.GUNSLINGER) item = 1072294; - else item = 1072018; - - qm.gainItem(item, 1); - qm.gainItem(4000007, -150); - qm.gainExp(2200); - qm.completeQuest(); - - qm.sendOk("Alright, if you need work sometime down the road, feel free to come back and see me. This town sure can use a person like you for help~"); - } + var stance = qm.getPlayer().getJobStyle(); - else if (status == 2) { - qm.dispose(); - } + const MapleJob = Java.type('client.MapleJob'); + if(stance == MapleJob.WARRIOR) item = 1072003; + else if(stance == MapleJob.MAGICIAN) item = 1072077; + else if(stance == MapleJob.BOWMAN || stance == MapleJob.CROSSBOWMAN) item = 1072081; + else if(stance == MapleJob.THIEF) item = 1072035; + else if(stance == MapleJob.BRAWLER || stance == MapleJob.GUNSLINGER) item = 1072294; + else item = 1072018; + + qm.gainItem(item, 1); + qm.gainItem(4000007, -150); + qm.gainExp(2200); + qm.completeQuest(); + + qm.sendOk("Alright, if you need work sometime down the road, feel free to come back and see me. This town sure can use a person like you for help~"); + } + + else if (status == 2) { + qm.dispose(); + } } \ No newline at end of file diff --git a/scripts/quest/20514.js b/scripts/quest/20514.js index f7c6fcb65a..b487c7a658 100644 --- a/scripts/quest/20514.js +++ b/scripts/quest/20514.js @@ -20,9 +20,6 @@ // @Author Ronan -importPackage(Packages.constants.game); -importPackage(Packages.server); - function raiseOpen() { var chr = qm.getPlayer(); var questStatus = chr.getQuestStatus(qm.getQuest()); @@ -34,11 +31,13 @@ function raiseOpen() { var diffExp = chr.getExp() - qm.getQuestProgressInt(20515, 1); var initLevel = qm.getQuestProgressInt(20515, 0); + const ExpTable = Java.type('constants.game.ExpTable'); for (var i = initLevel; i < chr.getLevel(); i++) { diffExp += ExpTable.getExpNeededForLevel(i); } if (diffExp > 0) { // thanks IxianMace for noticing Mimiana egg not following progress by EXP + const MapleItemInformationProvider = Java.type('server.MapleItemInformationProvider'); var consItem = MapleItemInformationProvider.getInstance().getQuestConsumablesInfo(4220137); var exp = consItem.exp; var grade = consItem.grade; diff --git a/scripts/quest/21000.js b/scripts/quest/21000.js index 711d31c3a8..7977b5c09d 100644 --- a/scripts/quest/21000.js +++ b/scripts/quest/21000.js @@ -26,8 +26,6 @@ Quest ID : 21000 */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/21010.js b/scripts/quest/21010.js index 2f30a5eef5..3367c3a85b 100644 --- a/scripts/quest/21010.js +++ b/scripts/quest/21010.js @@ -22,7 +22,6 @@ /* Author : kevintjuh93 */ -importPackage(Packages.client); var status = -1; diff --git a/scripts/quest/21101.js b/scripts/quest/21101.js index 05636b3cbc..ba9e53e5a0 100644 --- a/scripts/quest/21101.js +++ b/scripts/quest/21101.js @@ -19,8 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.client); -importPackage(Packages.config); status = -1; @@ -47,7 +45,8 @@ function start(mode, type, selection) { qm.changeJobById(2100); qm.resetStats(); - + + const YamlConfig = Java.type('config.YamlConfig'); if (YamlConfig.config.server.USE_FULL_ARAN_SKILLSET) { qm.teachSkill(21000000, 0, 10, -1); //combo ability qm.teachSkill(21001003, 0, 20, -1); //polearm booster diff --git a/scripts/quest/21200.js b/scripts/quest/21200.js index c7e7bb101d..2659dc0c14 100644 --- a/scripts/quest/21200.js +++ b/scripts/quest/21200.js @@ -19,7 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.client); var status = -1; diff --git a/scripts/quest/21201.js b/scripts/quest/21201.js index f03e71968e..8af9601a89 100644 --- a/scripts/quest/21201.js +++ b/scripts/quest/21201.js @@ -19,8 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.client); -importPackage(Packages.config); var status = -1; @@ -65,7 +63,8 @@ function end(mode, type, selection) { qm.gainItem(1142130, true); qm.changeJobById(2110); - + + const YamlConfig = Java.type('config.YamlConfig'); if (YamlConfig.config.server.USE_FULL_ARAN_SKILLSET) { qm.teachSkill(21100000, 0, 20, -1); //polearm mastery qm.teachSkill(21100002, 0, 30, -1); //final charge diff --git a/scripts/quest/21302.js b/scripts/quest/21302.js index 4719a4a61f..cfb2f4ffe1 100644 --- a/scripts/quest/21302.js +++ b/scripts/quest/21302.js @@ -19,8 +19,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -importPackage(Packages.client); -importPackage(Packages.config); var status = -1; @@ -50,7 +48,8 @@ function end(mode, type, selection) { qm.gainItem(1142131, true); qm.changeJobById(2111); - + + const YamlConfig = Java.type('config.YamlConfig'); if (YamlConfig.config.server.USE_FULL_ARAN_SKILLSET) { qm.teachSkill(21110002, 0, 20, -1); //full swing } diff --git a/scripts/quest/21401.js b/scripts/quest/21401.js index 600aaded9e..380cc7a6aa 100644 --- a/scripts/quest/21401.js +++ b/scripts/quest/21401.js @@ -1,5 +1,3 @@ -importPackage(Packages.server.life); - var status = -1; function start(mode, type, selection) { @@ -76,7 +74,9 @@ function end(mode, type, selection) { function spawnMob(x, y, id, map) { if(map.getMonsterById(id) != null) return; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); + const Point = Java.type('java.awt.Point'); var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + map.spawnMonsterOnGroundBelow(mob, new Point(x, y)); } \ No newline at end of file diff --git a/scripts/quest/21703.js b/scripts/quest/21703.js index 380e6e59f7..7e8333bf90 100644 --- a/scripts/quest/21703.js +++ b/scripts/quest/21703.js @@ -1,5 +1,3 @@ - -importPackage(Packages.client); var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2260.js b/scripts/quest/2260.js index 852411aaaa..491db22c2e 100644 --- a/scripts/quest/2260.js +++ b/scripts/quest/2260.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.constants.game); - var status = -1; function start(mode, type, selection) { @@ -60,6 +58,7 @@ function end(mode, type, selection) { status--; if (status == 0) { + const GameConstants = Java.type('constants.game.GameConstants'); if(GameConstants.getJobBranch(qm.getPlayer().getJob()) == 1) { qm.sendNext("Eh, didn't you get the #r2nd job advancement#k yet?"); qm.dispose(); diff --git a/scripts/quest/2293.js b/scripts/quest/2293.js index dd9cefc5d0..62294055cf 100644 --- a/scripts/quest/2293.js +++ b/scripts/quest/2293.js @@ -20,8 +20,6 @@ Description: The Last Song */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2312.js b/scripts/quest/2312.js index 2111510cd7..054f28fa7e 100644 --- a/scripts/quest/2312.js +++ b/scripts/quest/2312.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2313.js b/scripts/quest/2313.js index 1deddac73e..7c10cfbb7b 100644 --- a/scripts/quest/2313.js +++ b/scripts/quest/2313.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2315.js b/scripts/quest/2315.js index 2432054981..d4a9639d3b 100644 --- a/scripts/quest/2315.js +++ b/scripts/quest/2315.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2316.js b/scripts/quest/2316.js index f55d8af293..6e4adf133b 100644 --- a/scripts/quest/2316.js +++ b/scripts/quest/2316.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { @@ -25,10 +23,10 @@ function start(mode, type, selection) { } if (status == 0) qm.sendAcceptDecline("I think i've heard of a potion that breaks these kinds of barriers. I think it's called #bKiller Mushroom Spores#k? Hmmm... outside, you'll find the Mushroom Scholar #bScarrs#k waiting outside. #bScarrs#k is an expert on mushrooms, so go talk to him."); - else if (status == 1){ + else if (status == 1) { qm.forceStartQuest(); qm.sendOk("I am confident #kScarrs#k will do everything to help you."); - else if (status == 2){ + } else if (status == 2){ qm.dispose(); } } @@ -36,14 +34,14 @@ function start(mode, type, selection) { function end(mode, type, selection) { status++; if (mode != 1) { - if(type == 1 && mode == 0) - status -= 2; - else{ + if(type == 1 && mode == 0) { + status -= 2; + } else { qm.dispose(); return; } } - if (status == 0) + if (status == 0) { qm.sendOk("Ah, so you're the explorer people were talking about. I'm #bScarrs, the Royal Mushroom Scholar#k representing the Kingdom of Mushroom. So you need some #kKiller Mushroom Spores#k?"); } else if (status == 1){ qm.forceCompleteQuest(); @@ -51,6 +49,6 @@ function end(mode, type, selection) { qm.sendOk("#kKiller Mushroom Spores#k... I think i've heard of them before..."); } else if (status == 2) { qm.dispose(); - } + } } \ No newline at end of file diff --git a/scripts/quest/2317.js b/scripts/quest/2317.js index 919c75815f..797a11ec91 100644 --- a/scripts/quest/2317.js +++ b/scripts/quest/2317.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2318.js b/scripts/quest/2318.js index 40fc347f56..85d10153a6 100644 --- a/scripts/quest/2318.js +++ b/scripts/quest/2318.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2319.js b/scripts/quest/2319.js index a7897a0978..2c9a4b7347 100644 --- a/scripts/quest/2319.js +++ b/scripts/quest/2319.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2320.js b/scripts/quest/2320.js index 381d762e37..b00e711bef 100644 --- a/scripts/quest/2320.js +++ b/scripts/quest/2320.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2321.js b/scripts/quest/2321.js index b9fc263f00..8bb1c962f1 100644 --- a/scripts/quest/2321.js +++ b/scripts/quest/2321.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/2322.js b/scripts/quest/2322.js index 6ce6f2309b..d07be2c103 100644 --- a/scripts/quest/2322.js +++ b/scripts/quest/2322.js @@ -8,8 +8,6 @@ Version 1.0 - Script Done.(18/7/2010) ============================================================= */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/3239.js b/scripts/quest/3239.js index 4e89e74cca..2ba8548747 100644 --- a/scripts/quest/3239.js +++ b/scripts/quest/3239.js @@ -4,25 +4,27 @@ function end(mode, type, selection) { if (mode == -1) { qm.dispose(); } else { - if(mode == 0 && type > 0) { + if (mode == 0 && type > 0) { qm.dispose(); return; } - - if (mode == 1) + + if (mode == 1) { status++; - else + } else { status--; - + } + if (status == 0) { - if(qm.haveItem(4031092, 10)) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() >= 1) { + if (qm.haveItem(4031092, 10)) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if (qm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) { qm.sendOk("Well done! You brought back all the #t4031092# that were missing. Here, take this scroll as a token of my gratitude..."); - } else { + } else { qm.sendOk("Free a space on your USE inventory before receiving your prize."); qm.dispose(); return; - } + } } else { qm.sendOk("Please return me 10 #t4031092# that went missing on this room."); qm.dispose(); @@ -30,12 +32,17 @@ function end(mode, type, selection) { } } else if (status == 1) { qm.gainItem(4031092, -10); - + rnd = Math.floor(Math.random() * 4); - if(rnd == 0) qm.gainItem(2040704, 1); - else if(rnd == 1) qm.gainItem(2040705, 1); - else if(rnd == 2) qm.gainItem(2040707, 1); - else qm.gainItem(2040708, 1); + if (rnd == 0) { + qm.gainItem(2040704, 1); + } else if (rnd == 1) { + qm.gainItem(2040705, 1); + } else if (rnd == 2) { + qm.gainItem(2040707, 1); + } else { + qm.gainItem(2040708, 1); + } qm.gainExp(2700); qm.forceCompleteQuest(); diff --git a/scripts/quest/3314.js b/scripts/quest/3314.js index e549b69e8d..f54e2b99b0 100644 --- a/scripts/quest/3314.js +++ b/scripts/quest/3314.js @@ -18,12 +18,11 @@ along with this program. If not, see . */ -importPackage(Packages.client); - var status = -1; function isPillUsed(ch) { - return ch.getBuffSource(MapleBuffStat.HPREC) == 2022198; + const MapleBuffStat = Java.type('client.MapleBuffStat'); + return ch.getBuffSource(MapleBuffStat.HPREC) == 2022198; } function end(mode, type, selection) { diff --git a/scripts/quest/3320.js b/scripts/quest/3320.js index 4c091cc6bc..564348b3ec 100644 --- a/scripts/quest/3320.js +++ b/scripts/quest/3320.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/3321.js b/scripts/quest/3321.js index e53fb914b4..aa330f1164 100644 --- a/scripts/quest/3321.js +++ b/scripts/quest/3321.js @@ -18,8 +18,6 @@ along with this program. If not, see . */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { diff --git a/scripts/quest/3414.js b/scripts/quest/3414.js index 26c5a87aca..a39808d21b 100644 --- a/scripts/quest/3414.js +++ b/scripts/quest/3414.js @@ -1,5 +1,3 @@ -importPackage(Packages.client); - var item; var stance; var status = -1; @@ -17,7 +15,8 @@ function end(mode, type, selection) { } else if(status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() < 1) { qm.getPlayer().dropMessage(1, "USE inventory full."); qm.dispose(); return; @@ -25,11 +24,12 @@ function end(mode, type, selection) { var talkStr = "Here, please select the scroll of your choice. All success rates are at 10%. \r\n\r\n#rSELECT A ITEM\r\n#b" stance = qm.getPlayer().getJobStyle(); - - if(stance == Packages.client.MapleJob.WARRIOR || stance == Packages.client.MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); - else if(stance == Packages.client.MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); - else if(stance == Packages.client.MapleJob.BOWMAN || stance == Packages.client.MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); - else if(stance == Packages.client.MapleJob.THIEF) vecItem = new Array(2043302, 2044702); + + const MapleJob = Java.type('client.MapleJob'); + if(stance == MapleJob.WARRIOR || stance == MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); + else if(stance == MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); + else if(stance == MapleJob.BOWMAN || stance == MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); + else if(stance == MapleJob.THIEF) vecItem = new Array(2043302, 2044702); else vecItem = new Array(2044802, 2044902); for (var i = 0; i < vecItem.length; i++) diff --git a/scripts/quest/3414_free10rate.js b/scripts/quest/3414_free10rate.js index fa84eab33f..22bb951a07 100644 --- a/scripts/quest/3414_free10rate.js +++ b/scripts/quest/3414_free10rate.js @@ -1,5 +1,3 @@ -importPackage(Packages.client); - var item; var stance; var status = -1; @@ -20,10 +18,11 @@ function end(mode, type, selection) { var talkStr = "Here, please select the scroll of your choice. All success rates are at 10%. \r\n\r\n#rSELECT A ITEM\r\n#b" stance = qm.getPlayer().getJobStyle(); - if(stance == Packages.client.MapleJob.WARRIOR || stance == Packages.client.MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); - else if(stance == Packages.client.MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); - else if(stance == Packages.client.MapleJob.BOWMAN || stance == Packages.client.MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); - else if(stance == Packages.client.MapleJob.THIEF) vecItem = new Array(2043302, 2044702); + const MapleJob = Java.type('client.MapleJob'); + if(stance == MapleJob.WARRIOR || stance == MapleJob.BEGINNER) vecItem = new Array(2043002, 2043102, 2043202, 2044002, 2044102, 2044202, 2044402, 2044302); + else if(stance == MapleJob.MAGICIAN) vecItem = new Array(2043702, 2043802); + else if(stance == MapleJob.BOWMAN || stance == MapleJob.CROSSBOWMAN) vecItem = new Array(2044502, 2044602); + else if(stance == MapleJob.THIEF) vecItem = new Array(2043302, 2044702); else vecItem = new Array(2044802, 2044902); for (var i = 0; i < vecItem.length; i++) diff --git a/scripts/quest/3437.js b/scripts/quest/3437.js index 6c159e63f2..da1ddd9077 100644 --- a/scripts/quest/3437.js +++ b/scripts/quest/3437.js @@ -1,5 +1,3 @@ -importPackage(Packages.client); - var item; var stance; var status = -1; @@ -15,7 +13,8 @@ function end(mode, type, selection) { if(status == 0) { qm.sendNext("What the? Are you telling me you've already taken out 150 #o4230120#s? And these ... yes, these really are 120 #t4000122#s. I was wondering how you were going to complete this mission all by yourself, but you took care of it just fine. Alright, here ... this is a very important item for me, but please take it."); } else if(status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.EQUIP).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.EQUIP).getNumFreeSlot() < 1) { qm.sendOk("Please free a EQUIP inventory slot to receive the reward."); qm.dispose(); return; @@ -24,11 +23,12 @@ function end(mode, type, selection) { var talkStr = "Do you like the glove? I've kept this for a while, and I was planning on using it someday, but it looks much better on you. Please put it to good use; besides, I got so much stuff from the Sector, that I don't need it anymore."; stance = qm.getPlayer().getJobStyle(); - if(stance == Packages.client.MapleJob.WARRIOR) item = 1082024; - else if(stance == Packages.client.MapleJob.MAGICIAN) item = 1082063; - else if(stance == Packages.client.MapleJob.BOWMAN || stance == Packages.client.MapleJob.CROSSBOWMAN) item = 1082072; - else if(stance == Packages.client.MapleJob.THIEF) item = 1082076; - else if(stance == Packages.client.MapleJob.BRAWLER || stance == Packages.client.MapleJob.GUNSLINGER) item = 1082195; + const MapleJob = Java.type('client.MapleJob'); + if(stance == MapleJob.WARRIOR) item = 1082024; + else if(stance == MapleJob.MAGICIAN) item = 1082063; + else if(stance == MapleJob.BOWMAN || stance == MapleJob.CROSSBOWMAN) item = 1082072; + else if(stance == MapleJob.THIEF) item = 1082076; + else if(stance == MapleJob.BRAWLER || stance == MapleJob.GUNSLINGER) item = 1082195; else item = 1082149; qm.sendNext(talkStr); diff --git a/scripts/quest/3452.js b/scripts/quest/3452.js index a87f73f566..709f74d959 100644 --- a/scripts/quest/3452.js +++ b/scripts/quest/3452.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var status = -1; function end(mode, type, selection) { @@ -12,7 +10,8 @@ function end(mode, type, selection) { qm.sendNext("Take these #bMana Elixir Pills#k as a token of my gratitude."); } else if (status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() >= 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) { qm.gainItem(4000099, -1); qm.gainItem(2000011, 50); qm.gainExp(8000); diff --git a/scripts/quest/3454.js b/scripts/quest/3454.js index 84f2c77bf4..b6d0ebb721 100644 --- a/scripts/quest/3454.js +++ b/scripts/quest/3454.js @@ -44,7 +44,8 @@ function end(mode, type, selection) { status--; if (status == 0) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) { + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if(qm.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() < 1) { qm.sendOk("Make room on your ETC inventory first."); qm.dispose(); return; diff --git a/scripts/quest/3514.js b/scripts/quest/3514.js index 696e6bbcea..2dd7a00afb 100644 --- a/scripts/quest/3514.js +++ b/scripts/quest/3514.js @@ -23,8 +23,6 @@ * The sorcerer who sells emotions */ -importPackage(Packages.client); - var status = -1; function start(mode, type, selection) { @@ -46,7 +44,8 @@ function start(mode, type, selection) { } function usedPotion(ch) { - return ch.getBuffSource(MapleBuffStat.HPREC) == 2022337; + const MapleBuffStat = Java.type('client.MapleBuffStat'); + return ch.getBuffSource(MapleBuffStat.HPREC) == 2022337; } function end(mode, type, selection) { diff --git a/scripts/quest/3833.js b/scripts/quest/3833.js index b01f5946fa..05ac8aa67a 100644 --- a/scripts/quest/3833.js +++ b/scripts/quest/3833.js @@ -1,5 +1,3 @@ -importPackage(Packages.tools); - var status = -1; function end(mode, type, selection) { @@ -10,50 +8,41 @@ function end(mode, type, selection) { if (status == 0) { qm.sendOk("Great! You managed to get the herb I need. As a #btoken of gratitude#k, take this item to help on your journey."); } else if (status == 1) { - if(qm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.USE).getNumFreeSlot() >= 2) { - if(qm.haveItem(4000294, 1000)) { - qm.gainItem(4000294, -1000); - qm.gainItem(2040501, 1); - qm.gainItem(2000005, 50); - qm.gainExp(54000); - qm.forceCompleteQuest(); - } - - else if(qm.haveItem(4000294, 600)) { - qm.gainItem(4000294, -600); - qm.gainItem(2020013, 50); - qm.gainExp(54000); - qm.forceCompleteQuest(); - } + const MapleInventoryType = Java.type('client.inventory.MapleInventoryType'); + if (qm.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 2) { + if (qm.haveItem(4000294, 1000)) { + qm.gainItem(4000294, -1000); + qm.gainItem(2040501, 1); + qm.gainItem(2000005, 50); + qm.gainExp(54000); + qm.forceCompleteQuest(); + } else if (qm.haveItem(4000294, 600)) { + qm.gainItem(4000294, -600); + qm.gainItem(2020013, 50); + qm.gainExp(54000); + qm.forceCompleteQuest(); + } else if (qm.haveItem(4000294, 500)) { + qm.gainItem(4000294, -500); + qm.gainExp(54000); + qm.forceCompleteQuest(); + } else if (qm.haveItem(4000294, 100)) { + qm.gainItem(4000294, -100); + qm.gainExp(45000); + qm.forceCompleteQuest(); + } else if (qm.haveItem(4000294, 50)) { + qm.gainItem(4000294, -50); + qm.gainItem(2020007, 50); + qm.gainExp(10000); + qm.forceCompleteQuest(); + } else if (qm.haveItem(4000294, 1)) { + qm.gainItem(4000294, -1); + qm.gainItem(2000000, 1); + qm.gainExp(10); + qm.forceCompleteQuest(); + } - else if(qm.haveItem(4000294, 500)) { - qm.gainItem(4000294, -500); - qm.gainExp(54000); - qm.forceCompleteQuest(); + qm.dispose(); } - - else if(qm.haveItem(4000294, 100)) { - qm.gainItem(4000294, -100); - qm.gainExp(45000); - qm.forceCompleteQuest(); - } - - else if(qm.haveItem(4000294, 50)) { - qm.gainItem(4000294, -50); - qm.gainItem(2020007, 50); - qm.gainExp(10000); - qm.forceCompleteQuest(); - } - - else if(qm.haveItem(4000294, 1)) { - qm.gainItem(4000294, -1); - qm.gainItem(2000000, 1); - qm.gainExp(10); - qm.forceCompleteQuest(); - } - - qm.dispose(); - } else { qm.sendOk("Could you make #b2 slots available#k on your USE inventory before receiving your reward?"); } diff --git a/scripts/quest/3941.js b/scripts/quest/3941.js index 6588efd4af..f24af97ebd 100644 --- a/scripts/quest/3941.js +++ b/scripts/quest/3941.js @@ -20,10 +20,9 @@ /* Steal queen's silk */ -importPackage(Packages.client); - function isTigunMorphed(ch) { - return ch.getBuffSource(MapleBuffStat.MORPH) == 2210005; + const MapleBuffStat = Java.type('client.MapleBuffStat'); + return ch.getBuffSource(MapleBuffStat.MORPH) == 2210005; } var status = -1; diff --git a/scripts/quest/4659.js b/scripts/quest/4659.js index 2e50f3ca01..d612aab6f3 100644 --- a/scripts/quest/4659.js +++ b/scripts/quest/4659.js @@ -24,8 +24,6 @@ Map(s): New Leaf City Description: Quest - Pet Evolution */ -importPackage(Packages.client.inventory.manipulator); -importPackage(Packages.server); var status = -1; diff --git a/scripts/quest/8185.js b/scripts/quest/8185.js index dccab63ba8..64dfb33217 100644 --- a/scripts/quest/8185.js +++ b/scripts/quest/8185.js @@ -25,8 +25,6 @@ Description: Quest - Pet Evolution2 */ -importPackage (Packages.net.server.channel.handlers); - var status = -1; function end(mode, type, selection) { diff --git a/scripts/quest/8189.js b/scripts/quest/8189.js index bc0d038f3a..b349ef9e39 100644 --- a/scripts/quest/8189.js +++ b/scripts/quest/8189.js @@ -24,7 +24,6 @@ Map(s): New Leaf City : Town Center Description: Quest - Pet Re-Evolution */ -importPackage(Packages.server); var status = -1; diff --git a/scripts/reactor/2408002.js b/scripts/reactor/2408002.js index 3b55b5d787..edc7840696 100644 --- a/scripts/reactor/2408002.js +++ b/scripts/reactor/2408002.js @@ -25,8 +25,6 @@ *@author Jvlaple */ -importPackage(Packages.client.inventory); - function act() { var eim = rm.getPlayer().getEventInstance(); var womanfred = eim.getMapFactory().getMap(240050100); @@ -64,7 +62,8 @@ function act() { } eim.setIntProperty(vvpStage + "stageclear", 1); - + + const Item = Java.type('client.inventory.Item'); var tehWomanfred = new Item(vvpKey, 0, 1); var theWomanfred = womanfred.getReactorByName("keyDrop1"); var dropper = eim.getPlayers().get(0); diff --git a/scripts/reactor/2519000.js b/scripts/reactor/2519000.js index 25ef4387be..e977cb07af 100644 --- a/scripts/reactor/2519000.js +++ b/scripts/reactor/2519000.js @@ -22,13 +22,11 @@ /*2519000.js - Reactor used at the door on stage 4. *@author Ronan */ - -importPackage(Packages.tools); -importPackage(java.awt); - + function act() { var denyWidth = 320, denyHeight = 150; var denyPos = rm.getReactor().getPosition(); + const Rectangle = Java.type('java.awt.Rectangle'); var denyArea = new Rectangle(denyPos.getX() - denyWidth / 2, denyPos.getY() - denyHeight / 2, denyWidth, denyHeight); rm.getReactor().getMap().setAllowSpawnPointInBox(false, denyArea); diff --git a/scripts/reactor/2519001.js b/scripts/reactor/2519001.js index 9a9a0e4a2a..9839837e06 100644 --- a/scripts/reactor/2519001.js +++ b/scripts/reactor/2519001.js @@ -23,12 +23,10 @@ *@author Ronan */ -importPackage(Packages.tools); -importPackage(java.awt); - function act() { var denyWidth = 320, denyHeight = 150; var denyPos = rm.getReactor().getPosition(); + const Rectangle = Java.type('java.awt.Rectangle'); var denyArea = new Rectangle(denyPos.getX() - denyWidth / 2, denyPos.getY() - denyHeight / 2, denyWidth, denyHeight); rm.getReactor().getMap().setAllowSpawnPointInBox(false, denyArea); diff --git a/scripts/reactor/2519002.js b/scripts/reactor/2519002.js index ce3da673eb..81124185ad 100644 --- a/scripts/reactor/2519002.js +++ b/scripts/reactor/2519002.js @@ -23,12 +23,10 @@ *@author Ronan */ -importPackage(Packages.tools); -importPackage(java.awt); - function act() { var denyWidth = 320, denyHeight = 150; var denyPos = rm.getReactor().getPosition(); + const Rectangle = Java.type('java.awt.Rectangle'); var denyArea = new Rectangle(denyPos.getX() - denyWidth / 2, denyPos.getY() - denyHeight / 2, denyWidth, denyHeight); rm.getReactor().getMap().setAllowSpawnPointInBox(false, denyArea); diff --git a/scripts/reactor/2519003.js b/scripts/reactor/2519003.js index 80a371e5c1..5a8e33fc93 100644 --- a/scripts/reactor/2519003.js +++ b/scripts/reactor/2519003.js @@ -23,12 +23,10 @@ *@author Ronan */ -importPackage(Packages.tools); -importPackage(java.awt); - function act() { var denyWidth = 320, denyHeight = 150; var denyPos = rm.getReactor().getPosition(); + const Rectangle = Java.type('java.awt.Rectangle'); var denyArea = new Rectangle(denyPos.getX() - denyWidth / 2, denyPos.getY() - denyHeight / 2, denyWidth, denyHeight); var map = rm.getReactor().getMap(); diff --git a/scripts/reactor/2708000.js b/scripts/reactor/2708000.js index 73c35f07fd..f25f3db81a 100644 --- a/scripts/reactor/2708000.js +++ b/scripts/reactor/2708000.js @@ -20,12 +20,11 @@ along with this program. If not, see . */ -importPackage(Packages.server.life); - function spawnJrBoss(mobObj) { mobObj.getMap().killMonster(mobObj.getId()); var spawnid = mobObj.getId() - 17; - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); var mob = MapleLifeFactory.getMonster(spawnid); mobObj.getMap().spawnMonsterOnGroundBelow(mob, mobObj.getPosition()); } diff --git a/scripts/reactor/5511000.js b/scripts/reactor/5511000.js index 748aabe1aa..810e44d48c 100644 --- a/scripts/reactor/5511000.js +++ b/scripts/reactor/5511000.js @@ -2,14 +2,9 @@ * 5511000.js: Summons Targa. */ -function summonBoss() { - rm.spawnMonster(9420542,-527,637); - rm.changeMusic("Bgm09/TimeAttack"); - rm.mapMessage(6, "Beware! The furious Targa has shown himself!"); -} - function act() { - if (rm.getReactor().getMap().getMonsterById(9420542) == null) { - rm.schedule("summonBoss", 3200); + const targaMobId = 9420542; + if (rm.getReactor().getMap().getMonsterById(targaMobId) == null) { + rm.summonBossDelayed(targaMobId, 3200, -527, 637, "Bgm09/TimeAttack", "Beware! The furious Targa has shown himself!"); } } \ No newline at end of file diff --git a/scripts/reactor/5511001.js b/scripts/reactor/5511001.js index 8dc042274d..e4dc2313ac 100644 --- a/scripts/reactor/5511001.js +++ b/scripts/reactor/5511001.js @@ -2,14 +2,9 @@ * 5511001.js: Summons Scarlion. */ -function summonBoss() { - rm.spawnMonster(9420547,-238,636); - rm.changeMusic("Bgm09/TimeAttack"); - rm.mapMessage(6, "Beware! The furious Scarlion has shown himself!"); -} - function act() { - if (rm.getReactor().getMap().getMonsterById(9420547) == null) { - rm.schedule("summonBoss", 3200); - } + const scarlionMobId = 9420547; + if (rm.getReactor().getMap().getMonsterById(scarlionMobId) == null) { + rm.summonBossDelayed(scarlionMobId, 3200, -238, 636, "Bgm09/TimeAttack", "Beware! The furious Scarlion has shown himself!"); + } } \ No newline at end of file diff --git a/scripts/reactor/6701000.js b/scripts/reactor/6701000.js index a6b44d559e..2f873daa13 100644 --- a/scripts/reactor/6701000.js +++ b/scripts/reactor/6701000.js @@ -26,12 +26,11 @@ * */ -importPackage(Packages.server.life); - function act(){ var startId = 9400523; var mobObj, mapObj = rm.getMap(); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); for(var i = 0; i < 7; i++) { mobObj = MapleLifeFactory.getMonster(startId + Math.floor(Math.random() * 3)); mapObj.spawnMonsterOnGroundBelow(mobObj, rm.getReactor().getPosition()); diff --git a/scripts/reactor/6701001.js b/scripts/reactor/6701001.js index a6b44d559e..2f873daa13 100644 --- a/scripts/reactor/6701001.js +++ b/scripts/reactor/6701001.js @@ -26,12 +26,11 @@ * */ -importPackage(Packages.server.life); - function act(){ var startId = 9400523; var mobObj, mapObj = rm.getMap(); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); for(var i = 0; i < 7; i++) { mobObj = MapleLifeFactory.getMonster(startId + Math.floor(Math.random() * 3)); mapObj.spawnMonsterOnGroundBelow(mobObj, rm.getReactor().getPosition()); diff --git a/scripts/reactor/6701002.js b/scripts/reactor/6701002.js index a6b44d559e..2f873daa13 100644 --- a/scripts/reactor/6701002.js +++ b/scripts/reactor/6701002.js @@ -26,12 +26,11 @@ * */ -importPackage(Packages.server.life); - function act(){ var startId = 9400523; var mobObj, mapObj = rm.getMap(); - + + const MapleLifeFactory = Java.type('server.life.MapleLifeFactory'); for(var i = 0; i < 7; i++) { mobObj = MapleLifeFactory.getMonster(startId + Math.floor(Math.random() * 3)); mapObj.spawnMonsterOnGroundBelow(mobObj, rm.getReactor().getPosition()); diff --git a/scripts/reactor/9101000.js b/scripts/reactor/9101000.js index 10fc373076..6467d5d633 100644 --- a/scripts/reactor/9101000.js +++ b/scripts/reactor/9101000.js @@ -27,9 +27,9 @@ * [x]shows animation, * [x]makes stirges and stuff appear */ -importPackage(Packages.tools); function act() { + const MaplePacketCreator = Java.type('tools.MaplePacketCreator'); rm.spawnMonster(9300061, 1, 0, 0); // (0, 0) is temp position rm.getClient().getMap().startMapEffect("Protect the Moon Bunny that's pounding the mill, and gather up 10 Moon Bunny's Rice Cakes!", 5120016, 7000); rm.getClient().getMap().broadcastMessage(MaplePacketCreator.bunnyPacket()); // Protect the Moon Bunny! diff --git a/sql/readme.txt b/sql/readme.txt deleted file mode 100644 index c47cb542f9..0000000000 --- a/sql/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ ----- Cosmic MySQL Database ---- - -These SQL files must be executed IN ORDER to set up the database: - - db_database.sql - - db_drops.sql - - db_shopupdate.sql (optional & require provided WZs) \ No newline at end of file diff --git a/src/main/java/client/MapleClient.java b/src/main/java/client/MapleClient.java index 77edc0401f..83f76f6e5b 100644 --- a/src/main/java/client/MapleClient.java +++ b/src/main/java/client/MapleClient.java @@ -24,7 +24,6 @@ package client; import client.inventory.MapleInventoryType; import config.YamlConfig; import constants.game.GameConstants; -import jdk.nashorn.api.scripting.NashornScriptEngine; import net.server.Server; import net.server.audit.locks.MonitoredLockType; import net.server.audit.locks.factory.MonitoredReentrantLockFactory; @@ -50,6 +49,7 @@ import server.maps.MapleMap; import server.maps.MapleMiniDungeonInfo; import tools.*; +import javax.script.ScriptEngine; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.InetAddress; @@ -85,7 +85,7 @@ public class MapleClient { private long lastPong; private int gmlevel; private Set macs = new HashSet<>(); - private Map engines = new HashMap<>(); + private Map engines = new HashMap<>(); private byte characterSlots = 3; private byte loginattempt = 0; private String pin = ""; @@ -1041,11 +1041,11 @@ public class MapleClient { gmlevel = level; } - public void setScriptEngine(String name, NashornScriptEngine e) { - engines.put(name, e); + public void setScriptEngine(String name, ScriptEngine e) { + engines.put(name, e); } - public NashornScriptEngine getScriptEngine(String name) { + public ScriptEngine getScriptEngine(String name) { return engines.get(name); } diff --git a/src/main/java/constants/net/ServerConstants.java b/src/main/java/constants/net/ServerConstants.java index 306ba287a4..2905adbccd 100644 --- a/src/main/java/constants/net/ServerConstants.java +++ b/src/main/java/constants/net/ServerConstants.java @@ -5,32 +5,6 @@ public class ServerConstants { //Server Version public static short VERSION = 83; - //Java Configuration - public static final boolean JAVA_8 = getJavaVersion() >= 8; //Max amount of times a party leader is allowed to persist on the Party Search before entry expiration (thus needing to manually restart the Party Search to be able to search for members). - //Debug Variables public static int[] DEBUG_VALUES = new int[10]; // Field designed for packet testing purposes - - // https://github.com/openstreetmap/josm/blob/a3a6e8a6b657cf4c5b4c64ea14d6e87be6280d65/src/org/openstreetmap/josm/tools/Utils.java#L1566-L1585 - // Added by kolakcc (Familiar) - /** - * Returns the Java version as an int value. - * @return the Java version as an int value (8, 9, etc.) - * @since 12130 - */ - public static int getJavaVersion() { - String version = System.getProperty("java.version"); - if (version.startsWith("1.")) { - version = version.substring(2); - } - // Allow these formats: - // 1.8.0_72-ea - // 9-ea - // 9 - // 9.0.1 - int dotPos = version.indexOf('.'); - int dashPos = version.indexOf('-'); - return Integer.parseInt(version.substring(0, - dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1)); - } } diff --git a/src/main/java/scripting/AbstractPlayerInteraction.java b/src/main/java/scripting/AbstractPlayerInteraction.java index f7a9b1b84e..35de7419da 100644 --- a/src/main/java/scripting/AbstractPlayerInteraction.java +++ b/src/main/java/scripting/AbstractPlayerInteraction.java @@ -28,7 +28,6 @@ import client.inventory.manipulator.MapleInventoryManipulator; import config.YamlConfig; import constants.game.GameConstants; import constants.inventory.ItemConstants; -import constants.net.ServerConstants; import net.server.Server; import net.server.guild.MapleGuild; import net.server.world.MapleParty; @@ -217,45 +216,30 @@ public class AbstractPlayerInteraction { public boolean canHold(int itemid, int quantity, int removeItemid, int removeQuantity) { return canHoldAllAfterRemoving(Collections.singletonList(itemid), Collections.singletonList(quantity), Collections.singletonList(removeItemid), Collections.singletonList(removeQuantity)); } - - private List convertToIntegerArray(List list) { - List intList = new ArrayList<>(); // JAVA 7 Rhino script engine. Thanks Bruno, felipepm10 for noticing a typecast issue here. - - if (ServerConstants.JAVA_8) { - for (Object d: list) { - intList.add((Integer) d); - } - } else { - for (Object d: list) { - intList.add(((Double) d).intValue()); - } - } - return intList; + private List convertToIntegerList(List objects) { + List intList = new ArrayList<>(); + + for (Object object : objects) { + intList.add((Integer) object); } - - public boolean canHoldAll(List itemids) { - List quantity = new LinkedList<>(); - - if (ServerConstants.JAVA_8) { - Integer intOne = 1; - - for (int i = 0; i < itemids.size(); i++) { - quantity.add(intOne); - } - } else { - Double doubleOne = 1.0; - - for (int i = 0; i < itemids.size(); i++) { - quantity.add(doubleOne); - } - } - - return canHoldAll(itemids, quantity); + + return intList; + } + + public boolean canHoldAll(List itemids) { + List quantity = new LinkedList<>(); + + final int intOne = 1; + for (int i = 0; i < itemids.size(); i++) { + quantity.add(intOne); } + + return canHoldAll(itemids, quantity); + } public boolean canHoldAll(List itemids, List quantity) { - return canHoldAll(convertToIntegerArray(itemids), convertToIntegerArray(quantity), true); + return canHoldAll(convertToIntegerList(itemids), convertToIntegerList(quantity), true); } private boolean canHoldAll(List itemids, List quantity, boolean isInteger) { diff --git a/src/main/java/scripting/AbstractScriptManager.java b/src/main/java/scripting/AbstractScriptManager.java index ec9ad7f043..187f46b3a0 100644 --- a/src/main/java/scripting/AbstractScriptManager.java +++ b/src/main/java/scripting/AbstractScriptManager.java @@ -22,58 +22,68 @@ along with this program. If not, see . package scripting; import client.MapleClient; +import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine; +import tools.FilePrinter; +import javax.script.*; import java.io.File; import java.io.FileReader; import java.io.IOException; -import javax.script.*; - -import constants.net.ServerConstants; -import jdk.nashorn.api.scripting.NashornScriptEngine; -import tools.FilePrinter; - /** * * @author Matze */ public abstract class AbstractScriptManager { - private ScriptEngineFactory sef; + private final ScriptEngineFactory sef; protected AbstractScriptManager() { - sef = new ScriptEngineManager().getEngineByName("javascript").getFactory(); + sef = new ScriptEngineManager().getEngineByName("graal.js").getFactory(); } - protected NashornScriptEngine getScriptEngine(String path) { + protected ScriptEngine getInvocableScriptEngine(String path) { path = "scripts/" + path; File scriptFile = new File(path); if (!scriptFile.exists()) { return null; } - NashornScriptEngine engine = (NashornScriptEngine) sef.getScriptEngine(); + + ScriptEngine engine = sef.getScriptEngine(); + if (!(engine instanceof GraalJSScriptEngine graalScriptEngine)) { + throw new IllegalStateException("ScriptEngineFactory did not provide a GraalJSScriptEngine"); + } + + enableScriptHostAccess(graalScriptEngine); + try (FileReader fr = new FileReader(scriptFile)) { - if (ServerConstants.JAVA_8){ - engine.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator()); - } engine.eval(fr); } catch (final ScriptException | IOException t) { FilePrinter.printError(FilePrinter.INVOCABLE + path.substring(12), t, path); return null; } - return engine; + return graalScriptEngine; } - protected NashornScriptEngine getScriptEngine(String path, MapleClient c) { - NashornScriptEngine engine = c.getScriptEngine("scripts/" + path); + protected ScriptEngine getInvocableScriptEngine(String path, MapleClient c) { + ScriptEngine engine = c.getScriptEngine("scripts/" + path); if (engine == null) { - engine = getScriptEngine(path); + engine = getInvocableScriptEngine(path); c.setScriptEngine(path, engine); } return engine; } + /** + * Allow usage of "Java.type()" in script to look up host class + */ + private void enableScriptHostAccess(GraalJSScriptEngine engine) { + Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); + bindings.put("polyglot.js.allowHostAccess", true); + bindings.put("polyglot.js.allowHostClassLookup", true); + } + protected void resetContext(String path, MapleClient c) { c.removeScriptEngine("scripts/" + path); } diff --git a/src/main/java/scripting/SynchronizedInvocable.java b/src/main/java/scripting/SynchronizedInvocable.java new file mode 100644 index 0000000000..e68576df25 --- /dev/null +++ b/src/main/java/scripting/SynchronizedInvocable.java @@ -0,0 +1,44 @@ +package scripting; + +import net.jcip.annotations.ThreadSafe; + +import javax.script.Invocable; +import javax.script.ScriptException; + +/** + * Thread safe wrapper around Invocable. + * Thread safety is achieved by synchronizing all methods. + * Needed to get around the restriction that GraalVM imposes on evaluated scripts: no concurrent access allowed. + */ +@ThreadSafe +public class SynchronizedInvocable implements Invocable { + private final Invocable invocable; + + private SynchronizedInvocable(Invocable invocable) { + this.invocable = invocable; + } + + public static Invocable of(Invocable invocable) { + return new SynchronizedInvocable(invocable); + } + + @Override + public synchronized Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { + return invocable.invokeMethod(thiz, name, args); + } + + @Override + public synchronized Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException { + return invocable.invokeFunction(name, args); + } + + @Override + public synchronized T getInterface(Class clasz) { + return invocable.getInterface(clasz); + } + + @Override + public synchronized T getInterface(Object thiz, Class clasz) { + return invocable.getInterface(thiz, clasz); + } +} diff --git a/src/main/java/scripting/event/EventInstanceManager.java b/src/main/java/scripting/event/EventInstanceManager.java index 237713d2b3..ee4dbc6104 100644 --- a/src/main/java/scripting/event/EventInstanceManager.java +++ b/src/main/java/scripting/event/EventInstanceManager.java @@ -26,7 +26,6 @@ import client.Skill; import client.SkillFactory; import config.YamlConfig; import constants.inventory.ItemConstants; -import constants.net.ServerConstants; import net.server.audit.LockCollector; import net.server.audit.locks.*; import net.server.audit.locks.factory.MonitoredReadLockFactory; @@ -214,7 +213,7 @@ public class EventInstanceManager { } } - + public Object invokeScriptFunction(String name, Object... args) throws ScriptException, NoSuchMethodException { if (!disposed) { return em.getIv().invokeFunction(name, args); @@ -557,31 +556,25 @@ public class EventInstanceManager { } public void monsterKilled(MapleCharacter chr, final MapleMonster mob) { - try { - int inc; - - if (ServerConstants.JAVA_8) { - inc = (int)invokeScriptFunction("monsterValue", EventInstanceManager.this, mob.getId()); - } else { - inc = ((Double) invokeScriptFunction("monsterValue", EventInstanceManager.this, mob.getId())).intValue(); - } - - if (inc != 0) { - Integer kc = killCount.get(chr); - if (kc == null) { - kc = inc; - } else { - kc += inc; - } - killCount.put(chr, kc); - if (expedition != null){ - expedition.monsterKilled(chr, mob); - } - } - } catch (ScriptException | NoSuchMethodException ex) { - ex.printStackTrace(); - } - } + try { + final int inc = (int) invokeScriptFunction("monsterValue", EventInstanceManager.this, mob.getId()); + + if (inc != 0) { + Integer kc = killCount.get(chr); + if (kc == null) { + kc = inc; + } else { + kc += inc; + } + killCount.put(chr, kc); + if (expedition != null) { + expedition.monsterKilled(chr, mob); + } + } + } catch (ScriptException | NoSuchMethodException ex) { + ex.printStackTrace(); + } + } public int getKillCount(MapleCharacter chr) { Integer kc = killCount.get(chr); @@ -886,31 +879,25 @@ public class EventInstanceManager { public MapleMonster getMonster(int mid) { return(MapleLifeFactory.getMonster(mid)); } - - private List convertToIntegerArray(List list) { - List intList = new ArrayList<>(); - - if (ServerConstants.JAVA_8) { - for (Object d: list) { - intList.add((Integer) d); + + private List convertToIntegerList(List objects) { + List intList = new ArrayList<>(); + + for (Object object : objects) { + intList.add((Integer) object); } - } else { - for (Object d: list) { - intList.add(((Double) d).intValue()); - } - } - - return intList; + + return intList; } public void setEventClearStageExp(List gain) { onMapClearExp.clear(); - onMapClearExp.addAll(convertToIntegerArray(gain)); + onMapClearExp.addAll(convertToIntegerList(gain)); } public void setEventClearStageMeso(List gain) { onMapClearMeso.clear(); - onMapClearMeso.addAll(convertToIntegerArray(gain)); + onMapClearMeso.addAll(convertToIntegerList(gain)); } public Integer getClearStageExp(int stage) { //stage counts from ONE. @@ -940,7 +927,7 @@ public class EventInstanceManager { } public final void setExclusiveItems(List items) { - List exclusive = convertToIntegerArray(items); + List exclusive = convertToIntegerList(items); wL.lock(); try { @@ -968,8 +955,8 @@ public class EventInstanceManager { if(eventLevel <= 0 || eventLevel > YamlConfig.config.server.MAX_EVENT_LEVELS) return; eventLevel--; //event level starts from 1 - List rewardIds = convertToIntegerArray(rwds); - List rewardQtys = convertToIntegerArray(qtys); + List rewardIds = convertToIntegerList(rwds); + List rewardQtys = convertToIntegerList(qtys); //rewardsSet and rewardsQty hold temporary values wL.lock(); diff --git a/src/main/java/scripting/event/EventManager.java b/src/main/java/scripting/event/EventManager.java index 11f9535def..b254c1bb49 100644 --- a/src/main/java/scripting/event/EventManager.java +++ b/src/main/java/scripting/event/EventManager.java @@ -24,10 +24,6 @@ package scripting.event; import client.MapleCharacter; import config.YamlConfig; import constants.game.GameConstants; -import constants.net.ServerConstants; -import jdk.nashorn.api.scripting.NashornScriptEngine; -import jdk.nashorn.api.scripting.ScriptObjectMirror; -import jdk.nashorn.api.scripting.ScriptUtils; import net.server.Server; import net.server.audit.LockCollector; import net.server.audit.locks.MonitoredLockType; @@ -48,6 +44,7 @@ import server.maps.MapleMap; import server.quest.MapleQuest; import tools.exceptions.EventInstanceInProgressException; +import javax.script.Invocable; import javax.script.ScriptException; import java.util.*; import java.util.concurrent.Semaphore; @@ -62,7 +59,7 @@ import java.util.logging.Logger; * @author Ronan */ public class EventManager { - private NashornScriptEngine iv; + private Invocable iv; private Channel cserv; private World wserv; private Server server; @@ -85,7 +82,7 @@ public class EventManager { private static final int maxLobbys = 8; // an event manager holds up to this amount of concurrent lobbys - public EventManager(Channel cserv, NashornScriptEngine iv, String name) { + public EventManager(Channel cserv, Invocable iv, String name) { this.server = Server.getInstance(); this.iv = iv; this.cserv = cserv; @@ -151,20 +148,14 @@ public class EventManager { queueLock = queueLock.dispose(); startLock = startLock.dispose(); } - - private List convertToIntegerArray(List list) { + + private List convertToIntegerList(List objects) { List intList = new ArrayList<>(); - - if (ServerConstants.JAVA_8) { - for (Object d: list) { - intList.add((Integer) d); - } - } else { - for (Object d: list) { - intList.add(((Double) d).intValue()); - } + + for (Object object : objects) { + intList.add((Integer) object); } - + return intList; } @@ -172,26 +163,11 @@ public class EventManager { return YamlConfig.config.server.EVENT_LOBBY_DELAY; } - private List getLobbyRange() { + private int getMaxLobbies() { try { - if (!ServerConstants.JAVA_8) { - return convertToIntegerArray((List)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 list = new ArrayList<>(); - for (int i : to) { - list.add(i); - } - return list; - - } + return (int) iv.invokeFunction("getMaxLobbies"); } catch (ScriptException | NoSuchMethodException ex) { // they didn't define a lobby range - List defaultRange = new ArrayList<>(); - defaultRange.add(0); - defaultRange.add(maxLobbys); - - return defaultRange; + return maxLobbys; } } @@ -235,7 +211,7 @@ public class EventManager { return cserv; } - public NashornScriptEngine getIv() { + public Invocable getIv() { return iv; } @@ -351,23 +327,19 @@ public class EventManager { public String getName() { return name; } - + private int availableLobbyInstance() { - List lr = getLobbyRange(); - int lb = 0, hb = 0; - - if(lr.size() >= 2) { - lb = Math.max(lr.get(0), 0); - hb = Math.min(lr.get(1), maxLobbys - 1); + int maxLobbies = getMaxLobbies(); + + if (maxLobbies > 0) { + for (int i = 0; i < maxLobbies; i++) { + if (startLobbyInstance(i)) { + return i; + } } - - for(int i = lb; i <= hb; i++) { - if(startLobbyInstance(i)) { - return i; - } - } - - return -1; + } + + return -1; } private String getInternalScriptExceptionMessage(Throwable a) { @@ -707,7 +679,7 @@ public class EventManager { } registerEventInstance(eim.getName(), lobbyId); eim.setLeader(leader); - + iv.invokeFunction("setup", eim); eim.setProperty("leader", ldr); @@ -732,28 +704,21 @@ public class EventManager { public List getEligibleParty(MapleParty party) { if (party == null) { - return(new ArrayList<>()); + return new ArrayList<>(); } try { - Object p = iv.invokeFunction("getEligibleParty", party.getPartyMembersOnline()); + Object o = iv.invokeFunction("getEligibleParty", party.getPartyMembersOnline()); - if(p != null) { - List lmpc; - - if(ServerConstants.JAVA_8) { - lmpc = new ArrayList<>(((Map)(ScriptUtils.convert(p, Map.class))).values()); - } else { - lmpc = new ArrayList<>((List) p); - } - - party.setEligibleMembers(lmpc); - return lmpc; + if (o instanceof MaplePartyCharacter[] partyChrs) { + final List eligibleParty = new ArrayList<>(Arrays.asList(partyChrs)); + party.setEligibleMembers(eligibleParty); + return eligibleParty; } } catch (ScriptException | NoSuchMethodException ex) { ex.printStackTrace(); } - return(new ArrayList<>()); + return new ArrayList<>(); } public void clearPQ(EventInstanceManager eim) { diff --git a/src/main/java/scripting/event/EventScriptManager.java b/src/main/java/scripting/event/EventScriptManager.java index 1e6afe628b..18a13d454d 100644 --- a/src/main/java/scripting/event/EventScriptManager.java +++ b/src/main/java/scripting/event/EventScriptManager.java @@ -21,45 +21,44 @@ */ package scripting.event; -import java.util.concurrent.ConcurrentHashMap; +import net.server.channel.Channel; +import scripting.AbstractScriptManager; +import scripting.SynchronizedInvocable; + +import javax.script.Invocable; +import javax.script.ScriptEngine; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; -import jdk.nashorn.api.scripting.NashornScriptEngine; - -import net.server.channel.Channel; -import scripting.AbstractScriptManager; - /** * * @author Matze */ public class EventScriptManager extends AbstractScriptManager { + private static final String INJECTED_VARIABLE_NAME = "em"; + private static EventEntry fallback; + private final Map events = new ConcurrentHashMap<>(); + private boolean active = false; - private class EventEntry { + private static class EventEntry { - public EventEntry(NashornScriptEngine iv, EventManager em) { + public EventEntry(Invocable iv, EventManager em) { this.iv = iv; this.em = em; } - public NashornScriptEngine iv; + public Invocable iv; public EventManager em; } - - private static EventEntry fallback; - private Map events = new ConcurrentHashMap<>(); - private boolean active = false; - - public EventScriptManager(Channel cserv, String[] scripts) { - super(); + + public EventScriptManager(final Channel channel, String[] scripts) { for (String script : scripts) { - if (!script.equals("")) { - NashornScriptEngine iv = getScriptEngine("event/" + script + ".js"); - events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script))); + if (!script.isEmpty()) { + events.put(script, initializeEventEntry(script, channel)); } } @@ -82,7 +81,6 @@ public class EventScriptManager extends AbstractScriptManager { public final void init() { for (EventEntry entry : events.values()) { try { - entry.iv.put("em", entry.em); entry.iv.invokeFunction("init", (Object) null); } catch (Exception ex) { Logger.getLogger(EventScriptManager.class.getName()).log(Level.SEVERE, null, ex); @@ -99,14 +97,22 @@ public class EventScriptManager extends AbstractScriptManager { return; } - Channel cserv = eventEntries.iterator().next().getValue().em.getChannelServer(); + Channel channel = eventEntries.iterator().next().getValue().em.getChannelServer(); for (Entry entry : eventEntries) { String script = entry.getKey(); - NashornScriptEngine iv = getScriptEngine("event/" + script + ".js"); - events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script))); + events.put(script, initializeEventEntry(script, channel)); } } + private EventEntry initializeEventEntry(String script, Channel channel) { + ScriptEngine engine = getInvocableScriptEngine("event/" + script + ".js"); + Invocable iv = SynchronizedInvocable.of((Invocable) engine); + EventManager eventManager = new EventManager(channel, iv, script); + engine.put(INJECTED_VARIABLE_NAME, eventManager); + return new EventEntry(iv, eventManager); + } + + // Is never being called public void reload() { cancel(); reloadScripts(); diff --git a/src/main/java/scripting/map/MapScriptManager.java b/src/main/java/scripting/map/MapScriptManager.java index 976b37521e..4d42e43bda 100644 --- a/src/main/java/scripting/map/MapScriptManager.java +++ b/src/main/java/scripting/map/MapScriptManager.java @@ -23,31 +23,22 @@ package scripting.map; import client.MapleCharacter; import client.MapleClient; -import java.lang.reflect.UndeclaredThrowableException; -import java.util.HashMap; -import java.util.Map; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import jdk.nashorn.api.scripting.NashornScriptEngine; import scripting.AbstractScriptManager; import tools.FilePrinter; -public class MapScriptManager extends AbstractScriptManager { +import javax.script.Invocable; +import javax.script.ScriptException; +import java.util.HashMap; +import java.util.Map; + +public class MapScriptManager extends AbstractScriptManager { + private static final MapScriptManager instance = new MapScriptManager(); + + private final Map scripts = new HashMap<>(); - private static MapScriptManager instance = new MapScriptManager(); - public static MapScriptManager getInstance() { return instance; } - - private Map scripts = new HashMap<>(); - private ScriptEngineFactory sef; - - private MapScriptManager() { - ScriptEngineManager sem = new ScriptEngineManager(); - sef = sem.getEngineByName("javascript").getFactory(); - } public void reloadScripts() { scripts.clear(); @@ -64,7 +55,7 @@ public class MapScriptManager extends AbstractScriptManager { } } - NashornScriptEngine iv = scripts.get(mapScriptPath); + Invocable iv = scripts.get(mapScriptPath); if (iv != null) { try { iv.invokeFunction("start", new MapScriptMethods(c)); @@ -75,7 +66,7 @@ public class MapScriptManager extends AbstractScriptManager { } try { - iv = getScriptEngine("map/" + mapScriptPath + ".js"); + iv = (Invocable) getInvocableScriptEngine("map/" + mapScriptPath + ".js"); if (iv == null) { return false; } @@ -83,12 +74,10 @@ public class MapScriptManager extends AbstractScriptManager { scripts.put(mapScriptPath, iv); iv.invokeFunction("start", new MapScriptMethods(c)); return true; - } catch (final UndeclaredThrowableException | ScriptException ute) { - FilePrinter.printError(FilePrinter.MAP_SCRIPT + mapScriptPath + ".txt", ute); } catch (final Exception e) { FilePrinter.printError(FilePrinter.MAP_SCRIPT + mapScriptPath + ".txt", e); } - + return false; } } \ No newline at end of file diff --git a/src/main/java/scripting/npc/NPCScriptManager.java b/src/main/java/scripting/npc/NPCScriptManager.java index d310efa2a8..39b74f2bc1 100644 --- a/src/main/java/scripting/npc/NPCScriptManager.java +++ b/src/main/java/scripting/npc/NPCScriptManager.java @@ -23,44 +23,40 @@ package scripting.npc; import client.MapleCharacter; import client.MapleClient; - -import java.lang.reflect.UndeclaredThrowableException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.script.ScriptException; - -import jdk.nashorn.api.scripting.NashornScriptEngine; import net.server.world.MaplePartyCharacter; - import scripting.AbstractScriptManager; import server.MapleItemInformationProvider.ScriptedItem; import tools.FilePrinter; import tools.MaplePacketCreator; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * * @author Matze */ public class NPCScriptManager extends AbstractScriptManager { + private static final NPCScriptManager instance = new NPCScriptManager(); - private static NPCScriptManager instance = new NPCScriptManager(); + private final Map cms = new HashMap<>(); + private final Map scripts = new HashMap<>(); public static NPCScriptManager getInstance() { return instance; } - private Map cms = new HashMap<>(); - private Map scripts = new HashMap<>(); - public boolean isNpcScriptAvailable(MapleClient c, String fileName) { - NashornScriptEngine iv = null; + ScriptEngine engine = null; if (fileName != null) { - iv = getScriptEngine("npc/" + fileName + ".js", c); + engine = getInvocableScriptEngine("npc/" + fileName + ".js", c); } - return iv != null; + return engine != null; } public boolean start(MapleClient c, int npc, MapleCharacter chr) { @@ -85,30 +81,29 @@ public class NPCScriptManager extends AbstractScriptManager { public void start(String filename, MapleClient c, int npc, List chrs) { try { - NPCConversationManager cm = new NPCConversationManager(c, npc, chrs, true); + final NPCConversationManager cm = new NPCConversationManager(c, npc, chrs, true); cm.dispose(); if (cms.containsKey(c)) { return; } cms.put(c, cm); - NashornScriptEngine iv = getScriptEngine("npc/" + filename + ".js", c); + ScriptEngine engine = getInvocableScriptEngine("npc/" + filename + ".js", c); - if (iv == null) { + if (engine == null) { c.getPlayer().dropMessage(1, "NPC " + npc + " is uncoded."); cm.dispose(); return; } - iv.put("cm", cm); - scripts.put(c, iv); + engine.put("cm", cm); + + Invocable invocable = (Invocable) engine; + scripts.put(c, invocable); try { - iv.invokeFunction("start", chrs); + invocable.invokeFunction("start", chrs); } catch (final NoSuchMethodException nsme) { nsme.printStackTrace(); } - } catch (final UndeclaredThrowableException ute) { - FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute); - dispose(c); } catch (final Exception e) { FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e); dispose(c); @@ -117,31 +112,33 @@ public class NPCScriptManager extends AbstractScriptManager { private boolean start(MapleClient c, int npc, int oid, String fileName, MapleCharacter chr, boolean itemScript, String engineName) { try { - NPCConversationManager cm = new NPCConversationManager(c, npc, oid, fileName, itemScript); + final NPCConversationManager cm = new NPCConversationManager(c, npc, oid, fileName, itemScript); if (cms.containsKey(c)) { dispose(c); } if (c.canClickNPC()) { cms.put(c, cm); - NashornScriptEngine iv = null; + ScriptEngine engine = null; if (!itemScript) { if (fileName != null) { - iv = getScriptEngine("npc/" + fileName + ".js", c); + engine = getInvocableScriptEngine("npc/" + fileName + ".js", c); } } else { if (fileName != null) { // thanks MiLin for drafting NPC-based item scripts - iv = getScriptEngine("item/" + fileName + ".js", c); + engine = getInvocableScriptEngine("item/" + fileName + ".js", c); } } - if (iv == null) { - iv = getScriptEngine("npc/" + npc + ".js", c); + if (engine == null) { + engine = getInvocableScriptEngine("npc/" + npc + ".js", c); cm.resetItemScript(); } - if (iv == null) { + if (engine == null) { dispose(c); return false; } - iv.put(engineName, cm); + engine.put(engineName, cm); + + Invocable iv = (Invocable) engine; scripts.put(c, iv); c.setClickedNPC(); try { @@ -157,21 +154,16 @@ public class NPCScriptManager extends AbstractScriptManager { c.announce(MaplePacketCreator.enableActions()); } return true; - } catch (final UndeclaredThrowableException | ScriptException ute) { + } catch (final Exception ute) { FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute); dispose(c); - return false; - } catch (final Exception e) { - FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e); - dispose(c); - return false; } } public void action(MapleClient c, byte mode, byte type, int selection) { - NashornScriptEngine iv = scripts.get(c); + Invocable iv = scripts.get(c); if (iv != null) { try { c.setClickedNPC(); diff --git a/src/main/java/scripting/portal/PortalPlayerInteraction.java b/src/main/java/scripting/portal/PortalPlayerInteraction.java index 59589d6c47..d12ea79a1d 100644 --- a/src/main/java/scripting/portal/PortalPlayerInteraction.java +++ b/src/main/java/scripting/portal/PortalPlayerInteraction.java @@ -34,8 +34,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class PortalPlayerInteraction extends AbstractPlayerInteraction { - - private MaplePortal portal; + private final MaplePortal portal; public PortalPlayerInteraction(MapleClient c, MaplePortal portal) { super(c); diff --git a/src/main/java/scripting/portal/PortalScriptManager.java b/src/main/java/scripting/portal/PortalScriptManager.java index 926f5fd52e..7900676466 100644 --- a/src/main/java/scripting/portal/PortalScriptManager.java +++ b/src/main/java/scripting/portal/PortalScriptManager.java @@ -22,59 +22,56 @@ along with this program. If not, see . package scripting.portal; import client.MapleClient; -import java.lang.reflect.UndeclaredThrowableException; -import java.util.HashMap; -import java.util.Map; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptEngineManager; -import jdk.nashorn.api.scripting.NashornScriptEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import scripting.AbstractScriptManager; import server.maps.MaplePortal; -import tools.FilePrinter; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptException; +import java.util.HashMap; +import java.util.Map; public class PortalScriptManager extends AbstractScriptManager { + private static final Logger log = LoggerFactory.getLogger(PortalScriptManager.class); + private static final PortalScriptManager instance = new PortalScriptManager(); + + private final Map scripts = new HashMap<>(); - private static PortalScriptManager instance = new PortalScriptManager(); - public static PortalScriptManager getInstance() { return instance; } - - private Map scripts = new HashMap<>(); - private ScriptEngineFactory sef; - private PortalScriptManager() { - ScriptEngineManager sem = new ScriptEngineManager(); - sef = sem.getEngineByName("javascript").getFactory(); - } - - private NashornScriptEngine getPortalScript(String scriptName) { + private PortalScript getPortalScript(String scriptName) throws ScriptException { String scriptPath = "portal/" + scriptName + ".js"; - NashornScriptEngine iv = scripts.get(scriptPath); - if (iv != null) { - return iv; + PortalScript script = scripts.get(scriptPath); + if (script != null) { + return script; } - iv = getScriptEngine(scriptPath); - if (iv == null) { + ScriptEngine engine = getInvocableScriptEngine(scriptPath); + if (!(engine instanceof Invocable iv)) { return null; } - - scripts.put(scriptPath, iv); - return iv; + + script = iv.getInterface(PortalScript.class); + if (script == null) { + throw new ScriptException(String.format("Portal script \"%s\" fails to implement the PortalScript interface", scriptName)); + } + + scripts.put(scriptPath, script); + return script; } public boolean executePortalScript(MaplePortal portal, MapleClient c) { try { - NashornScriptEngine iv = getPortalScript(portal.getScriptName()); - if (iv != null) { - boolean couldWarp = (boolean) iv.invokeFunction("enter", new PortalPlayerInteraction(c, portal)); - return couldWarp; + PortalScript script = getPortalScript(portal.getScriptName()); + if (script != null) { + return script.enter(new PortalPlayerInteraction(c, portal)); } - } catch (UndeclaredThrowableException ute) { - FilePrinter.printError(FilePrinter.PORTAL + portal.getScriptName() + ".txt", ute); - } catch (final Exception e) { - FilePrinter.printError(FilePrinter.PORTAL + portal.getScriptName() + ".txt", e); + } catch (Exception e) { + log.warn("Portal script {}", portal.getScriptName(), e); } return false; } diff --git a/src/main/java/scripting/quest/QuestScriptManager.java b/src/main/java/scripting/quest/QuestScriptManager.java index c67de4b196..127dd9a5b8 100644 --- a/src/main/java/scripting/quest/QuestScriptManager.java +++ b/src/main/java/scripting/quest/QuestScriptManager.java @@ -21,187 +21,187 @@ */ package scripting.quest; -import java.lang.reflect.UndeclaredThrowableException; -import java.util.HashMap; -import java.util.Map; - -import jdk.nashorn.api.scripting.NashornScriptEngine; +import client.MapleClient; +import client.MapleQuestStatus; +import constants.game.GameConstants; import scripting.AbstractScriptManager; import server.quest.MapleQuest; import tools.FilePrinter; -import constants.game.GameConstants; -import client.MapleClient; -import client.MapleQuestStatus; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.HashMap; +import java.util.Map; /** * * @author RMZero213 */ public class QuestScriptManager extends AbstractScriptManager { + private static final QuestScriptManager instance = new QuestScriptManager(); - private static QuestScriptManager instance = new QuestScriptManager(); + private final Map qms = new HashMap<>(); + private final Map scripts = new HashMap<>(); - public static QuestScriptManager getInstance() { - return instance; - } - - private Map qms = new HashMap<>(); - private Map scripts = new HashMap<>(); - - private NashornScriptEngine getQuestScriptEngine(MapleClient c, short questid) { - NashornScriptEngine iv = getScriptEngine("quest/" + questid + ".js", c); - if (iv == null && GameConstants.isMedalQuest(questid)) { - iv = getScriptEngine("quest/medalQuest.js", c); // start generic medal quest - } + public static QuestScriptManager getInstance() { + return instance; + } - return iv; + private ScriptEngine getQuestScriptEngine(MapleClient 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 } + + return engine; + } public void start(MapleClient c, short questid, int npc) { - MapleQuest quest = MapleQuest.getInstance(questid); - try { - QuestActionManager qm = new QuestActionManager(c, questid, npc, true); - if (qms.containsKey(c)) { - return; - } - if(c.canClickNPC()) { - qms.put(c, qm); - - if (!quest.hasScriptRequirement(false)) { // lack of scripted quest checks found thanks to Mali, Resinate - qm.dispose(); - return; - } - - NashornScriptEngine iv = getQuestScriptEngine(c, questid); - if (iv == null) { - FilePrinter.printError(FilePrinter.QUEST_UNCODED, "START Quest " + questid + " is uncoded."); - qm.dispose(); - return; - } - - iv.put("qm", qm); - scripts.put(c, iv); - c.setClickedNPC(); - iv.invokeFunction("start", (byte) 1, (byte) 0, 0); - } - } 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); + MapleQuest quest = MapleQuest.getInstance(questid); + try { + QuestActionManager qm = new QuestActionManager(c, questid, npc, true); + if (qms.containsKey(c)) { + return; + } + if (c.canClickNPC()) { + qms.put(c, qm); + + if (!quest.hasScriptRequirement(false)) { // lack of scripted quest checks found thanks to Mali, Resinate + qm.dispose(); + return; } - } + + ScriptEngine engine = getQuestScriptEngine(c, questid); + if (engine == null) { + FilePrinter.printError(FilePrinter.QUEST_UNCODED, "START Quest " + questid + " is uncoded."); + qm.dispose(); + return; + } + + engine.put("qm", qm); + + Invocable iv = (Invocable) engine; + scripts.put(c, iv); + c.setClickedNPC(); + iv.invokeFunction("start", (byte) 1, (byte) 0, 0); + } + } 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 start(MapleClient c, byte mode, byte type, int selection) { - NashornScriptEngine iv = scripts.get(c); + Invocable iv = scripts.get(c); if (iv != null) { try { c.setClickedNPC(); - iv.invokeFunction("start", mode, type, selection); - } catch (final UndeclaredThrowableException ute) { - FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", ute); - dispose(c); - } catch (final Throwable t) { - FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t); + iv.invokeFunction("start", mode, type, selection); + } catch (final Exception e) { + FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e); dispose(c); } - } + } } public void end(MapleClient 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); - return; - } - try { - QuestActionManager qm = new QuestActionManager(c, questid, npc, false); - if (qms.containsKey(c)) { - return; - } - if(c.canClickNPC()){ - qms.put(c, qm); - - if (!quest.hasScriptRequirement(true)) { - qm.dispose(); - return; - } - - NashornScriptEngine iv = getQuestScriptEngine(c, questid); - if (iv == null) { - FilePrinter.printError(FilePrinter.QUEST_UNCODED, "END Quest " + questid + " is uncoded."); - qm.dispose(); - return; - } - - iv.put("qm", qm); - scripts.put(c, iv); - c.setClickedNPC(); - iv.invokeFunction("end", (byte) 1, (byte) 0, 0); - } - } 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); - } - } + MapleQuest quest = MapleQuest.getInstance(questid); + if (!c.getPlayer().getQuest(quest).getStatus().equals(MapleQuestStatus.Status.STARTED) || !c.getPlayer().getMap().containsNPC(npc)) { + dispose(c); + return; + } + try { + QuestActionManager qm = new QuestActionManager(c, questid, npc, false); + if (qms.containsKey(c)) { + return; + } + if (c.canClickNPC()) { + qms.put(c, qm); + + if (!quest.hasScriptRequirement(true)) { + qm.dispose(); + return; + } + + ScriptEngine engine = getQuestScriptEngine(c, questid); + if (engine == null) { + FilePrinter.printError(FilePrinter.QUEST_UNCODED, "END Quest " + questid + " is uncoded."); + qm.dispose(); + return; + } + + engine.put("qm", qm); + + Invocable iv = (Invocable) engine; + scripts.put(c, iv); + c.setClickedNPC(); + iv.invokeFunction("end", (byte) 1, (byte) 0, 0); + } + } 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 end(MapleClient c, byte mode, byte type, int selection) { - NashornScriptEngine iv = scripts.get(c); + Invocable iv = scripts.get(c); if (iv != null) { try { c.setClickedNPC(); - iv.invokeFunction("end", mode, type, selection); - } catch (final UndeclaredThrowableException ute) { - FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", ute); - dispose(c); - } catch (final Throwable t) { - FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t); + iv.invokeFunction("end", mode, type, selection); + } catch (final Exception e) { + FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", e); dispose(c); } - } + } } public void raiseOpen(MapleClient 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); - - NashornScriptEngine iv = getQuestScriptEngine(c, questid); - if (iv == null) { - //FilePrinter.printError(FilePrinter.QUEST_UNCODED, "RAISE Quest " + questid + " is uncoded."); - qm.dispose(); - return; - } - - iv.put("qm", qm); - 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); + try { + QuestActionManager qm = new QuestActionManager(c, questid, npc, true); + if (qms.containsKey(c)) { + return; } - } + if (c.canClickNPC()) { + qms.put(c, qm); - public void dispose(QuestActionManager qm, MapleClient c) { - qms.remove(c); - scripts.remove(c); - c.getPlayer().setNpcCooldown(System.currentTimeMillis()); - resetContext("quest/" + qm.getQuest() + ".js", c); - c.getPlayer().flushDelayedUpdateQuests(); - } + 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, MapleClient c) { + qms.remove(c); + scripts.remove(c); + c.getPlayer().setNpcCooldown(System.currentTimeMillis()); + resetContext("quest/" + qm.getQuest() + ".js", c); + c.getPlayer().flushDelayedUpdateQuests(); + } public void dispose(MapleClient c) { QuestActionManager qm = qms.get(c); @@ -210,12 +210,12 @@ public class QuestScriptManager extends AbstractScriptManager { } } - public QuestActionManager getQM(MapleClient c) { - return qms.get(c); - } - - public void reloadQuestScripts() { - scripts.clear(); - qms.clear(); - } + public QuestActionManager getQM(MapleClient c) { + return qms.get(c); + } + + public void reloadQuestScripts() { + scripts.clear(); + qms.clear(); + } } diff --git a/src/main/java/scripting/reactor/ReactorActionManager.java b/src/main/java/scripting/reactor/ReactorActionManager.java index 417ea59288..b5246a69af 100644 --- a/src/main/java/scripting/reactor/ReactorActionManager.java +++ b/src/main/java/scripting/reactor/ReactorActionManager.java @@ -28,10 +28,7 @@ import client.inventory.Item; import client.inventory.MapleInventoryType; import config.YamlConfig; import constants.inventory.ItemConstants; -import jdk.nashorn.api.scripting.NashornScriptEngine; import scripting.AbstractPlayerInteraction; -import scripting.event.EventInstanceManager; -import scripting.event.EventManager; import server.MapleItemInformationProvider; import server.TimerManager; import server.life.MapleLifeFactory; @@ -44,25 +41,23 @@ import server.partyquest.MapleCarnivalFactory; import server.partyquest.MapleCarnivalFactory.MCSkill; import tools.MaplePacketCreator; -import javax.script.ScriptException; +import javax.script.Invocable; import java.awt.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @author Lerk * @author Ronan */ public class ReactorActionManager extends AbstractPlayerInteraction { - private MapleReactor reactor; - private NashornScriptEngine iv; + private final MapleReactor reactor; + private final Invocable iv; private ScheduledFuture sprayTask = null; - public ReactorActionManager(MapleClient c, MapleReactor reactor, NashornScriptEngine iv) { + public ReactorActionManager(MapleClient c, MapleReactor reactor, Invocable iv) { super(c); this.reactor = reactor; this.iv = iv; @@ -311,29 +306,21 @@ public class ReactorActionManager extends AbstractPlayerInteraction { public void spawnFakeMonster(int id) { reactor.getMap().spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(id), getPosition()); } - - public ScheduledFuture schedule(String methodName, long delay) { - return schedule(methodName, null, delay); + + /** + * Used for Targa and Scarlion + */ + public void summonBossDelayed(final int mobId, final int delayMs, final int x, final int y, final String bgm, + final String summonMessage) { + TimerManager.getInstance().schedule(() -> { + summonBoss(mobId, x, y, bgm, summonMessage); + }, delayMs); } - public ScheduledFuture schedule(final String methodName, final EventInstanceManager eim, long delay) { - return TimerManager.getInstance().schedule(() -> { - try { - iv.invokeFunction(methodName, eim); - } catch (ScriptException | NoSuchMethodException ex) { - Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); - } - }, delay); - } - - public ScheduledFuture scheduleAtTimestamp(final String methodName, long timestamp) { - return TimerManager.getInstance().scheduleAtTimestamp(() -> { - try { - iv.invokeFunction(methodName, (Object) null); - } catch (ScriptException | NoSuchMethodException ex) { - Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); - } - }, timestamp); + private void summonBoss(int mobId, int x, int y, String bgmName, String summonMessage) { + spawnMonster(mobId, x, y); + changeMusic(bgmName); + mapMessage(6, summonMessage); } public void dispelAllMonsters(int num, int team) { //dispels all mobs, cpq diff --git a/src/main/java/scripting/reactor/ReactorScriptManager.java b/src/main/java/scripting/reactor/ReactorScriptManager.java index 737bb21235..e380b64036 100644 --- a/src/main/java/scripting/reactor/ReactorScriptManager.java +++ b/src/main/java/scripting/reactor/ReactorScriptManager.java @@ -22,13 +22,14 @@ along with this program. If not, see . package scripting.reactor; import client.MapleClient; -import jdk.nashorn.api.scripting.NashornScriptEngine; import scripting.AbstractScriptManager; import server.maps.MapleReactor; import server.maps.ReactorDropEntry; import tools.DatabaseConnection; import tools.FilePrinter; +import javax.script.Invocable; +import javax.script.ScriptEngine; import javax.script.ScriptException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -42,22 +43,21 @@ import java.util.Map; * @author Lerk */ public class ReactorScriptManager extends AbstractScriptManager { - - private static ReactorScriptManager instance = new ReactorScriptManager(); + private static final ReactorScriptManager instance = new ReactorScriptManager(); + private final Map> drops = new HashMap<>(); + public static ReactorScriptManager getInstance() { return instance; } - private Map> drops = new HashMap<>(); - public void onHit(MapleClient c, MapleReactor reactor) { try { - NashornScriptEngine iv = getScriptEngine("reactor/" + reactor.getId() + ".js", c); - if (iv == null) return; - - ReactorActionManager rm = new ReactorActionManager(c, reactor, iv); - iv.put("rm", rm); + Invocable iv = initializeInvocable(c, reactor); + if (iv == null) { + return; + } + iv.invokeFunction("hit"); } catch (final NoSuchMethodException e) {} //do nothing, hit is OPTIONAL @@ -68,11 +68,11 @@ public class ReactorScriptManager extends AbstractScriptManager { public void act(MapleClient c, MapleReactor reactor) { try { - NashornScriptEngine iv = getScriptEngine("reactor/" + reactor.getId() + ".js", c); - if (iv == null) return; - - ReactorActionManager rm = new ReactorActionManager(c, reactor, iv); - iv.put("rm", rm); + Invocable iv = initializeInvocable(c, reactor); + if (iv == null) { + return; + } + iv.invokeFunction("act"); } catch (final ScriptException | NoSuchMethodException | NullPointerException e) { FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e); @@ -114,11 +114,11 @@ public class ReactorScriptManager extends AbstractScriptManager { private void touching(MapleClient c, MapleReactor reactor, boolean touching) { try { - NashornScriptEngine iv = getScriptEngine("reactor/" + reactor.getId() + ".js", c); - if (iv == null) return; - - ReactorActionManager rm = new ReactorActionManager(c, reactor, iv); - iv.put("rm", rm); + Invocable iv = initializeInvocable(c, reactor); + if (iv == null) { + return; + } + if (touching) { iv.invokeFunction("touch"); } else { @@ -128,4 +128,17 @@ public class ReactorScriptManager extends AbstractScriptManager { FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", ute); } } + + private Invocable initializeInvocable(MapleClient c, MapleReactor reactor) { + ScriptEngine engine = getInvocableScriptEngine("reactor/" + reactor.getId() + ".js", c); + if (engine == null) { + return null; + } + + Invocable iv = (Invocable) engine; + ReactorActionManager rm = new ReactorActionManager(c, reactor, iv); + engine.put("rm", rm); + + return iv; + } } \ No newline at end of file diff --git a/src/main/java/tools/MaplePacketCreator.java b/src/main/java/tools/MaplePacketCreator.java index 50ee148ad7..e135021a86 100644 --- a/src/main/java/tools/MaplePacketCreator.java +++ b/src/main/java/tools/MaplePacketCreator.java @@ -73,6 +73,7 @@ import java.sql.SQLException; import java.util.List; import java.util.*; import java.util.Map.Entry; +import java.util.stream.Collectors; /** * @@ -1439,7 +1440,12 @@ public class MaplePacketCreator { private static void encodeTemporary(MaplePacketLittleEndianWriter mplew, Map stati) { int pCounter = -1, mCounter = -1; - + + stati = stati.entrySet() // to patch some status crashing players + .stream() + .filter(e -> !(e.getKey().equals(MonsterStatus.WATK) || e.getKey().equals(MonsterStatus.WDEF))) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); + writeLongEncodeTemporaryMask(mplew, stati.keySet()); // packet structure mapped thanks to Eric for (Entry s : stati.entrySet()) { @@ -2663,6 +2669,9 @@ public class MaplePacketCreator { mplew.writeShort(SendOpcode.DAMAGE_PLAYER.getValue()); mplew.writeInt(cid); mplew.write(skill); + if (skill == -3) { + mplew.writeInt(0); + } mplew.writeInt(damage); if(skill != -4) { mplew.writeInt(monsteridfrom);