Reformat and clean up npc scripts

This commit is contained in:
P0nk
2021-09-09 23:35:02 +02:00
parent 0c1545f81d
commit d893309b4f
665 changed files with 19932 additions and 19046 deletions

View File

@@ -15,57 +15,58 @@ var levels = ["Common", "Donator", "JrGM", "GM", "SuperGM", "Developer", "Admin"
var commands;
function writeHeavenMSCommands() {
const CommandsExecutor = Java.type('client.command.CommandsExecutor');
commands = CommandsExecutor.getInstance().getGmCommands();
const CommandsExecutor = Java.type('client.command.CommandsExecutor');
commands = CommandsExecutor.getInstance().getGmCommands();
}
function start() {
status = -1;
writeHeavenMSCommands();
action(1, 0, 0);
status = -1;
writeHeavenMSCommands();
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && type > 0) {
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
var sendStr = "There are all available commands for you:\r\n\r\n#b";
for(var i = 0; i <= cm.getPlayer().gmLevel(); i++) {
sendStr += "#L" + i + "#" + levels[i] + "#l\r\n";
}
cm.sendSimple(sendStr);
} else if(status == 1) {
var lvComm, lvDesc, lvHead = (selection < 2) ? common_heading : staff_heading;
if(selection > 6) {
selection = 6;
} else if(selection < 0) {
selection = 0;
}
lvComm = commands.get(selection).getLeft();
lvDesc = commands.get(selection).getRight();
var sendStr = "The following commands are available for #b" + levels[selection] + "#k:\r\n\r\n";
for(var i = 0; i < lvComm.size(); i++) {
sendStr += " #L" + i + "# " + lvHead + lvComm.get(i) + " - " + lvDesc.get(i);
sendStr += "#l\r\n";
}
cm.sendPrev(sendStr);
} else {
cm.dispose();
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && type > 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
var sendStr = "There are all available commands for you:\r\n\r\n#b";
for (var i = 0; i <= cm.getPlayer().gmLevel(); i++) {
sendStr += "#L" + i + "#" + levels[i] + "#l\r\n";
}
cm.sendSimple(sendStr);
} else if (status == 1) {
var lvComm, lvDesc, lvHead = (selection < 2) ? common_heading : staff_heading;
if (selection > 6) {
selection = 6;
} else if (selection < 0) {
selection = 0;
}
lvComm = commands.get(selection).getLeft();
lvDesc = commands.get(selection).getRight();
var sendStr = "The following commands are available for #b" + levels[selection] + "#k:\r\n\r\n";
for (var i = 0; i < lvComm.size(); i++) {
sendStr += " #L" + i + "# " + lvHead + lvComm.get(i) + " - " + lvDesc.get(i);
sendStr += "#l\r\n";
}
cm.sendPrev(sendStr);
} else {
cm.dispose();
}
}
}