-
Notifications
You must be signed in to change notification settings - Fork 0
/
customServerChooser.js
52 lines (49 loc) · 1.64 KB
/
customServerChooser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
executeCommand,
registerCommand,
registerOverride
} from "ez:command";
import {
send
} from "ez:formui";
registerCommand("customserverchooser", "Open /transferserver GUI", 0);
registerOverride("customserverchooser", [], function () {
if (this.player) {
send(this.player, {
type: "custom_form",
title: "§l§aCustom Server Chooser",
content: [
{
"type": "input",
"text": "§6Server Address",
"placeholder": "address"
},
{
"type": "input",
"text": "§3Server Port",
"placeholder": "19132"
}
]
}, data => {
let playerName = this.player.name;
//if (data == null) return;
if (data == null) {
executeCommand(`execute ${playerName} ~ ~ ~ selectserver`);
return;
}
let [address, port] = data;
if (port == null) { port = 19132; }
if (address == null || address == "") { executeCommand(`execute ${playerName} ~ ~ ~ customserverchooser`); }
else { try {
executeCommand(`transferserver ${playerName} ${address} ${port}`);
executeCommand(`execute ${playerName} ~ ~ ~ customserverchooser`);
console.log(`${playerName} **TRANSFERED TO** ${address}:${port}`);
}
catch { executeCommand(`tell ${playerName} error`); }
}
}
);
return null
}
});
console.log("customServerChooser.js loaded");