Updated the rebirth NPC to use GraalJS

This commit is contained in:
James McDowell
2021-05-26 19:45:58 +10:00
parent ae744aa870
commit 136ea68ab3

View File

@@ -19,7 +19,7 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* 9010021 - Wolf Spirit Ryko /* Rebirth NPC
@author Ronan @author Ronan
@author wejrox @author wejrox
*/ */
@@ -27,7 +27,8 @@ var status;
function start() { function start() {
status = -1; status = -1;
if (!Packages.config.YamlConfig.config.server.USE_REBIRTH_SYSTEM) { const YamlConfig = Java.type('config.YamlConfig');
if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) {
cm.sendOk("Rebirths aren't enabled on this server, how did you get here?"); cm.sendOk("Rebirths aren't enabled on this server, how did you get here?");
cm.dispose(); cm.dispose();
return; return;
@@ -36,29 +37,29 @@ function start() {
} }
function action(mode, type, selection) { function action(mode, type, selection) {
if (mode == 1) { if (mode === 1) {
status++; status++;
} else { } else {
cm.dispose(); cm.dispose();
return; return;
} }
if (status == 0) { if (status === 0) {
cm.sendNext("Come to me when you want to be reborn again. You currently have a total of #r" + cm.getChar().getReborns() + " #krebirths."); cm.sendNext("Come to me when you want to be reborn again. You currently have a total of #r" + cm.getChar().getReborns() + " #krebirths.");
} else if (status == 1) { } else if (status === 1) {
cm.sendSimple("What do you want me to do today: \r\n \r\n #L0##bI want to be reborn!#l \r\n #L1##bNothing for now...#k#l"); cm.sendSimple("What do you want me to do today: \r\n \r\n #L0##bI want to be reborn!#l \r\n #L1##bNothing for now...#k#l");
} else if (status == 2) { } else if (status === 2) {
if (selection == 0) { if (selection === 0) {
if (cm.getChar().getLevel() == 200) { if (cm.getChar().getLevel() === 200) {
cm.sendYesNo("Are you sure you want to be reborn?"); cm.sendYesNo("Are you sure you want to be reborn?");
} else { } else {
cm.sendOk("You are not level 200, please come back when you hit level 200."); cm.sendOk("You are not level 200, please come back when you hit level 200.");
cm.dispose(); cm.dispose();
} }
} else if (selection == 1) { } else if (selection === 1) {
cm.sendOk("See you soon!") cm.sendOk("See you soon!")
cm.dispose(); cm.dispose();
} }
} else if (status == 3 && type == 1) { } else if (status === 3 && type === 1) {
cm.getChar().executeReborn(); cm.getChar().executeReborn();
cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths"); cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths");
cm.dispose(); cm.dispose();