-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
264 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as config from "../config"; | ||
|
||
let commands = {}; | ||
|
||
export function newCommand(obj){ | ||
if(commands[obj.name]) return console.warn(`§4[ERROR] A command named "${obj.name}" already exists!`) | ||
commands[obj.name] = obj; | ||
} | ||
|
||
export function commandHandler(data){ | ||
const prefix = config.default.chat.prefix; | ||
const player = data.sender; | ||
const message = data.message; | ||
const args = message.substring(prefix.length).split(" "); | ||
const cmdName = args[0]; | ||
data.cancel = true; | ||
|
||
|
||
if(!commands[cmdName]) return player.sendMessage(`§cUnknown command: §f${args[0]}`); | ||
|
||
let runData = { | ||
args: args, | ||
player: player, | ||
message: message | ||
} | ||
|
||
commands[cmdName].run(runData); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//import all commands | ||
import "../command/src/help"; | ||
import "../command/src/ban"; | ||
import "../command/src/invsee"; | ||
import "../command/src/mute"; | ||
import "../command/src/unmute"; | ||
import "../command/src/unban"; | ||
import "../command/src/summon_npc"; | ||
import "../command/src/vanish"; | ||
import "../command/src/clearchat"; | ||
import "../command/src/fakeleave"; | ||
import "../command/src/fakeleave_server"; | ||
import "../command/src/lagclear"; | ||
import "../command/src/notify"; | ||
import "../command/src/worldborder"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { canFindPlayer, getPlayerByName } from '../../assets/util'; | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"ban", | ||
run: (data) => { | ||
let player = data.player; | ||
const setNameBan = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); | ||
if (!canFindPlayer(setNameBan)) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setNameBan}§f was not found`); | ||
return; | ||
} | ||
if (getPlayerByName(setNameBan).hasTag("admin")) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Can't ban §e${setNameBan}§f, they're an admin.`); | ||
return; | ||
} | ||
player.runCommandAsync('tag "' + setNameBan +'" add Ban'); | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Banned §e${setNameBan}`); | ||
player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bbanned§l§5 ${setNameBan}! §r"}]}`); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"clearchat", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/clearchat"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"fakeleave", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/fake_leave"); | ||
} | ||
}) |
8 changes: 8 additions & 0 deletions
8
Safeguard anti-cheat B/scripts/command/src/fakeleave_server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"fakeleave_server", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/fake_leave_server"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { newCommand } from '../handle'; | ||
import config from '../../config'; | ||
|
||
newCommand({ | ||
name:"help", | ||
run: (data) => { | ||
//TODO: change this to work somehow else because this is not a-okay | ||
data.player.sendMessage(`§l§aPREFIX:§2 §r${config.chat.prefix}\n§l§aCOMMANDS:\n§r§eban <player name> §r|| to ban a person\n§einvsee <player name> §r|| see inventory of a player\n§ecopyinv <player name> §r|| copy inventory of a player to yours\n§emute <player name> §r|| mute a player\n§eunmute <player name>§r || unmute a player\n§eworldborder [border] §r|| get or set the world border\n§evanish §r|| toggle vanish mode\n§eclearchat §r|| clear the chat\n§efakeleave §r|| simulate leaving the realm\n§efakeleave_server §r|| simulate leaving the server\n§esummon_npc §r|| summon an NPC\n§enotify §r|| toggle anticheat notifications\n§elagclear §r|| clear lag\n§eunban <player name> §r|| unban a player`) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { newCommand } from '../handle'; | ||
import { getPlayerByName, invsee } from '../../assets/util'; | ||
|
||
newCommand({ | ||
name:"invsee", | ||
run: (data) => { | ||
const setNameInvsee = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); | ||
if (getPlayerByName(setNameInvsee).hasTag("admin")) { | ||
data.player.sendMessage(`§6[§eSafeGuard§6]§f Can't view the inventory of §e${setNameInvsee}§f, they're an admin.`); | ||
return; | ||
} | ||
data.player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bviewed the inventory of§l§5 ${setNameInvsee.replace("@", "")}! §r"}]}`); | ||
invsee(data.player.name, setNameInvsee); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"lagclear", | ||
run: (data) => { | ||
data.player.runCommandAsync("function anti/anti_lag"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { canFindPlayer, getPlayerByName } from '../../assets/util'; | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"mute", | ||
run: (data) => { | ||
let player = data.player; | ||
const setNameMute = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); | ||
if (!canFindPlayer(setNameMute)) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setNameMute}§f was not found`); | ||
return; | ||
} | ||
if (getPlayerByName(setNameMute).hasTag("admin")) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Can't mute §e${setNameMute}§f, they're an admin.`); | ||
return; | ||
} | ||
player.runCommandAsync('tag "' + setNameMute +'" add muted'); | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Muted §e${setNameMute}`); | ||
player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bmuted§l§5 ${setNameMute}! §r"}]}`); | ||
|
||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"notify", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/notify"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"summon_npc", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/summon_npc"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { unban } from '../../assets/util'; | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"unban", | ||
run: (data) => { | ||
const setNameUnban = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); | ||
unban(data.player,setNameUnban); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { canFindPlayer, getPlayerByName } from '../../assets/util'; | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"unmute", | ||
run: (data) => { | ||
let player = data.player; | ||
const setNameUnmute = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); | ||
if (!canFindPlayer(setNameUnmute)) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setNameUnmute}§f was not found`); | ||
return; | ||
} | ||
if (!getPlayerByName(setNameUnmute).hasTag("muted")) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setNameUnmute}§f is not muted.`); | ||
return; | ||
} | ||
player.runCommandAsync('tag "' + setNameUnmute +'" remove muted'); | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Unmuted §e${setNameUnmute}`); | ||
player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bunmuted§l§5 ${setNameUnmute}! §r"}]}`); | ||
|
||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { newCommand } from '../handle'; | ||
|
||
newCommand({ | ||
name:"vanish", | ||
run: (data) => { | ||
data.player.runCommandAsync("function admin_cmds/vanish"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { scoreboardAction } from '../../assets/util'; | ||
import config from '../../config'; | ||
import { newCommand } from '../handle'; | ||
import * as Minecraft from "@minecraft/server"; | ||
|
||
const world = Minecraft.world; | ||
|
||
newCommand({ | ||
name:"worldborder", | ||
run: (data) => { | ||
let player = data.player; | ||
let oldBorder = null; | ||
world.scoreboard.getObjectives().forEach((objective) => { | ||
const objectiveId = objective.id; | ||
if (objectiveId.startsWith("safeguard:worldBorder:")) oldBorder = objectiveId.split("safeguard:worldBorder:")[1]; | ||
}); | ||
const border = data.args[1]; | ||
if (!border) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f The current border is §e${oldBorder ?? "not set"}§f.`); | ||
return; | ||
} | ||
if(border === "remove"){ | ||
if(!oldBorder) return player.sendMessage(`§6[§eSafeGuard§6]§f The world border is §enot set§f.`); | ||
scoreboardAction(`safeguard:worldBorder:${oldBorder}`,"remove"); | ||
player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bremoved the world border! §r"}]}`); | ||
player.sendMessage(`§6[§eSafeGuard§6]§r Removed the world border.`); | ||
return; | ||
} | ||
if (isNaN(border) || border === "" || border < config.world.worldborder.minBorderDistance) { | ||
player.sendMessage(`§6[§eSafeGuard§6]§f You need to enter a valid number for the border (must be more than ${config.world.worldborder.minBorderDistance}).`); | ||
return; | ||
} | ||
world.scoreboard.getObjectives().forEach((objective) => { | ||
if (objective.id.startsWith("safeguard:worldBorder:")) scoreboardAction(objective.id, "remove"); | ||
}); | ||
scoreboardAction(`safeguard:worldBorder:${border}`, "add"); | ||
player.sendMessage(`§6[§eSafeGuard§6]§f Set world border to §e${border}§f blocks.`); | ||
player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bset the world border to§5 ${border}§b blocks! §r"}]}`); | ||
|
||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.