Skip to content

Commit

Permalink
Update Paradox for support of Minecraft 1.18.10
Browse files Browse the repository at this point in the history
In regards to #14 updates have been made to reflect the changes for the Gametest Framework released in 1.18.10.
  • Loading branch information
Visual1mpact committed Feb 8, 2022
1 parent 0366513 commit 04097a0
Show file tree
Hide file tree
Showing 62 changed files with 272 additions and 327 deletions.
5 changes: 2 additions & 3 deletions scripts/commands/handler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as Minecraft from "mojang-minecraft";
import config from "../data/config.js";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

// import all our commands
import { kick } from "./moderation/kick.js";
Expand Down Expand Up @@ -104,6 +103,6 @@ export function commandHandler(player, message) {
else return;
} catch (error) {
console.warn(`${new Date()} | ` + error);
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"There was an error while trying to run this command. Please read console output"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"There was an error while trying to run this command. Please read console output"}]}`);
}
}
29 changes: 14 additions & 15 deletions scripts/commands/moderation/ban.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint no-var: "off"*/
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name ban
Expand All @@ -21,37 +20,37 @@ export function ban(message, args) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

if (!args.length) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to ban!"}]}`, World.getDimension("overworld"));
if (!args.length) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to ban!"}]}`);

// try to find the player requested
for (let pl of World.getPlayers()) if (pl.nameTag.toLowerCase().includes(args[0].toLowerCase().replace("@", "").replace("\"", ""))) var member = pl.nameTag;

if (!member) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`, World.getDimension("overworld"));
if (!member) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`);

// make sure they dont ban themselves
if (member === player.nameTag) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot ban yourself."}]}`, World.getDimension("overworld"));
if (member === player.nameTag) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot ban yourself."}]}`);

let tags = Commands.run(`tag "${member}" list`, World.getDimension('overworld')).statusMessage.replace(/§./g, '').match(/(?<=: ).*$/g);
let tags = World.getDimension("overworld").runCommand(`tag "${member}" list`, World.getDimension('overworld')).statusMessage.replace(/§./g, '').match(/(?<=: ).*$/g);
if (tags) tags = String(tags).split(/[,]/);

// this removes old ban stuff
tags.forEach(t => {
if(t.startsWith(" reason:")) Commands.run(`tag "${member}" remove "${t.slice(1)}"`, World.getDimension("overworld"));
if(t.startsWith(" by:")) Commands.run(`tag "${member}" remove "${t.slice(1)}"`, World.getDimension("overworld"));
if(t.startsWith(" reason:")) World.getDimension("overworld").runCommand(`tag "${member}" remove "${t.slice(1)}"`);
if(t.startsWith(" by:")) World.getDimension("overworld").runCommand(`tag "${member}" remove "${t.slice(1)}"`);
});

try {
Commands.run(`tag "${member}" add "reason:${reason}"`, World.getDimension("overworld"));
Commands.run(`tag "${member}" add "by:${player.nameTag}"`, World.getDimension("overworld"));
Commands.run(`tag "${member}" add isBanned`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`tag "${member}" add "reason:${reason}"`);
World.getDimension("overworld").runCommand(`tag "${member}" add "by:${player.nameTag}"`);
World.getDimension("overworld").runCommand(`tag "${member}" add isBanned`);
} catch (error) {
console.warn(`${new Date()} | ` + error);
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to ban that player! Error: ${error}"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to ban that player! Error: ${error}"}]}`);
}
return Commands.run(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has banned ${member}. Reason: ${reason}"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has banned ${member}. Reason: ${reason}"}]}`);
}
9 changes: 4 additions & 5 deletions scripts/commands/moderation/credits.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name credits
Expand All @@ -17,10 +16,10 @@ export function credits(message) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

return Commands.run(`execute "${player.nameTag}" ~~~ function credits`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`execute "${player.nameTag}" ~~~ function credits`);
}
11 changes: 5 additions & 6 deletions scripts/commands/moderation/deop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/* eslint no-redeclare: "off"*/
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name deop
Expand All @@ -21,15 +20,15 @@ export function deop(message, args) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

// try to find the player requested
if (args.length) for (let pl of World.getPlayers()) if (pl.nameTag.toLowerCase().includes(args[0].toLowerCase().replace("@", "").replace("\"", ""))) var member = pl;

if (!member) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`, World.getDimension("overworld"));
if (!member) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`);

return Commands.run(`execute "${member.nameTag}" ~~~ function deop`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`execute "${member.nameTag}" ~~~ function deop`);
}
9 changes: 4 additions & 5 deletions scripts/commands/moderation/help.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name help
Expand All @@ -17,10 +16,10 @@ export function help(message) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

return Commands.run(`execute "${player.nameTag}" ~~~ function help`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`execute "${player.nameTag}" ~~~ function help`);
}
21 changes: 10 additions & 11 deletions scripts/commands/moderation/kick.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint no-var: "off"*/
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name kick
Expand All @@ -24,27 +23,27 @@ export function kick(message, args) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

if (!args.length) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to kick!"}]}`, World.getDimension("overworld"));
if (!args.length) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to kick!"}]}`);

// try to find the player requested
for (let pl of World.getPlayers()) if (pl.nameTag.toLowerCase().includes(args[0].toLowerCase().replace("@", "").replace("\"", ""))) var member = pl.nameTag;

if (!member) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`, World.getDimension("overworld"));
if (!member) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`);

// make sure they dont kick themselves
if (member === player.nameTag) return Commands.run(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot kick yourself."}]}`, World.getDimension("overworld"));
if (member === player.nameTag) return World.getDimension("overworld").runCommand(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot kick yourself."}]}`);

try {
if (!isSilent) Commands.run(`kick "${member}" ${reason}`, World.getDimension("overworld"));
else Commands.run(`event entity "${member}" paradox:kick`, World.getDimension("overworld"));
if (!isSilent) World.getDimension("overworld").runCommand(`kick "${member}" ${reason}`);
else World.getDimension("overworld").runCommand(`event entity "${member}" paradox:kick`);
} catch (error) {
console.warn(`${new Date()} | ` + error);
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to ban that player! Error: ${error}"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to ban that player! Error: ${error}"}]}`);
}
return Commands.run(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has kicked ${member} (Silent:${isSilent}). Reason: ${reason}"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has kicked ${member} (Silent:${isSilent}). Reason: ${reason}"}]}`);
}
21 changes: 10 additions & 11 deletions scripts/commands/moderation/mute.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint no-var: "off"*/
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name mute
Expand All @@ -21,27 +20,27 @@ export function mute(message, args) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

if (!args.length) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to mute!"}]}`, World.getDimension("overworld"));
if (!args.length) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to provide who to mute!"}]}`);

// try to find the player requested
for (let pl of World.getPlayers()) if (pl.nameTag.toLowerCase().includes(args[0].toLowerCase().replace("@", "").replace("\"", ""))) var member = pl.nameTag;

if (!member) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`, World.getDimension("overworld"));
if (!member) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"Couldnt find that player!"}]}`);

// make sure they dont mute themselves
if (member === player.nameTag) return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot mute yourself."}]}`, World.getDimension("overworld"));
if (member === player.nameTag) return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You cannot mute yourself."}]}`);

try {
Commands.run(`ability "${member}" mute true`, World.getDimension("overworld"));
Commands.run(`tellraw "${member}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You have been muted. Reason: ${reason}"}]}`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`ability "${member}" mute true`);
World.getDimension("overworld").runCommand(`tellraw "${member}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You have been muted. Reason: ${reason}"}]}`);
} catch (error) {
console.warn(`${new Date()} | ` + error);
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to mute that player! You most likely dont have education edition enabled."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"I was unable to mute that player! You most likely dont have education edition enabled."}]}`);
}
return Commands.run(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has muted ${member}. Reason: ${reason}"}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw @a[tag=op] {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"${player.nameTag} has muted ${member}. Reason: ${reason}"}]}`);
}
9 changes: 4 additions & 5 deletions scripts/commands/moderation/notify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Minecraft from "mojang-minecraft";

const World = Minecraft.World;
const Commands = Minecraft.Commands;
const World = Minecraft.world;

/**
* @name notify
Expand All @@ -17,10 +16,10 @@ export function notify(message) {

// make sure the user has permissions to run the command
try {
Commands.run(`testfor @a[name="${player.nameTag}",tag=op]`, World.getDimension("overworld"));
World.getDimension("overworld").runCommand(`testfor @a[name="${player.nameTag}",tag=op]`);
} catch (error) {
return Commands.run(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`tellraw "${player.nameTag}" {"rawtext":[{"text":"§r§4[§6Paradox§4]§r "},{"text":"You need to be Paradox-Opped to use this command."}]}`);
}

return Commands.run(`execute "${player.nameTag}" ~~~ function notify`, World.getDimension("overworld"));
return World.getDimension("overworld").runCommand(`execute "${player.nameTag}" ~~~ function notify`);
}
Loading

0 comments on commit 04097a0

Please sign in to comment.