From 65dd91c55e4f06e7cce259737a2c60f23b0c689e Mon Sep 17 00:00:00 2001 From: SRHackerr <51216880+BlaizerBrumo@users.noreply.github.com> Date: Fri, 19 Apr 2024 20:48:53 -0400 Subject: [PATCH] v1.9 --- README.md | 9 +- .../functions/admin_cmds/clearchat.mcfunction | 1 - .../admin_cmds/fake_leave.mcfunction | 1 - .../admin_cmds/fake_leave_server.mcfunction | 11 +- .../functions/admin_cmds/notify.mcfunction | 1 - .../admin_cmds/summon_npc.mcfunction | 1 - .../functions/admin_cmds/vanish.mcfunction | 1 - .../functions/anti/anti_grief.mcfunction | 25 +- .../functions/anti/anti_lag.mcfunction | 7 +- .../functions/assets/asset.mcfunction | 2 +- .../functions/assets/boom.mcfunction | 1 - .../functions/assets/death_effect.mcfunction | 1 - .../functions/assets/default.mcfunction | 1 - .../functions/assets/welcomer.mcfunction | 13 +- .../functions/check_settings.mcfunction | 2 + .../functions/credit.mcfunction | 2 +- .../punishment/ban/ac_ban.mcfunction | 1 - .../echest_ban/echest_ban.mcfunction | 1 - .../echest_ban/echest_remove.mcfunction | 1 - .../echest_ban/echest_wipe.mcfunction | 1 - .../punishment/flag/flagged.mcfunction | 4 +- .../punishment/flag/flagged_remove.mcfunction | 4 +- .../punishment/freeze/freeze.mcfunction | 4 +- .../freeze/freeze_remove.mcfunction | 3 +- .../punishment/inv_lock/inv_lock.mcfunction | 1 - .../inv_lock/inv_lock_remove.mcfunction | 1 - .../punishment/warning/warning.mcfunction | 1 - .../functions/settings/anti_gmc.mcfunction | 2 - .../functions/settings/anti_grief.mcfunction | 2 - .../functions/settings/anti_items.mcfunction | 2 - .../functions/settings/auto_mod.mcfunction | 2 - .../settings/beta/anti_fly.mcfunction | 14 + .../settings/beta/anti_scaffold.mcfunction | 14 + .../settings/beta/combat_logging.mcfunction | 14 + .../beta/invalid_velocity_check.mcfunction | 14 + .../settings/death_coords.mcfunction | 2 - .../functions/settings/lock_end.mcfunction | 2 - .../settings/no_shulker_barrels.mcfunction | 2 - .../functions/settings/welcomer.mcfunction | 2 - .../functions/setup/help.mcfunction | 4 +- .../functions/setup/setup.mcfunction | 3 + Safeguard anti-cheat B/functions/tick.json | 1 - Safeguard anti-cheat B/manifest.json | 6 +- Safeguard anti-cheat B/scripts/assets/ui.js | 162 ++++++---- Safeguard anti-cheat B/scripts/assets/util.js | 67 +++- .../scripts/command/handle.js | 24 +- .../scripts/command/importer.js | 9 +- .../scripts/command/src/ban.js | 17 +- .../scripts/command/src/clearchat.js | 1 + .../scripts/command/src/copyinv.js | 20 ++ .../scripts/command/src/fakeleave.js | 1 + .../scripts/command/src/fakeleave_server.js | 1 + .../scripts/command/src/help.js | 17 +- .../scripts/command/src/invsee.js | 8 +- .../scripts/command/src/lagclear.js | 1 + .../scripts/command/src/mute.js | 6 +- .../scripts/command/src/notify.js | 1 + .../scripts/command/src/report.js | 57 ++++ .../scripts/command/src/summon_npc.js | 1 + .../scripts/command/src/unban.js | 1 + .../scripts/command/src/unmute.js | 6 +- .../scripts/command/src/vanish.js | 1 + .../scripts/command/src/worldborder.js | 12 +- Safeguard anti-cheat B/scripts/config.js | 41 ++- Safeguard anti-cheat B/scripts/index.js | 291 +++++++++++++++--- .../safeguard/spawnPlayer.mcstructure | Bin 0 -> 272 bytes 66 files changed, 717 insertions(+), 215 deletions(-) create mode 100644 Safeguard anti-cheat B/functions/settings/beta/anti_fly.mcfunction create mode 100644 Safeguard anti-cheat B/functions/settings/beta/anti_scaffold.mcfunction create mode 100644 Safeguard anti-cheat B/functions/settings/beta/combat_logging.mcfunction create mode 100644 Safeguard anti-cheat B/functions/settings/beta/invalid_velocity_check.mcfunction create mode 100644 Safeguard anti-cheat B/scripts/command/src/copyinv.js create mode 100644 Safeguard anti-cheat B/scripts/command/src/report.js create mode 100644 Safeguard anti-cheat B/structures/safeguard/spawnPlayer.mcstructure diff --git a/README.md b/README.md index ffd946b..38e9a7a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ For any questions or help please join the official SafeGuard discord server: [di > _If player matches any of these checks, player is warned and is given weakness for 2s to prevent giving attacks_ > - **High CPS Check:** Checks if a player has a cps higher than the set amount inside of [config] > - **Multi Killaura Check:** Checks if a player attacks more entities then the set amount inside [config] + > - **Combat Log Detection:** Checks if a player rejoins the server after leaving during combat and gives them the punishment selected in [config] > > > ### 🏷️ Item Cheat Detections @@ -29,11 +30,13 @@ For any questions or help please join the official SafeGuard discord server: [di > ### 🏃 Movement Cheat Detections > _If player matches any of these checks, player is warned and the anticheat tries to fix their position by teleporting_ > - **Fly Check:** Checks if player is flying + > - **Invalid Velocity Check:** Checks if player is reaching an invalid Y velocity > > > ### 🌎 World Cheat Detections > _If player matches any of these checks, player is warned and anticheat replaces any broken blocks_ > - **Nuker Check:** Checks if player breaks more blocks than the set amount inside [config] + > - **Scaffold Check:** Checks if player is using scaffold or tower modules for horion > - **Illegal Item Place Check:** Checks if player places a block or uses an item that is inside the banned item list in [config] > > @@ -78,7 +81,7 @@ For any questions or help please join the official SafeGuard discord server: [di > - **invsee [player name]:** See the inventory of a player > - **mute [player name]:** Mute a player > - **unmute [player name]:** Unmute a player - > - **worldborder [border]:** Get or set the world border + > - **worldborder [border | remove]:** Get or set the world border > - **vanish:** Toggle vanish mode > - **clearchat:** Clear the chat > - **fakeleave:** Simulate leaving the realm @@ -86,12 +89,14 @@ For any questions or help please join the official SafeGuard discord server: [di > - **summon_npc:** Summon an NPC > - **notify:** Toggle anticheat notifications > - **lagclear:** Run lag clear function + > - **copyinv [player name]:** Copy the inventory of a player > - **unban [player name]:** Unban a player + > - **report [player name]:** Players can report other player anonymously to all online admins > > > ### 📃 Admin Panel Item > _The admin panel is an item which can be obtained with command `/give @s safeguard:admin_panel`_ - > - **Settings:** Turn SafeGuard module/feature settings + > - **Settings:** Toggle SafeGuard modules/features > - **Quick Ban:** Quickly ban a player using SafeGuard ban system > - **Player Actions:** Select an online player to ban, clear echest, warn, etc > - **Unban Player:** Enter a player's name to unban, they will be unban when they rejoin diff --git a/Safeguard anti-cheat B/functions/admin_cmds/clearchat.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/clearchat.mcfunction index c0a8785..d68fbe2 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/clearchat.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/clearchat.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #12 execute as @s[tag=admin] run tellraw @a {"rawtext":[{"text":"\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n§6[§eSafeGuard§6]§r Chat has been cleared by §d"},{"selector":"@s"}]} execute as @s[tag=!admin] run tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§4 You need admin tag to run this!§r"}]} playsound random.anvil_land @s[tag=!admin] \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/admin_cmds/fake_leave.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/fake_leave.mcfunction index 2f4e4fe..dad7a5f 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/fake_leave.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/fake_leave.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #11 execute as @s[tag=admin] run tellraw @a {"rawtext":[{"text":"§e"},{"selector":"@s"},{"text":" left the realm"}]} tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§a Fake left success!"}]} playsound random.levelup @s[tag=admin] diff --git a/Safeguard anti-cheat B/functions/admin_cmds/fake_leave_server.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/fake_leave_server.mcfunction index fe7927c..1805f5c 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/fake_leave_server.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/fake_leave_server.mcfunction @@ -1,8 +1,7 @@ -#bridge-file-version: #1 -execute as @s[tag=admin] run tellraw @a {"rawtext":[{"text":"§e"},{"selector":"@s"},{"text":" left the server"}]} -tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§a Fake left success!"}]} -playsound random.levelup @s[tag=admin] -tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!"}]} -playsound random.anvil_land @s[tag=!admin] +execute as @s[tag=admin] run tellraw @a {"rawtext":[{"text":"§e"},{"selector":"@s"},{"text":" left the server"}]} +tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§a Fake left success!"}]} +playsound random.levelup @s[tag=admin] +tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!"}]} +playsound random.anvil_land @s[tag=!admin] #notify tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s"},{"text":" §bfake left!§r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/admin_cmds/notify.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/notify.mcfunction index aabbfa6..866f82a 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/notify.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/notify.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #6 scoreboard players add @s notify 1 scoreboard players set @s[tag=admin,scores={notify=2..}] notify 0 tellraw @s[tag=admin,scores={notify=0}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§l§b You will §5no longer§b recieve anticheat notifications!§r"}]} diff --git a/Safeguard anti-cheat B/functions/admin_cmds/summon_npc.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/summon_npc.mcfunction index abbd4d0..8b7f756 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/summon_npc.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/summon_npc.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #7 execute as @s[tag=admin] run summon npc ~ ~ ~ tag @e[type=npc,r=5] add friend tellraw @s[tag=admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §aSuccessfully summoned the NPC!§r"}]} diff --git a/Safeguard anti-cheat B/functions/admin_cmds/vanish.mcfunction b/Safeguard anti-cheat B/functions/admin_cmds/vanish.mcfunction index 0333fec..b148ae9 100644 --- a/Safeguard anti-cheat B/functions/admin_cmds/vanish.mcfunction +++ b/Safeguard anti-cheat B/functions/admin_cmds/vanish.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #25 scoreboard players add @s[tag=admin] vanish 1 scoreboard players set @s[tag=admin,scores={vanish=2..}] vanish 0 effect @s[tag=admin,scores={vanish=0}] invisibility 0 0 diff --git a/Safeguard anti-cheat B/functions/anti/anti_grief.mcfunction b/Safeguard anti-cheat B/functions/anti/anti_grief.mcfunction index d8e46fe..0bdfcdd 100644 --- a/Safeguard anti-cheat B/functions/anti/anti_grief.mcfunction +++ b/Safeguard anti-cheat B/functions/anti/anti_grief.mcfunction @@ -1,19 +1,18 @@ -#bridge-file-version: #35 -tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} +tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} #gamerule -execute as @a[scores={grief_on=0}] run gamerule tntexplodes false -execute as @a[scores={grief_on=0}] run gamerule respawnblocksexplode false +execute as @a[scores={grief_on=0}] run gamerule tntexplodes false +execute as @a[scores={grief_on=0}] run gamerule respawnblocksexplode false #detect -execute as @a[scores={grief_on=0}] run execute as @e[type=tnt,tag=!admin] run tellraw @a {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"selector":"@p[tag=!admin]"},{"text":" §r§4Was detected summoning a §l§cTNT!§r"}]} -execute as @a[scores={grief_on=0}] run execute as @e[type=tnt,tag=!admin] run execute as @p run function punishment/warning/grief_warning +execute as @a[scores={grief_on=0}] run execute as @e[type=tnt,tag=!admin] run tellraw @a {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"selector":"@p[tag=!admin]"},{"text":" §r§4Was detected summoning a §l§cTNT!§r"}]} +execute as @a[scores={grief_on=0}] run execute as @e[type=tnt,tag=!admin] run execute as @p run function punishment/warning/grief_warning #clear inventory -execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] tnt 0 -execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] tnt_minecart 0 -execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] end_crystal 0 -execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] respawn_anchor 0 +execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] tnt 0 +execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] tnt_minecart 0 +execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] end_crystal 0 +execute as @a[scores={grief_on=0}] run clear @a[tag=!admin] respawn_anchor 0 #Kill tnt -execute as @a[scores={grief_on=0}] run execute as @a run kill @e[type=tnt] -execute as @a[scores={grief_on=0}] run execute as @a run kill @e[type=tnt_minecart] +execute as @a[scores={grief_on=0}] run execute as @a run kill @e[type=tnt] +execute as @a[scores={grief_on=0}] run execute as @a run kill @e[type=tnt_minecart] #Replace tnt and other explosive blocks as a security measure -execute as @a[scores={grief_on=0}] run execute as @a[tag=!admin] run fill ~8 ~5 ~8 ~-8 ~-5 ~-8 air 0 replace tnt +execute as @a[scores={grief_on=0}] run execute as @a[tag=!admin] run fill ~8 ~5 ~8 ~-8 ~-5 ~-8 air 0 replace tnt execute as @a[scores={grief_on=0}] run execute as @a[tag=!admin] run fill ~8 ~5 ~8 ~-8 ~-5 ~-8 air 0 replace fire \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/anti/anti_lag.mcfunction b/Safeguard anti-cheat B/functions/anti/anti_lag.mcfunction index 934c0e7..860e97e 100644 --- a/Safeguard anti-cheat B/functions/anti/anti_lag.mcfunction +++ b/Safeguard anti-cheat B/functions/anti/anti_lag.mcfunction @@ -1,7 +1,6 @@ -#bridge-file-version: #37 #PUT THIS IN A REPEATING COMMAND BLOCK ONLY WITH A TICK PER SECOND DELAY #Killing the entities and stuff idk -gamerule domobloot false -scoreboard objectives add anti_lag dummy -scoreboard players add @r anti_lag 1 +gamerule domobloot false +scoreboard objectives add anti_lag dummy +scoreboard players add @r anti_lag 1 execute as @a[scores={anti_lag=1}] run tellraw @a[scores={anti_lag=1}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§l§a Ground items cleared in 10 seconds..."}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/assets/asset.mcfunction b/Safeguard anti-cheat B/functions/assets/asset.mcfunction index c1e39b0..1598c07 100644 --- a/Safeguard anti-cheat B/functions/assets/asset.mcfunction +++ b/Safeguard anti-cheat B/functions/assets/asset.mcfunction @@ -106,7 +106,7 @@ scoreboard players reset @a[scores={warn_check=6001..}] warn_check tag @a[tag=warn_check] remove warn_check #warning check2 execute as @a[tag=warn_fast] run tellraw @a {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§l§c "},{"selector": "@s"},{"text":" §4is reaching warnings too fast and was softbanned!§r"}]} -execute as @a[tag=warn_fast] run tag @s add softban_five +execute as @a[tag=warn_fast] run tag @s add safeguard:reachingWarningsTooFast execute as @a[tag=warn_fast] run tag @s add warning execute as @a[tag=warn_fast] run scoreboard players reset @s warn_check execute as @a[tag=warn_fast] run tag @s remove warn_fast diff --git a/Safeguard anti-cheat B/functions/assets/boom.mcfunction b/Safeguard anti-cheat B/functions/assets/boom.mcfunction index 1e6fa74..8236680 100644 --- a/Safeguard anti-cheat B/functions/assets/boom.mcfunction +++ b/Safeguard anti-cheat B/functions/assets/boom.mcfunction @@ -1,3 +1,2 @@ -#bridge-file-version: #1 particle minecraft:huge_explosion_emitter ~~~ playsound mob.wither.break_block \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/assets/death_effect.mcfunction b/Safeguard anti-cheat B/functions/assets/death_effect.mcfunction index 62179f8..9feb964 100644 --- a/Safeguard anti-cheat B/functions/assets/death_effect.mcfunction +++ b/Safeguard anti-cheat B/functions/assets/death_effect.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #25 gamerule mobgriefing false execute as @s[scores={death_effect=0}] run summon minecraft:lightning_bolt ~ ~3~ execute as @s[scores={death_effect=0}] run playsound random.levelup @s diff --git a/Safeguard anti-cheat B/functions/assets/default.mcfunction b/Safeguard anti-cheat B/functions/assets/default.mcfunction index 6946bc4..d4e8724 100644 --- a/Safeguard anti-cheat B/functions/assets/default.mcfunction +++ b/Safeguard anti-cheat B/functions/assets/default.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #29 #These are punishments and similar tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} function assets/welcomer diff --git a/Safeguard anti-cheat B/functions/assets/welcomer.mcfunction b/Safeguard anti-cheat B/functions/assets/welcomer.mcfunction index b506bf7..b15c824 100644 --- a/Safeguard anti-cheat B/functions/assets/welcomer.mcfunction +++ b/Safeguard anti-cheat B/functions/assets/welcomer.mcfunction @@ -1,9 +1,8 @@ -#bridge-file-version: #27 #Tag -tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} -execute as @a[scores={welcome_on=0}] run scoreboard players set @a[scores={welcomer=3..}] welcomer 2 -execute as @a[scores={welcome_on=0}] run execute as @a[scores={welcomer=..1}] run tellraw @a {"rawtext":[{"text":"§e"},{"selector":"@s"},{"text":" §bIs joining for the first time! This realm is protected by §eSafeGuard§b, enjoy your stay!§r"}]} -execute as @a[scores={welcome_on=0}] run scoreboard players add @a welcomer 1 -execute as @a[scores={welcome_on=0}] run title @a[scores={welcomer=..1}] title §e§lSafe§6Guard -execute as @a[scores={welcome_on=0}] run title @a[scores={welcomer=..1}] subtitle §l§fProtecting §a24§f/§a7 +tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} +execute as @a[scores={welcome_on=0}] run scoreboard players set @a[scores={welcomer=3..}] welcomer 2 +execute as @a[scores={welcome_on=0}] run execute as @a[scores={welcomer=..1}] run tellraw @a {"rawtext":[{"text":"§e"},{"selector":"@s"},{"text":" §bIs joining for the first time! This realm is protected by §eSafeGuard§b, enjoy your stay!§r"}]} +execute as @a[scores={welcome_on=0}] run scoreboard players add @a welcomer 1 +execute as @a[scores={welcome_on=0}] run title @a[scores={welcomer=..1}] title §e§lSafe§6Guard +execute as @a[scores={welcome_on=0}] run title @a[scores={welcomer=..1}] subtitle §l§fProtecting §a24§f/§a7 execute as @a[scores={welcome_on=0}] run title @a[scores={welcomer=..1}] times 20 80 20 \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/check_settings.mcfunction b/Safeguard anti-cheat B/functions/check_settings.mcfunction index 9527624..8edc598 100644 --- a/Safeguard anti-cheat B/functions/check_settings.mcfunction +++ b/Safeguard anti-cheat B/functions/check_settings.mcfunction @@ -1,3 +1,5 @@ +tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§6§l "},{"text":"WARNING: §r§4This function is deprecated and is no longer updated, expect broken behavior and outdated information§r"}]} + #deny tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!§r"}]} playsound random.anvil_land @s[tag=!admin] diff --git a/Safeguard anti-cheat B/functions/credit.mcfunction b/Safeguard anti-cheat B/functions/credit.mcfunction index e8de11e..7d9bf66 100644 --- a/Safeguard anti-cheat B/functions/credit.mcfunction +++ b/Safeguard anti-cheat B/functions/credit.mcfunction @@ -8,4 +8,4 @@ tellraw @s {"rawtext":[{"text":"\n"}]} tellraw @s {"rawtext":[{"text":"§l§e Help"}]} tellraw @s {"rawtext":[{"text":"§l§6----------------------------------------------------------§r"}]} tellraw @s {"rawtext":[{"text":"Blazer#9677 - Join the disord for any help nGu5gehXs3"}]} -tellraw @s {"rawtext":[{"text":"Version 1.8.4"}]} \ No newline at end of file +tellraw @s {"rawtext":[{"text":"Version 1.9"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/punishment/ban/ac_ban.mcfunction b/Safeguard anti-cheat B/functions/punishment/ban/ac_ban.mcfunction index 34bff31..0f3182d 100644 --- a/Safeguard anti-cheat B/functions/punishment/ban/ac_ban.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/ban/ac_ban.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #28 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} tag @a[tag=ban,tag=!admin] add Ban scoreboard players add @a[tag=ac_ban,tag=!admin] ac_banned 1 diff --git a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_ban.mcfunction b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_ban.mcfunction index bc65d9e..35d3820 100644 --- a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_ban.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_ban.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #3 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} title @a[tag=echest_ban] times 1 1 1 title @a[tag=echest_ban] actionbar §l§4You are echest banned. diff --git a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_remove.mcfunction b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_remove.mcfunction index de28fc8..2088794 100644 --- a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_remove.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_remove.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #10 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} tellraw @a[tag=echest_unban] {"rawtext":[{"text":"§6[§eSafeGuard§6] §aEchest ban was removed!!"}]} execute as @a[tag=echest_unban] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@a[tag=echest_unban]"},{"text":"'s §benderchest ban was removed! §r"}]} diff --git a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_wipe.mcfunction b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_wipe.mcfunction index f319219..1cc5aca 100644 --- a/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_wipe.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/echest_ban/echest_wipe.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #14 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} replaceitem entity @a[tag=!admin,tag=echest_wipe] slot.enderchest 0 air replaceitem entity @a[tag=!admin,tag=echest_wipe] slot.enderchest 1 air diff --git a/Safeguard anti-cheat B/functions/punishment/flag/flagged.mcfunction b/Safeguard anti-cheat B/functions/punishment/flag/flagged.mcfunction index 593950d..31b6e71 100644 --- a/Safeguard anti-cheat B/functions/punishment/flag/flagged.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/flag/flagged.mcfunction @@ -1,7 +1,7 @@ -#bridge-file-version: #18 title @a[tag=flagged] times 1 1 1 gamemode adventure @a[tag=flagged] -effect @a[tag=flagged] slowness 1000 10 true +inputpermission set @a[tag=flagged] movement disabled +inputpermission set @a[tag=flagged] camera disabled effect @a[tag=flagged] blindness 1000 10 true title @a[tag=flagged] title §4You have been flagged!§r title @a[tag=flagged] subtitle §4Contact your admin for appeal.§r diff --git a/Safeguard anti-cheat B/functions/punishment/flag/flagged_remove.mcfunction b/Safeguard anti-cheat B/functions/punishment/flag/flagged_remove.mcfunction index 6daaa42..a675686 100644 --- a/Safeguard anti-cheat B/functions/punishment/flag/flagged_remove.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/flag/flagged_remove.mcfunction @@ -1,8 +1,8 @@ -#bridge-file-version: #17 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} tag @a[tag=unflag] remove flagged gamemode survival @a[tag=unflag] -effect @a[tag=unflag] clear +inputpermission set @a[tag=unflag] movement enabled +inputpermission set @a[tag=unflag] camera enabled tellraw @a[tag=unflag] {"rawtext":[{"text":"§6[§eSafeGuard§6] §aFlag was removed!!"}]} execute as @a[tag=unflag] run tp @p[tag=unflag] ~ 140 ~ effect @a[tag=unflag] slow_falling 60 0 true diff --git a/Safeguard anti-cheat B/functions/punishment/freeze/freeze.mcfunction b/Safeguard anti-cheat B/functions/punishment/freeze/freeze.mcfunction index 333490c..b8247e8 100644 --- a/Safeguard anti-cheat B/functions/punishment/freeze/freeze.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/freeze/freeze.mcfunction @@ -1,6 +1,4 @@ -#bridge-file-version: #10 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} title @a[tag=freeze] times 1 1 1 -execute at @a[tag=freeze] run tp @s[tag=freeze] ~ ~ ~ facing @s -effect @a[tag=freeze] slowness 100 100 true +inputpermission set @a[tag=freeze] movement disabled title @a[tag=freeze] actionbar §b§lYou are frozen.§r \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/punishment/freeze/freeze_remove.mcfunction b/Safeguard anti-cheat B/functions/punishment/freeze/freeze_remove.mcfunction index bedc164..20c58a4 100644 --- a/Safeguard anti-cheat B/functions/punishment/freeze/freeze_remove.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/freeze/freeze_remove.mcfunction @@ -1,8 +1,7 @@ -#bridge-file-version: #13 #unfreezes person tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} tag @a[tag=unfreeze] remove freeze -effect @a[tag=unfreeze] clear +inputpermission set @a[tag=unfreeze] movement enabled tellraw @a[tag=unfreeze] {"rawtext":[{"text":"§6[§eSafeGuard§6] §aFreeze was removed!!"}]} execute as @a[tag=unfreeze] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@a[tag=unfreeze]"},{"text":" §bwas unfreezed! §r"}]} tag @a[tag=unfreeze] remove unfreeze \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock.mcfunction b/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock.mcfunction index c61521e..681f252 100644 --- a/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #7 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r§c§l "},{"text":"ERROR: §r§4This function shouldn't be ran manually§r"}]} #This will clear victim's inventory and not let them use it. clear @a[tag=inv_lock] diff --git a/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock_remove.mcfunction b/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock_remove.mcfunction index 5aa7a0a..8b03115 100644 --- a/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock_remove.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/inv_lock/inv_lock_remove.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #7 tellraw @a[tag=inv_unlock] {"rawtext":[{"text":"§6[§eSafeGuard§6] §aInventory lock was removed!!"}]} clear @a[tag=inv_unlock] execute as @a[tag=inv_unlock] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@a[tag=inv_unlock]"},{"text":"'s §binventory was unlocked! §r"}]} diff --git a/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction b/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction index 021aff5..13402b5 100644 --- a/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction @@ -1,4 +1,3 @@ -#bridge-file-version: #22 execute as @a[scores={warning=3..},tag=!admin] run tag @s add ac_ban #Warning execute as @a[tag=warning,tag=!admin] run scoreboard players add @s warning 1 diff --git a/Safeguard anti-cheat B/functions/settings/anti_gmc.mcfunction b/Safeguard anti-cheat B/functions/settings/anti_gmc.mcfunction index b03b5c6..5131a44 100644 --- a/Safeguard anti-cheat B/functions/settings/anti_gmc.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/anti_gmc.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#0 #Toggle the Anti GMC scoreboard players add @s[tag=admin] gmc_toggle 1 scoreboard players set @s[tag=admin,scores={gmc_toggle=2..}] gmc_toggle 0 diff --git a/Safeguard anti-cheat B/functions/settings/anti_grief.mcfunction b/Safeguard anti-cheat B/functions/settings/anti_grief.mcfunction index 6670601..52f1602 100644 --- a/Safeguard anti-cheat B/functions/settings/anti_grief.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/anti_grief.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#2 #Toggle the Anti grief scoreboard players add @s[tag=admin] grief_toggle 1 scoreboard players set @s[tag=admin,scores={grief_toggle=2..}] grief_toggle 0 diff --git a/Safeguard anti-cheat B/functions/settings/anti_items.mcfunction b/Safeguard anti-cheat B/functions/settings/anti_items.mcfunction index 35659b9..0f5066b 100644 --- a/Safeguard anti-cheat B/functions/settings/anti_items.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/anti_items.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#0 #Toggle the Anti item scoreboard players add @s[tag=admin] item_toggle 1 scoreboard players set @s[tag=admin,scores={item_toggle=2..}] item_toggle 0 diff --git a/Safeguard anti-cheat B/functions/settings/auto_mod.mcfunction b/Safeguard anti-cheat B/functions/settings/auto_mod.mcfunction index b8df3df..f714ba0 100644 --- a/Safeguard anti-cheat B/functions/settings/auto_mod.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/auto_mod.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#19 #Toggle the auto mod scoreboard players add @s[tag=admin] auto_mod_toggle 1 scoreboard players set @s[tag=admin,scores={auto_mod_toggle=2..}] auto_mod_toggle 0 diff --git a/Safeguard anti-cheat B/functions/settings/beta/anti_fly.mcfunction b/Safeguard anti-cheat B/functions/settings/beta/anti_fly.mcfunction new file mode 100644 index 0000000..2f3961c --- /dev/null +++ b/Safeguard anti-cheat B/functions/settings/beta/anti_fly.mcfunction @@ -0,0 +1,14 @@ +#Toggle fly protection +scoreboard players add @s[tag=admin] antifly_toggle 1 +scoreboard players set @s[tag=admin,scores={antifly_toggle=2..}] antifly_toggle 0 +tellraw @s[tag=admin,scores={antifly_toggle=0}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Fly §l§5turned off! §r"}]} +execute as @s[tag=admin,scores={antifly_toggle=0}] run scoreboard objectives remove "safeguard:fly_check" +tellraw @s[tag=admin,scores={antifly_toggle=1}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Fly §l§5turned on! §r"}]} +execute as @s[tag=admin,scores={antifly_toggle=1}] run scoreboard objectives add "safeguard:fly_check" dummy +playsound note.bass @s[tag=admin] ~~~ +#deny +tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!§r"}]} +playsound random.anvil_land @s[tag=!admin] +#Notify people who turned it on +execute as @s[scores={antifly_toggle=1}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={antifly_toggle=1}]"},{"text":" §bturned on§l§5 Anti Fly! §r"}]} +execute as @s[scores={antifly_toggle=0}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={antifly_toggle=0}]"},{"text":" §bturned off§l§5 Anti Fly! §r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/settings/beta/anti_scaffold.mcfunction b/Safeguard anti-cheat B/functions/settings/beta/anti_scaffold.mcfunction new file mode 100644 index 0000000..6d440dd --- /dev/null +++ b/Safeguard anti-cheat B/functions/settings/beta/anti_scaffold.mcfunction @@ -0,0 +1,14 @@ +#Toggle the Diamond ore mine detection +scoreboard players add @s[tag=admin] safeguard:scaffold_toggle 1 +scoreboard players set @s[tag=admin,scores={safeguard:scaffold_toggle=2..}] safeguard:scaffold_toggle 0 +tellraw @s[tag=admin,scores={safeguard:scaffold_toggle=0}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Scaffold §l§5turned off! §r"}]} +execute as @s[tag=admin,scores={safeguard:scaffold_toggle=0}] run scoreboard objectives remove "safeguard:scaffold_check" +tellraw @s[tag=admin,scores={safeguard:scaffold_toggle=1}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Scaffold §l§5turned on! §r"}]} +execute as @s[tag=admin,scores={safeguard:scaffold_toggle=1}] run scoreboard objectives add "safeguard:scaffold_check" dummy +playsound note.bass @s[tag=admin] ~~~ +#deny +tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!§r"}]} +playsound random.anvil_land @s[tag=!admin] +#Notify people who turned it on +execute as @s[scores={safeguard:scaffold_toggle=1}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:scaffold_toggle=1}]"},{"text":" §bturned on§l§5 Anti Scaffold! §r"}]} +execute as @s[scores={safeguard:scaffold_toggle=0}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:scaffold_toggle=0}]"},{"text":" §bturned off§l§5 Anti Scaffold! §r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/settings/beta/combat_logging.mcfunction b/Safeguard anti-cheat B/functions/settings/beta/combat_logging.mcfunction new file mode 100644 index 0000000..30b3bf8 --- /dev/null +++ b/Safeguard anti-cheat B/functions/settings/beta/combat_logging.mcfunction @@ -0,0 +1,14 @@ +#Toggle the Diamond ore mine detection +scoreboard players add @s[tag=admin] safeguard:combatlog_toggle 1 +scoreboard players set @s[tag=admin,scores={safeguard:combatlog_toggle=2..}] safeguard:combatlog_toggle 0 +tellraw @s[tag=admin,scores={safeguard:combatlog_toggle=0}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Combat Logging §l§5turned off! §r"}]} +execute as @s[tag=admin,scores={safeguard:combatlog_toggle=0}] run scoreboard objectives remove "safeguard:anti_combatlog" +tellraw @s[tag=admin,scores={safeguard:combatlog_toggle=1}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Anti Combat Logging §l§5turned on! §r"}]} +execute as @s[tag=admin,scores={safeguard:combatlog_toggle=1}] run scoreboard objectives add "safeguard:anti_combatlog" dummy +playsound note.bass @s[tag=admin] ~~~ +#deny +tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!§r"}]} +playsound random.anvil_land @s[tag=!admin] +#Notify people who turned it on +execute as @s[scores={safeguard:combatlog_toggle=1}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:combatlog_toggle=1}]"},{"text":" §bturned on§l§5 Anti Combat Logging! §r"}]} +execute as @s[scores={safeguard:combatlog_toggle=0}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:combatlog_toggle=0}]"},{"text":" §bturned off§l§5 Anti Combat Logging! §r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/settings/beta/invalid_velocity_check.mcfunction b/Safeguard anti-cheat B/functions/settings/beta/invalid_velocity_check.mcfunction new file mode 100644 index 0000000..529c2c7 --- /dev/null +++ b/Safeguard anti-cheat B/functions/settings/beta/invalid_velocity_check.mcfunction @@ -0,0 +1,14 @@ +#Toggle the Diamond ore mine detection +scoreboard players add @s[tag=admin] safeguard:velocity_check_toggle 1 +scoreboard players set @s[tag=admin,scores={safeguard:velocity_check_toggle=2..}] safeguard:velocity_check_toggle 0 +tellraw @s[tag=admin,scores={safeguard:velocity_check_toggle=0}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Invalid Velocity Check §l§5turned off! §r"}]} +execute as @s[tag=admin,scores={safeguard:velocity_check_toggle=0}] run scoreboard objectives remove "safeguard:velocity_check" +tellraw @s[tag=admin,scores={safeguard:velocity_check_toggle=1}] {"rawtext":[{"text":"§6[§eSafeGuard§6]§b Invalid Velocity Check §l§5turned on! §r"}]} +execute as @s[tag=admin,scores={safeguard:velocity_check_toggle=1}] run scoreboard objectives add "safeguard:velocity_check" dummy +playsound note.bass @s[tag=admin] ~~~ +#deny +tellraw @s[tag=!admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§r §4You need admin tag to run this!§r"}]} +playsound random.anvil_land @s[tag=!admin] +#Notify people who turned it on +execute as @s[scores={safeguard:velocity_check_toggle=1}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:velocity_check_toggle=1}]"},{"text":" §bturned on§l§5 Invalid Velocity Check! §r"}]} +execute as @s[scores={safeguard:velocity_check_toggle=0}] run tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"selector":"@s[scores={safeguard:velocity_check_toggle=0}]"},{"text":" §bturned off§l§5 Invalid Velocity Check! §r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/settings/death_coords.mcfunction b/Safeguard anti-cheat B/functions/settings/death_coords.mcfunction index 6b75334..4ef7378 100644 --- a/Safeguard anti-cheat B/functions/settings/death_coords.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/death_coords.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#2 #Toggle the Death Coords scoreboard players add @s[tag=admin] death_coord 1 scoreboard players set @s[tag=admin,scores={death_coord=2..}] death_coord 0 diff --git a/Safeguard anti-cheat B/functions/settings/lock_end.mcfunction b/Safeguard anti-cheat B/functions/settings/lock_end.mcfunction index 91f19a8..1f9225c 100644 --- a/Safeguard anti-cheat B/functions/settings/lock_end.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/lock_end.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#27 #Toggle the end lock scoreboard players add @s[tag=admin] endnether_toggle 1 scoreboard players set @s[tag=admin,scores={endnether_toggle=2..}] endnether_toggle 0 diff --git a/Safeguard anti-cheat B/functions/settings/no_shulker_barrels.mcfunction b/Safeguard anti-cheat B/functions/settings/no_shulker_barrels.mcfunction index f2dae12..fbeb648 100644 --- a/Safeguard anti-cheat B/functions/settings/no_shulker_barrels.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/no_shulker_barrels.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#14 #Toggle the shulker and barrel ban scoreboard players add @s[tag=admin] shulkBarrel_lock 1 scoreboard players set @s[tag=admin,scores={shulkBarrel_lock=4..}] shulkBarrel_lock 0 diff --git a/Safeguard anti-cheat B/functions/settings/welcomer.mcfunction b/Safeguard anti-cheat B/functions/settings/welcomer.mcfunction index 846baea..9d62311 100644 --- a/Safeguard anti-cheat B/functions/settings/welcomer.mcfunction +++ b/Safeguard anti-cheat B/functions/settings/welcomer.mcfunction @@ -1,5 +1,3 @@ -#bridge-file-version: #0 -#0 #Toggle the Welcomer scoreboard players add @s[tag=admin] welcome 1 scoreboard players set @s[tag=admin,scores={welcome=2..}] welcome 0 diff --git a/Safeguard anti-cheat B/functions/setup/help.mcfunction b/Safeguard anti-cheat B/functions/setup/help.mcfunction index 2ee9073..5d527a3 100644 --- a/Safeguard anti-cheat B/functions/setup/help.mcfunction +++ b/Safeguard anti-cheat B/functions/setup/help.mcfunction @@ -1,4 +1,2 @@ -#bridge-file-version: #9 tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r Please join our discord server for help! Invite: §ediscord.gg/nGu5gehXs3§r"}]} -tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r Please also read the github page for command help. Link: §egithub.com/BlaizerBrumo/SafeGuard/§r"}]} -structure load help ~~~ \ No newline at end of file +tellraw @s {"rawtext":[{"text":"§6[§eSafeGuard§6]§r Please also read the github page for command help. Link: §egithub.com/BlaizerBrumo/SafeGuard/§r"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/setup/setup.mcfunction b/Safeguard anti-cheat B/functions/setup/setup.mcfunction index d815aa0..a2e8b6f 100644 --- a/Safeguard anti-cheat B/functions/setup/setup.mcfunction +++ b/Safeguard anti-cheat B/functions/setup/setup.mcfunction @@ -21,6 +21,9 @@ scoreboard objectives add killaura_toggle dummy scoreboard objectives add spammer_toggle dummy scoreboard objectives add antifly_toggle dummy scoreboard objectives add antinuker_toggle dummy +scoreboard objectives add safeguard:scaffold_toggle dummy +scoreboard objectives add safeguard:velocity_check_toggle dummy +scoreboard objectives add safeguard:combatlog_toggle dummy scoreboard players add @a setup_success 0 #warning scoreboard setup scoreboard objectives add ill_warning dummy diff --git a/Safeguard anti-cheat B/functions/tick.json b/Safeguard anti-cheat B/functions/tick.json index c4fb8f0..c16ab63 100644 --- a/Safeguard anti-cheat B/functions/tick.json +++ b/Safeguard anti-cheat B/functions/tick.json @@ -1,4 +1,3 @@ -//bridge-file-version: #7 { "values": [ "assets/default" diff --git a/Safeguard anti-cheat B/manifest.json b/Safeguard anti-cheat B/manifest.json index f562a21..6e3c8dd 100644 --- a/Safeguard anti-cheat B/manifest.json +++ b/Safeguard anti-cheat B/manifest.json @@ -2,7 +2,7 @@ "format_version": 2, "header": { "name": "§l§eSafe§6Guard §fAntiCheat§r", - "description": "§l§fMade by §eBlazer#9677 §fV1.8.5\nBeta API §cREQUIRED", + "description": "§l§fMade by §eBlazer#9677 §fV1.9\nBeta API §cREQUIRED", "uuid": "81b13565-181a-42ee-abd9-a7bd3cb2dba4", "min_engine_version": [ 1, @@ -11,8 +11,8 @@ ], "version": [ 1, - 8, - 5 + 9, + 0 ] }, "modules": [ diff --git a/Safeguard anti-cheat B/scripts/assets/ui.js b/Safeguard anti-cheat B/scripts/assets/ui.js index 50fdf98..128e4cc 100644 --- a/Safeguard anti-cheat B/scripts/assets/ui.js +++ b/Safeguard anti-cheat B/scripts/assets/ui.js @@ -1,6 +1,6 @@ import * as Minecraft from '@minecraft/server'; import { ActionFormData, MessageFormData, ModalFormData } from '@minecraft/server-ui'; -import { invsee, unban, millisecondTime } from './util.js'; +import { invsee, unban, millisecondTime, sendMessageToAllAdmins } from './util.js'; const world = Minecraft.world; @@ -15,10 +15,14 @@ function banForm(player,targetPlayer,type,banReason){ .button1("Cancel") confirmF.show(player).then((confirmData) => { if(confirmData.selection === 1){ - player.addTag('Ban'); + targetPlayer.addTag("safeguard:Ban"); + const now = Date.now(); + targetPlayer.addTag(`safeguardBanInfo**true**${now}**${player.name}**No reason provided.`); + targetPlayer.runCommandAsync(`kick "${targetPlayer.name}" §r§6[§eSafeGuard§6]§r §4You are permanently banned.\n§4Reason: §cNo reason provided\n§4Banned by: §c${player.name}`) + player.sendMessage(`§6[§eSafeGuard§6]§f Banned §e${targetPlayer.name}`); - player.runCommandAsync(`kick "${targetPlayer.name}" §r§6[§eSafeGuard§6]§r §4You were banned by §c${player.name}`) - player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bbanned§l§5 ${targetPlayer.name}! §r"}]}`); + sendMessageToAllAdmins(`"§6[§eSafeGuard Notify§6]§5§l ${player.name} §bbanned§l§5 ${targetPlayer.name}! §r`,true); + //player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bbanned§l§5 ${targetPlayer.name}! §r"}]}`); } else return player.sendMessage(`§6[§eSafeGuard§6]§f Cancelled`); @@ -49,7 +53,8 @@ function banForm(player,targetPlayer,type,banReason){ targetPlayer.addTag(`safeguard:Ban`); player.sendMessage(`§6[§eSafeGuard§6]§f Banned §e${targetPlayer.name}`); - player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bbanned§l§5 ${targetPlayer.name}! §r"}]}`); + sendMessageToAllAdmins(`"§6[§eSafeGuard Notify§6]§5§l ${player.name} §bbanned§l§5 ${targetPlayer.name}! §r`,true); + //player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bbanned§l§5 ${targetPlayer.name}! §r"}]}`); if(!isPermanent) player.runCommandAsync(`kick "${targetPlayer.name}" §r§6[§eSafeGuard§6]§r §4You are banned.\n§4Time Remaining: §c${values[0]} Days ${values[1]} Hours ${values[2]} Mins\n§4Reason: §c${banReason == "" ? "No reason provided." : banReason}\n§4Banned by: §c${player.name}`) if(isPermanent) player.runCommandAsync(`kick "${targetPlayer.name}" §r§6[§eSafeGuard§6]§r §4You are permanently banned.\n§4Reason: §c${banReason == "" ? "No reason provided." : banReason}\n§4Banned by: §c${player.name}`) @@ -78,9 +83,9 @@ export function unbanForm(player){ //settings form function moduleSettingsForm(player){ - const settings = ["anti_gmc","anti_grief","anti_items","auto_mod","death_coords","death_effect","lock_end","welcomer","anti_autoclicker","anti_fly","anti_killaura","anti_nuker","anti_spammer"]; - const settingsName = ["Anti GMC","Anti Grief","Anti Items","Auto Mod","Death Coords","Death Effect","Lock End","Welcomer","High CPS Check","Anti Fly","Anti Killaura","Anti Block Nuker","Anti Spammer"]; - const settingsScoreboard = ["gmc_on","grief_on","item_on","auto_mod_on","death_coord_on","death_effect","end_lock","welcome_on","safeguard:cps_check","safeguard:fly_check","safeguard:killaura_check","safeguard:nuker_check","safeguard:spammer_protection"]; + const settings = ["anti_gmc","anti_grief","anti_items","auto_mod","death_coords","death_effect","lock_end","welcomer","anti_autoclicker","anti_killaura","anti_nuker","anti_spammer"]; + const settingsName = ["Anti GMC","Anti Grief","Anti Items","Auto Mod","Death Coords","Death Effect","Lock End","Welcomer","High CPS Check","Anti Killaura","Anti Block Nuker","Anti Spammer"]; + const settingsScoreboard = ["gmc_on","grief_on","item_on","auto_mod_on","death_coord_on","death_effect","end_lock","welcome_on","safeguard:cps_check","safeguard:killaura_check","safeguard:nuker_check","safeguard:spammer_protection"]; let settingsform = new ModalFormData() @@ -150,16 +155,60 @@ function oreAlertSettingsForm(player){ }) } +function betaFeatureSettingsForm(player){ + + const settings = ["anti_fly","anti_scaffold","invalid_velocity_check","combat_logging"]; + const settingsName = ["Anti Fly","Anti Scaffold","Invalid Velocity Check","Anti Combat Logging"]; + const settingsScoreboard = ["safeguard:fly_check","safeguard:scaffold_check","safeguard:velocity_check","safeguard:anti_combatlog"]; + + let betaFeaturesForm = new ModalFormData() + .title("SafeGuard Beta Feature Settings") + + for (let i = 0; i < settings.length; i++) { + const setting = settingsName[i]; + const scoreboard = settingsScoreboard[i]; + const isSettingEnabled = world.scoreboard.getObjective(scoreboard) !== undefined; + + betaFeaturesForm.toggle(setting, isSettingEnabled); + } + + betaFeaturesForm.show(player).then((formData) => { + if (formData.canceled) { + player.sendMessage(`§6[§eSafeGuard§6]§r You closed the form without saving!`); + return; + } + let warningDisplayed = false; + for (let i = 0; i < settings.length; i++) { + + const setting = settings[i]; + const scoreboard = settingsScoreboard[i]; + const isSettingEnabled = world.scoreboard.getObjective(scoreboard) !== undefined; + const shouldEnableSetting = formData.formValues[i]; + + if(shouldEnableSetting && !warningDisplayed){ + warningDisplayed = true; + player.sendMessage(`§6[§eSafeGuard§6] §4Warning!§c You just turned on a beta feature, these features are still being tested and could potentially have false positive, for this, SafeGuard sends alerts for beta features only to admins. Submit your feedback on these features in the offical SafeGuard discord: discord.gg/nGu5gehXs3§r`) + } + + if (isSettingEnabled !== shouldEnableSetting) { + player.runCommand(`function settings/beta/${setting}`); + } + } + }) +} + export function settingsForm(player){ let form = new ActionFormData() .title("SafeGuard Setting Selection") .body("Choose which settings you want to update:") .button("Module Settings") - .button("Ore alert settings") + .button("Ore Alert Settings") + .button("Beta Feature Settings") form.show(player).then((formData) => { if(formData.canceled) return player.sendMessage(`§6[§eSafeGuard§6]§r You closed the form without saving!`); if(formData.selection === 0) return moduleSettingsForm(player); if(formData.selection === 1) return oreAlertSettingsForm(player); + if(formData.selection === 2) return betaFeatureSettingsForm(player); }) } @@ -182,7 +231,7 @@ export function playerSelectionForm(player,action){ } function playerActionForm(player,targetPlayer){ - if(targetPlayer.hasTag("admin")) return player.sendMessage(`§6[§eSafeGuard§6]§r Can't perform actions on §e${targetPlayer.name}§f they're an admin.`); + //if(targetPlayer.hasTag("admin")) return player.sendMessage(`§6[§eSafeGuard§6]§r Can't perform actions on §e${targetPlayer.name}§f they're an admin.`); const playerActions = ["Ban Player","Kick Player","Warn Player","Echest Wipe","Freeze Player","Mute Player","View Inventory","Unmute Player","Unfreeze Player","Remove All Warnings"]; @@ -195,49 +244,56 @@ function playerActionForm(player,targetPlayer){ const action = formData.formValues[0]; const reason = formData.formValues[1] ?? ""; - player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bperformed ${playerActions[action]} on§l§5 ${targetPlayer.name}! §r"}]}`); - if(action === 0){ - return banForm(player,targetPlayer,"slow",reason); - } - if(action === 1) player.runCommandAsync(`kick "${targetPlayer.name}" ${reason}`); - if(action === 2){ - let warnings = world.scoreboard.getObjective("warning"); - if(warnings == undefined) return player.sendMessage(`§6[§eSafeGuard§6]§r §c§lERROR:§4 Please setup the anticheat!`); - let newWarnings = warnings.getScore(targetPlayer.scoreboardIdentity) + 1; - world.scoreboard.setScore(warnings,targetPlayer.scoreboardIdentity,newWarnings); - targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r§4§l You were warned!${reason ? ` Reason: §c${reason}` : ""}`); - if(newWarnings == 2) targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r§l§c §4Next warning will result in a permanent ban!§r`); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully warned player §e${targetPlayer.name}`); - } - if(action === 3){ - targetPlayer.addTag("echest_wipe"); - if(reason) targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r §4Reason: §c${reason}`); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully wiped §e${targetPlayer.name}§f's enderchest`) - } - if(action === 4){ - targetPlayer.addTag("freeze"); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully frozen §e${targetPlayer.name}`); - } - if(action === 5){ - targetPlayer.addTag("muted"); - targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r §4You were muted!${reason ? ` Reason: §c${reason}` : ""}`); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully muted §e${targetPlayer.name}`); - } - if(action === 6) return invsee(player.name,targetPlayer.name); - if(action === 7){ - if(!targetPlayer.hasTag("muted")) return player.sendMessage(`§6[§eSafeGuard§6]§r §e${targetPlayer.name}§f is not muted!`); - targetPlayer.removeTag("muted"); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully unmuted §e${targetPlayer.name}`); - player.sendMessage(`§6[§eSafeGuard§6]§r You were unmuted!`) - } - if(action === 8){ - if(!targetPlayer.hasTag("freeze")) return player.sendMessage(`§6[§eSafeGuard§6]§r §e${targetPlayer.name}§f is not frozen`); - targetPlayer.addTag("unfreeze"); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully unfreezed §e${targetPlayer.name}`); - } - if(action === 9){ - targetPlayer.addTag("warning_reset"); - player.sendMessage(`§6[§eSafeGuard§6]§r Successfully reset all warnings of §e${targetPlayer.name}`); + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bperformed ${playerActions[action]} on§l§5 ${targetPlayer.name}! §r`,true); + //player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bperformed ${playerActions[action]} on§l§5 ${targetPlayer.name}! §r"}]}`); + switch(action){ + case 0: + return banForm(player,targetPlayer,"slow",reason); + break; + case 1: + player.runCommandAsync(`kick "${targetPlayer.name}" ${reason}`); + break + case 2: + let warnings = world.scoreboard.getObjective("warning"); + if(warnings == undefined) return player.sendMessage(`§6[§eSafeGuard§6]§r §c§lERROR:§4 Please setup the anticheat!`); + let newWarnings = warnings.getScore(targetPlayer.scoreboardIdentity) + 1; + world.scoreboard.setScore(warnings,targetPlayer.scoreboardIdentity,newWarnings); + targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r§4§l You were warned!${reason ? ` Reason: §c${reason}` : ""}`); + if(newWarnings == 2) targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r§l§c §4Next warning will result in a permanent ban!§r`); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully warned player §e${targetPlayer.name}`); + break; + case 3: + targetPlayer.addTag("echest_wipe"); + if(reason) targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r §4Reason: §c${reason}`); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully wiped §e${targetPlayer.name}§f's enderchest`) + break; + case 4: + targetPlayer.addTag("freeze"); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully frozen §e${targetPlayer.name}`); + break; + case 5: + targetPlayer.addTag("muted"); + targetPlayer.sendMessage(`§6[§eSafeGuard§6]§r §4You were muted!${reason ? ` Reason: §c${reason}` : ""}`); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully muted §e${targetPlayer.name}`); + break; + case 6: + return invsee(player.name,targetPlayer.name); + break + case 7: + if(!targetPlayer.hasTag("muted")) return player.sendMessage(`§6[§eSafeGuard§6]§r §e${targetPlayer.name}§f is not muted!`); + targetPlayer.removeTag("muted"); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully unmuted §e${targetPlayer.name}`); + player.sendMessage(`§6[§eSafeGuard§6]§r You were unmuted!`) + break; + case 8: + if(!targetPlayer.hasTag("freeze")) return player.sendMessage(`§6[§eSafeGuard§6]§r §e${targetPlayer.name}§f is not frozen`); + targetPlayer.addTag("unfreeze"); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully unfreezed §e${targetPlayer.name}`); + break; + case 9: + targetPlayer.addTag("warning_reset"); + player.sendMessage(`§6[§eSafeGuard§6]§r Successfully reset all warnings of §e${targetPlayer.name}`); + break; } }) } diff --git a/Safeguard anti-cheat B/scripts/assets/util.js b/Safeguard anti-cheat B/scripts/assets/util.js index f240d0f..3ad9b51 100644 --- a/Safeguard anti-cheat B/scripts/assets/util.js +++ b/Safeguard anti-cheat B/scripts/assets/util.js @@ -1,5 +1,5 @@ import * as Minecraft from "@minecraft/server"; - +import * as config from "../config"; const world = Minecraft.world; @@ -24,9 +24,30 @@ export function formatMilliseconds(milliseconds) { const formattedMinutes = String(minutes).padStart(2, '0'); return `${formattedDays} Days ${formattedHours} Hours ${formattedMinutes} Mins`; - } +} +export function parsePunishmentTime(punishment) { + if (punishment.length !== 2) { + return null; + } - + const amount = parseInt(punishment[0]); + if (isNaN(amount) || amount <= 0) { + return null; + } + + const unit = punishment[1].toLowerCase(); + const multiplier = { + minute: millisecondTime.minute, + hour: millisecondTime.hour, + day: millisecondTime.day, + }[unit]; + + if (!multiplier) { + return null; + } + + return amount * multiplier; +} export function invsee(sender, target) { const senderPlayer = getPlayerByName(sender); const targetPlayer = getPlayerByName(target); @@ -74,7 +95,45 @@ export function unban(player,playerName){ export function isRiding(player){ if(player.getComponent("minecraft:riding")) return true else return false - } +} + +export function sendMessageToAllAdmins(message = "No message provided",isANotification = false){ + if(config.default.debug) return world.sendMessage(message); + let entityQueryOptions = { + tags:["admin"] + }; + if(isANotification){ + entityQueryOptions.scoreOptions = [{ + objective: "notify", + maxScore: 1, + minScore: 1, + exclude: false + }] + } + + const adminPlayers = world.getPlayers(entityQueryOptions); + adminPlayers.forEach((admin) => { + admin.sendMessage(message); + }) +} + +export function teleportToGround(player) { + const playerPosition = player.location; + const eyeY = playerPosition.y + 1.6; // Adjust for eye position + + const raycastStart = { x: playerPosition.x, y: eyeY, z: playerPosition.z }; + const raycastDirection = { x: 0, y: -1, z: 0 }; + const dimension = player.dimension; + + const tempBlock = dimension.getBlockFromRay(raycastStart,raycastDirection).block; + if(!tempBlock){ + console.warn("Couldn't teleport player to the ground."); + return + } + Minecraft.system.run(() => { + player.tryTeleport({ x: tempBlock.x, y: tempBlock.y + 1, z: tempBlock.z }); + }) +} export function copyInv(player,target){ Minecraft.system.run(()=>{ diff --git a/Safeguard anti-cheat B/scripts/command/handle.js b/Safeguard anti-cheat B/scripts/command/handle.js index 698a815..f9f4bc8 100644 --- a/Safeguard anti-cheat B/scripts/command/handle.js +++ b/Safeguard anti-cheat B/scripts/command/handle.js @@ -3,26 +3,44 @@ 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!`) + if(commands[obj.name]) return console.error(`§4[SafeGuard] A command named "${obj.name}" already exists!`) + if(!obj.description) { + obj.description = "No description provided"; + console.error(`§4[SafeGuard] The command "${obj.name}" does not have a description!`) + } + if(obj.adminOnly !== false) obj.adminOnly = true; commands[obj.name] = obj; } +export function getHelpData() { + const helpData = []; + for (const commandName in commands) { + const command = commands[commandName]; + helpData.push({ name: command.name, description: command.description, adminOnly: command.adminOnly }); + } + return helpData; +} + 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]; + const command = commands[cmdName]; data.cancel = true; - if(!commands[cmdName]) return player.sendMessage(`§cUnknown command: §f${args[0]}`); + if(!command) return player.sendMessage(`§cUnknown command: §f${args[0]}`); let runData = { args: args, player: player, message: message } + if(cmdName == "help") runData.commandsData = getHelpData(); - commands[cmdName].run(runData); + if(command.adminOnly && !player.hasTag("admin")) return player.sendMessage('§6[§eSafeGuard§6]§r§c You need admin tag to run this!'); + + command.run(runData); } \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/importer.js b/Safeguard anti-cheat B/scripts/command/importer.js index ebdd604..51e2db0 100644 --- a/Safeguard anti-cheat B/scripts/command/importer.js +++ b/Safeguard anti-cheat B/scripts/command/importer.js @@ -1,10 +1,10 @@ //import all commands -import "../command/src/help"; import "../command/src/ban"; +import "../command/src/unban"; import "../command/src/invsee"; +import "../command/src/copyinv"; 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"; @@ -12,4 +12,7 @@ import "../command/src/fakeleave"; import "../command/src/fakeleave_server"; import "../command/src/lagclear"; import "../command/src/notify"; -import "../command/src/worldborder"; \ No newline at end of file +import "../command/src/worldborder"; +import "../command/src/help"; + +import "../command/src/report"; \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/ban.js b/Safeguard anti-cheat B/scripts/command/src/ban.js index 7746a15..c688235 100644 --- a/Safeguard anti-cheat B/scripts/command/src/ban.js +++ b/Safeguard anti-cheat B/scripts/command/src/ban.js @@ -1,21 +1,28 @@ -import { canFindPlayer, getPlayerByName } from '../../assets/util'; +import { canFindPlayer, getPlayerByName, sendMessageToAllAdmins } from '../../assets/util'; import { newCommand } from '../handle'; newCommand({ name:"ban", + description:" Permanently bans a player by their name", run: (data) => { - let player = data.player; + const {player} = data; + 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")) { + const bannedPlayer = getPlayerByName(setNameBan); + if (bannedPlayer.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'); + bannedPlayer.addTag("safeguard:Ban"); + const now = Date.now(); + bannedPlayer.addTag(`safeguardBanInfo**true**${now}**${player.name}**No reason provided.`); + bannedPlayer.runCommandAsync(`kick "${bannedPlayer.name}" §r§6[§eSafeGuard§6]§r §4You are permanently banned.\n§4Reason: §cNo reason provided\n§4Banned by: §c${player.name}`) 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"}]}`); + sendMessageToAllAdmins(`"§6[§eSafeGuard Notify§6]§5§l ${player.name} §bbanned§l§5 ${setNameBan}! §r`,true); + //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"}]}`); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/clearchat.js b/Safeguard anti-cheat B/scripts/command/src/clearchat.js index 103f628..93a2168 100644 --- a/Safeguard anti-cheat B/scripts/command/src/clearchat.js +++ b/Safeguard anti-cheat B/scripts/command/src/clearchat.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"clearchat", + description: "Clear the chat", run: (data) => { data.player.runCommandAsync("function admin_cmds/clearchat"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/copyinv.js b/Safeguard anti-cheat B/scripts/command/src/copyinv.js new file mode 100644 index 0000000..427238c --- /dev/null +++ b/Safeguard anti-cheat B/scripts/command/src/copyinv.js @@ -0,0 +1,20 @@ +import { newCommand } from '../handle'; +import { getPlayerByName,copyInv, canFindPlayer, sendMessageToAllAdmins } from '../../assets/util'; + +newCommand({ + name:"copyinv", + description: " Copies all the player items into your inventory", + run: (data) => { + const {player} = data; + + const setName = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); + if(!canFindPlayer(setName)) return player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setName}§f was not found`); + if (getPlayerByName(setName).hasTag("admin")) { + data.player.sendMessage(`§6[§eSafeGuard§6]§f Can't copy the inventory of §e${setName}§f, they're an admin.`); + return; + } + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bcopied the inventory of§l§5 ${setName}! §r`,true); + //data.player.runCommandAsync(`tellraw @a[tag=admin,scores={notify=1}] {"rawtext":[{"text":"§6[§eSafeGuard Notify§6]§5§l "},{"text":"${player.name} §bcopied the inventory of§l§5 ${setNameInvsee.replace("@", "")}! §r"}]}`); + copyInv(data.player,setName); + } +}) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/fakeleave.js b/Safeguard anti-cheat B/scripts/command/src/fakeleave.js index 36bfc89..fb9887b 100644 --- a/Safeguard anti-cheat B/scripts/command/src/fakeleave.js +++ b/Safeguard anti-cheat B/scripts/command/src/fakeleave.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"fakeleave", + description: "Simulate leaving the realm", run: (data) => { data.player.runCommandAsync("function admin_cmds/fake_leave"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/fakeleave_server.js b/Safeguard anti-cheat B/scripts/command/src/fakeleave_server.js index 7c2c734..40776af 100644 --- a/Safeguard anti-cheat B/scripts/command/src/fakeleave_server.js +++ b/Safeguard anti-cheat B/scripts/command/src/fakeleave_server.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"fakeleave_server", + description: "Simulate leaving the server", run: (data) => { data.player.runCommandAsync("function admin_cmds/fake_leave_server"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/help.js b/Safeguard anti-cheat B/scripts/command/src/help.js index c13af42..809bb19 100644 --- a/Safeguard anti-cheat B/scripts/command/src/help.js +++ b/Safeguard anti-cheat B/scripts/command/src/help.js @@ -1,10 +1,21 @@ import { newCommand } from '../handle'; -import config from '../../config'; +import * as config from '../../config'; newCommand({ name:"help", + description: "Shows help message", + adminOnly: false, 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 §r|| to ban a person\n§einvsee §r|| see inventory of a player\n§ecopyinv §r|| copy inventory of a player to yours\n§emute §r|| mute a player\n§eunmute §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 §r|| unban a player`) + const {commandsData, player} = data; + + const playerIsAdmin = player.hasTag("admin"); + + let helpMessage = `§eREALM COMMAND PREFIX: §6${config.default.chat.prefix}§e\nAVAILABLE COMMANDS:§r\n\n`; + for (const command of commandsData) { + if(playerIsAdmin) helpMessage += `§6${command.name}§r - §e§o${command.description}§r\n`; + else if(!playerIsAdmin && !command.adminOnly) helpMessage += `§6${command.name}§r - §e§o${command.description}§r\n`; + } + + player.sendMessage(helpMessage); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/invsee.js b/Safeguard anti-cheat B/scripts/command/src/invsee.js index 212dc3e..f7aab19 100644 --- a/Safeguard anti-cheat B/scripts/command/src/invsee.js +++ b/Safeguard anti-cheat B/scripts/command/src/invsee.js @@ -1,15 +1,19 @@ import { newCommand } from '../handle'; -import { getPlayerByName, invsee } from '../../assets/util'; +import { canFindPlayer, getPlayerByName, invsee, sendMessageToAllAdmins } from '../../assets/util'; newCommand({ name:"invsee", + description: " List all the items that the player has in their inventory", run: (data) => { const setNameInvsee = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); + + if(!canFindPlayer(setNameInvsee)) return player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${setNameInvsee}§f was not found`); 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"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${data.player.name} §bviewed the inventory of§l§5 ${setNameInvsee.replace("@", "")}! §r`,true); + //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); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/lagclear.js b/Safeguard anti-cheat B/scripts/command/src/lagclear.js index 2ff1702..f56470c 100644 --- a/Safeguard anti-cheat B/scripts/command/src/lagclear.js +++ b/Safeguard anti-cheat B/scripts/command/src/lagclear.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"lagclear", + description:"Clears lag by killing entities", run: (data) => { data.player.runCommandAsync("function anti/anti_lag"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/mute.js b/Safeguard anti-cheat B/scripts/command/src/mute.js index dce8f66..d039090 100644 --- a/Safeguard anti-cheat B/scripts/command/src/mute.js +++ b/Safeguard anti-cheat B/scripts/command/src/mute.js @@ -1,8 +1,9 @@ -import { canFindPlayer, getPlayerByName } from '../../assets/util'; +import { canFindPlayer, getPlayerByName, sendMessageToAllAdmins } from '../../assets/util'; import { newCommand } from '../handle'; newCommand({ name:"mute", + description:" Prevents player from sending chat messages until unmuted", run: (data) => { let player = data.player; const setNameMute = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); @@ -16,7 +17,8 @@ newCommand({ } 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"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bmuted§l§5 ${setNameMute}! §r`,true); + //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"}]}`); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/notify.js b/Safeguard anti-cheat B/scripts/command/src/notify.js index 2d91f20..6ff7d4a 100644 --- a/Safeguard anti-cheat B/scripts/command/src/notify.js +++ b/Safeguard anti-cheat B/scripts/command/src/notify.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"notify", + description:"Toggle anticheat notifications", run: (data) => { data.player.runCommandAsync("function admin_cmds/notify"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/report.js b/Safeguard anti-cheat B/scripts/command/src/report.js new file mode 100644 index 0000000..bee8288 --- /dev/null +++ b/Safeguard anti-cheat B/scripts/command/src/report.js @@ -0,0 +1,57 @@ +import { canFindPlayer, getPlayerByName, sendMessageToAllAdmins } from '../../assets/util'; +import {newCommand} from '../handle'; + +newCommand({ + name: "report", + description: " Report a player privately to online admins", + adminOnly: false, + run: (data) => { + const {args, player} = data; + + // Check if there are enough arguments + if (args.length < 2) { + return player.sendMessage("§6[§eSafeGuard§6]§f Usage: !report "); + } + + if (args[1].startsWith('"') || args[1].startsWith('@"')) { + let closingQuoteIndex = -1; + for (let i = 1; i < args.length; i++) { + if (args[i].endsWith('"')) { + closingQuoteIndex = i; + break; + } + } + if (closingQuoteIndex === -1) { + return player.sendMessage("§6[§eSafeGuard§6]§f Invalid format! Closing quotation mark missing for player name."); + } + const playerName = args.slice(1, closingQuoteIndex + 1).join(" ").replaceAll('"', "").replaceAll('@', ""); + const reason = args.slice(closingQuoteIndex + 1).join(" ") ?? "No reason provided"; + + if(!canFindPlayer(playerName)) return player.sendMessage(`§6[§eSafeGuard§6]§f Player §e${playerName}§f was not found`); + + const reportedPlayer = getPlayerByName(playerName); + + reportPlayer(reportedPlayer,reason); + } else { + const playerName = args[1].replaceAll('"', "").replaceAll('@', ""); + const reportedPlayer = getPlayerByName(playerName); + const reason = args.slice(2).join(" ") ?? "No reason provided"; + + reportPlayer(reportedPlayer,reason); + } + + function reportPlayer(reportedPlayer,reason){ + if(!reportedPlayer.reports) reportedPlayer.reports = []; + + if(reportedPlayer.reports.includes(player.id)) return player.sendMessage(`§6[§eSafeGuard§6]§f You have already reported this player!`); + if(reportedPlayer.name == player.name) return player.sendMessage(`§6[§eSafeGuard§6]§f You cannot report yourself!`); + if(reportedPlayer.hasTag("admin")) return player.sendMessage(`§6[§eSafeGuard§6]§f You cannot report admins.`); + reportedPlayer.reports.push(player.id); + + player.sendMessage(`§6[§eSafeGuard§6]§f Sent your report to all online admins!`); + + sendMessageToAllAdmins(`§6[§eSafeGuard§6]§e ${player.name}§r has reported §e${reportedPlayer.name}§r for §e${reason}§r`); + } + + } +}) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/summon_npc.js b/Safeguard anti-cheat B/scripts/command/src/summon_npc.js index 1d52669..4c4d8bb 100644 --- a/Safeguard anti-cheat B/scripts/command/src/summon_npc.js +++ b/Safeguard anti-cheat B/scripts/command/src/summon_npc.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"summon_npc", + description:"Summons a NPC at your location", run: (data) => { data.player.runCommandAsync("function admin_cmds/summon_npc"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/unban.js b/Safeguard anti-cheat B/scripts/command/src/unban.js index 8ec5f84..9b88b57 100644 --- a/Safeguard anti-cheat B/scripts/command/src/unban.js +++ b/Safeguard anti-cheat B/scripts/command/src/unban.js @@ -3,6 +3,7 @@ import { newCommand } from '../handle'; newCommand({ name:"unban", + description:" Unbans a player", run: (data) => { const setNameUnban = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); unban(data.player,setNameUnban); diff --git a/Safeguard anti-cheat B/scripts/command/src/unmute.js b/Safeguard anti-cheat B/scripts/command/src/unmute.js index 0032cad..bfdd886 100644 --- a/Safeguard anti-cheat B/scripts/command/src/unmute.js +++ b/Safeguard anti-cheat B/scripts/command/src/unmute.js @@ -1,8 +1,9 @@ -import { canFindPlayer, getPlayerByName } from '../../assets/util'; +import { canFindPlayer, getPlayerByName, sendMessageToAllAdmins } from '../../assets/util'; import { newCommand } from '../handle'; newCommand({ name:"unmute", + description: " Unmutes a muted player", run: (data) => { let player = data.player; const setNameUnmute = data.args.slice(1).join(" ").replaceAll('"', "").replaceAll('@', ""); @@ -16,7 +17,8 @@ newCommand({ } 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"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bunmuted§l§5 ${setNameUnmute}! §r`,true); + //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"}]}`); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/command/src/vanish.js b/Safeguard anti-cheat B/scripts/command/src/vanish.js index ebc7891..989999d 100644 --- a/Safeguard anti-cheat B/scripts/command/src/vanish.js +++ b/Safeguard anti-cheat B/scripts/command/src/vanish.js @@ -2,6 +2,7 @@ import { newCommand } from '../handle'; newCommand({ name:"vanish", + description:"Toggles vanish mode", run: (data) => { data.player.runCommandAsync("function admin_cmds/vanish"); } diff --git a/Safeguard anti-cheat B/scripts/command/src/worldborder.js b/Safeguard anti-cheat B/scripts/command/src/worldborder.js index 591ad95..085784f 100644 --- a/Safeguard anti-cheat B/scripts/command/src/worldborder.js +++ b/Safeguard anti-cheat B/scripts/command/src/worldborder.js @@ -1,4 +1,4 @@ -import { scoreboardAction } from '../../assets/util'; +import { scoreboardAction, sendMessageToAllAdmins } from '../../assets/util'; import config from '../../config'; import { newCommand } from '../handle'; import * as Minecraft from "@minecraft/server"; @@ -7,6 +7,7 @@ const world = Minecraft.world; newCommand({ name:"worldborder", + description: " Get or set the worldborder", run: (data) => { let player = data.player; let oldBorder = null; @@ -22,7 +23,10 @@ newCommand({ 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"}]}`); + world.worldBorder = null; + + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bremoved the world border! §r`,true); + //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; } @@ -34,8 +38,10 @@ newCommand({ if (objective.id.startsWith("safeguard:worldBorder:")) scoreboardAction(objective.id, "remove"); }); scoreboardAction(`safeguard:worldBorder:${border}`, "add"); + world.worldBorder = border; 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"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard Notify§6]§5§l ${player.name} §bset the world border to§5 ${border}§b blocks! §r`,true); + //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"}]}`); } }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/scripts/config.js b/Safeguard anti-cheat B/scripts/config.js index e7fbce3..b535236 100644 --- a/Safeguard anti-cheat B/scripts/config.js +++ b/Safeguard anti-cheat B/scripts/config.js @@ -1,18 +1,38 @@ //Edit items in this file if you want customization: export default { - //dev only don't touch - "debug": false, - + "other":{ + //dev only don't touch + "debug": false, + //how long a person is banned for when reaching warnings too fast in minutes + "warningsTooFastPunishmentTime": 5, + }, "combat": { "autoclicker":{ //if player cps go over this number, player gets flagged for autoclicker - "maxCps": 12 + "maxCps": 20 }, "killaura":{ //if player attacks this or many more number of entities in a single tick, gets flagged for killaura "maxHitEntities": 2 + }, + "combatLogging":{ + //how many milliseconds player will stay in combat after last damage they received from a player + //this is set to 15 seconds by default + "timeToStayInCombat": 15000, + //punishment for when player is detected combat logging + //0 - send alert to everyone, do nothing + //1 - kill player + //2 - clear inventory + //3 - ban player (duration specified in "punishmentTime") + "punishmentType": 3, + //enabling this will send an alert when player combat logs to everyone in game + "alwaysSendAlert": false, + //valid input: + "punishmentTime": "15 minute", + //if admins don't get affected by anti combatlogging + "adminsBypass": true } }, "item":{ @@ -31,8 +51,9 @@ export default { }, "movement":{ "fly":{ - //if the fall distance goes over this number player gets flagged for flying, increase to -11 or above if you are getting a lot of false positives - "minFallDistance": -10 + //the anticheat checks for sudden changes in player velocity + //for example if it suddenly jumps from -4 to 6, the threshold determines how high that difference can be + "maxYVelocityThreshold": 8 } }, "world":{ @@ -40,12 +61,16 @@ export default { //if player breaks this many or more blocks in a single tick, gets flagged for nuker "maxBlocks": 3, //checks if admin players are using nuker (good for anti op abuse) - "checkAdmins": true + "checkAdmins": true, + //blocks that are excluded from nuker check because they are instant broken + "blockExceptions": ["minecraft:sea_pickle","minecraft:sugar_cane","minecraft:deadbush","minecraft:horn_coral","minecraft:coral_fan","minecraft:coral_fan_dead","minecraft:brain_coral","minecraft:bubble_coral","minecraft:dead_brain_coral","minecraft:dead_bubble_coral","minecraft:dead_fire_coral","minecraft:dead_horn_coral","minecraft:dead_tube_coral","minecraft:fire_coral","minecraft:tube_coral","minecraft:red_flower","minecraft:yellow_flower","minecraft:grass","minecraft:seagrass","minecraft:netherrack","minecraft:torchflower","minecraft:sapling","minecraft:cherry_sapling","minecraft:tallgrass","minecraft:double_plant","minecraft:nether_sprouts"] }, "worldborder":{ //the minimum border size required, this is used so if a possible admin abuse or force op occurs hackers don't create a border of a size 1 block or less which //will teleport all the players up in the air constantly - "minBorderDistance": 500 + "minBorderDistance": 500, + //if admins can go beyond world border + "adminsBypassBorder": true, } }, "chat":{ diff --git a/Safeguard anti-cheat B/scripts/index.js b/Safeguard anti-cheat B/scripts/index.js index a6156a6..7a9d865 100644 --- a/Safeguard anti-cheat B/scripts/index.js +++ b/Safeguard anti-cheat B/scripts/index.js @@ -4,17 +4,33 @@ import { ActionFormData } from '@minecraft/server-ui'; import * as config from "./config.js"; import * as ui from "./assets/ui.js"; -import { scoreboardAction, formatMilliseconds } from "./assets/util.js"; +import { scoreboardAction, formatMilliseconds, teleportToGround, sendMessageToAllAdmins, millisecondTime, parsePunishmentTime } from "./assets/util.js"; import { globalBanList } from './assets/globalBanList.js'; import { commandHandler } from './command/handle.js'; import "./command/importer.js"; -console.warn("Script Loaded"); +console.warn("[SafeGuard] Script Loaded"); const world = Minecraft.world; +world.afterEvents.playerPlaceBlock.subscribe((data) => { + const {player,block} = data; + const playerRotation = player.getRotation(); + + if(playerRotation.x == 60 || playerRotation.x == 90){ + if(!player.scaffoldChecks) player.scaffoldChecks = 0; + + const antiScaffoldOn = (world.scoreboard.getObjective('safeguard:scaffold_check') === undefined) ? false : true; + if(!antiScaffoldOn || player.hasTag("admin")) return; + block.setType("minecraft:air"); + if(player.scaffoldChecks === 1 || player.scaffoldChecks % 15 === 0) sendMessageToAllAdmins(`§6[§eSafeGuard Beta§6]§c ${player.name}§4 was detected using scaffold!`); + player.scaffoldChecks++ + player.runCommandAsync(`scoreboard players add @s "safeguard:scaffold_check" 1`); + } +}) + world.beforeEvents.itemUseOn.subscribe((data) => { const player = data.source; let antiItemsOn = (world.scoreboard.getObjective('item_on') === undefined) ? false : true; @@ -75,12 +91,6 @@ world.beforeEvents.chatSend.subscribe((data) => { - if (!player.hasTag("admin")) { - player.sendMessage('§6[§eSafeGuard§6]§r§c You need admin tag to run this!'); - data.cancel = true; - return; - } - commandHandler(data); }) @@ -101,12 +111,14 @@ world.afterEvents.playerBreakBlock.subscribe((data) => { block.setPermutation(data.brokenBlockPermutation); world.sendMessage(`§6[§eSafeGuard§6]§r§c§l §r§c${player.name}§4 Attempted to break §c${blockId}`) } - - - player.blocksBroken++ - if(player.blocksBroken > config.default.world.nuker.maxBlocks && antiNuker){ - if(player.hasTag("admin") && !config.default.world.nuker.checkAdmins) return; - player.runCommandAsync(`scoreboard players add @s "safeguard:nuker_check" 1`) + //check if the block id is in nuker block excpetions to prevent false positives + if(!config.default.world.nuker.blockExceptions.includes(blockId) && player.getEffect("haste") == undefined){ + player.blocksBroken++ + } + + if(player.blocksBroken > config.default.world.nuker.maxBlocks && antiNuker){ + if(player.hasTag("admin") && !config.default.world.nuker.checkAdmins) return; + player.runCommand(`scoreboard players add @s "safeguard:nuker_check" 1`); // kill the items dropped items const items = dimension.getEntities({ location:{x: block.location.x, y: block.location.y, z: block.location.z}, @@ -129,13 +141,15 @@ world.afterEvents.playerBreakBlock.subscribe((data) => { world.sendMessage(`§6[§eSafeGuard§6]§r§c§l ${player.name} §r§4Was detected using nuker by breaking §l§c${player.blocksBroken}§r§4 blocks in one tick!§r`); } return; - } + } if(blockId == "minecraft:diamond_ore" || blockId =="minecraft:deepslate_diamond_ore"){ if(!diamondAlertOn) return - player.runCommandAsync(`tellraw @a[tag=admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§5§l "},{"text":"§r§e${player.name}§f mined x1 §ediamond ore§r"}]}`); + //player.runCommandAsync(`tellraw @a[tag=admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§5§l "},{"text":"§r§e${player.name}§f mined x1 §ediamond ore§r"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard§6]§5§l §r§e${player.name}§f mined x1 §ediamond ore§r`); } if(blockId == "minecraft:ancient_debris" && netheriteAlertOn){ - player.runCommandAsync(`tellraw @a[tag=admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§5§l "},{"text":"§r§e${player.name}§f mined x1 §enetherite ore§r"}]}`); + sendMessageToAllAdmins(`§6[§eSafeGuard§6]§5§l §r§e${player.name}§f mined x1 §enetherite ore§r`); + //player.runCommandAsync(`tellraw @a[tag=admin] {"rawtext":[{"text":"§6[§eSafeGuard§6]§5§l "},{"text":"§r§e${player.name}§f mined x1 §enetherite ore§r"}]}`); } }) @@ -144,6 +158,10 @@ Minecraft.system.runInterval(() => { if(world.scoreboard.getObjective("safeguard:gametest_on") == undefined){ world.scoreboard.addObjective("safeguard:gametest_on","Gamtetest Is On"); } + //check settings status + const antiItemsOn = (world.scoreboard.getObjective('item_on') === undefined) ? false : true; + const autoModOn = (world.scoreboard.getObjective('auto_mod_on') === undefined) ? false : true; + const antiAutoClicker = (world.scoreboard.getObjective('safeguard:cps_check') === undefined) ? false : true; [...world.getPlayers()].forEach(player => { const plrName = player.name; const inv = player.getComponent("inventory").container; @@ -152,12 +170,27 @@ Minecraft.system.runInterval(() => { player.blocksBroken = 0; player.hitEntities = []; - //check settings status - const antiItemsOn = (world.scoreboard.getObjective('item_on') === undefined) ? false : true; - const autoModOn = (world.scoreboard.getObjective('auto_mod_on') === undefined) ? false : true; - const antiAutoClicker = (world.scoreboard.getObjective('safeguard:cps_check') === undefined) ? false : true; - const antiFly = (world.scoreboard.getObjective('safeguard:fly_check') === undefined) ? false : true; - + betaFeatures(player); + + //check if player received too many warnings + if(player.hasTag("safeguard:reachingWarningsTooFast")){ + player.removeTag("safeguard:reachingWarningsTooFast"); + player.addTag("safeguard:Ban"); + const now = Date.now(); + const punishmentTime = millisecondTime.minute * config.default.other.warningsTooFastPunishmentTime; + const unbanTime = now + punishmentTime + player.addTag(`safeguardBanInfo**false**${unbanTime}**SafeGuard AutoMod**Reaching warnings too fast`); + player.runCommandAsync(`kick "${player.name}" §r§6[§eSafeGuard§6]§r You are temporarily banned for reaching warnings too fast.`); + } + //check if player's combat log time ran out + if(player.combatLogTimer){ + const now = Date.now(); + if(now - player.combatLogTimer > config.default.combat.combatLogging.timeToStayInCombat){ + player.combatLogTimer = null; + player.removeTag("safeguard:isInCombat"); + player.sendMessage(`§r§6[§eSafeGuard§6]§r You are no longer in combat.`); + } + } if(velocity.x > 0 || velocity.z > 0){ if(!player.isFalling) player.addTag("safeguard:moving"); } @@ -237,38 +270,105 @@ Minecraft.system.runInterval(() => { if(player.dimension.id == "minecraft:the_end" && world.scoreboard.getObjective('end_lock')){ player.kill(); } + - world.scoreboard.getObjectives().forEach((objective) => { - if(objective.id.startsWith("safeguard:worldBorder:")){ - let {x,y,z} = player.location; - const border = objective.id.split("safeguard:worldBorder:")[1]; - if(x > border || y > border || z > border || x < -border || y < -border || z < -border ) { - player.sendMessage(`§6[§eSafeGuard§6]§r You reached the border of §e${border}§f blocks!`); - player.teleport({x: 0, y: 325, z: 0},{dimension: player.dimension, rotation: {x: 0, y: 0}, keepVelocity: false}); - player.addEffect("slow_falling", 1200, { amplifier: 1, showParticles: false }) - } + if(world.worldBorder){ + let { x, y, z } = player.location; + const border = world.worldBorder; + if(x > border || y > border || z > border || x < -border || y < -border || z < -border ) { + if(player.hasTag("admin") && config.default.world.worldborder.adminsBypassBorder) return; + + player.sendMessage(`§6[§eSafeGuard§6]§r You reached the border of §e${border}§f blocks!`); + const currentLocation = player.location; + const offsetX = currentLocation.x >= 0 ? -1 : 1; + const offsetZ = currentLocation.z >= 0 ? -1 : 1; + //const offsetY = currentLocation.y >= 0 ? -1 : 1; + + player.tryTeleport({ + x: currentLocation.x + offsetX, + y: currentLocation.y, + z: currentLocation.z + offsetZ, + }, { + checkForBlocks: false, + }); } - }); - - //anti fly idk - let debugMenu = { - rotation: player.getViewDirection() } - //world.sendMessage(`-------------\n§e${JSON.stringify(velocity, null, 2)}§r\n-------------`); - if(config.default.debug) world.sendMessage(`§e${JSON.stringify(debugMenu, null, 2)}§r\n-------------`); + + + + //removed because its bad //check if fall distance is in negatives (fly detection) - if(player.fallDistance < config.default.movement.fly.minFallDistance && antiFly && !player.hasTag("gamemode:creative") && !player.hasTag("admin") && !player.hasTag("safeguard:hasRiptide") && !player.isGliding && !player.isClimbing){ + /*if(player.fallDistance < config.default.movement.fly.minFallDistance && antiFly && !player.hasTag("gamemode:creative") && !player.hasTag("admin") && !player.hasTag("safeguard:hasRiptide") && !player.isGliding && !player.isClimbing){ world.sendMessage(`§6[§eSafeGuard§6] §r§l§c${player.name}§4 was detected flying!`); player.runCommandAsync(`scoreboard players add @s "safeguard:fly_check" 1`) - player.tryTeleport({x: player.location.x, y: player.location.y + player.fallDistance, z: player.location.z},{checkForBlocks: true,dimension: player.dimension, rotation: {x:0,y:0}, keepVelocity: false}); - } + }*/ }) }); +function betaFeatures(player){ + + if(player.hasTag("admin")) return; + const playerVelocity = player.getVelocity(); + const playerHealth = player.getComponent("minecraft:health"); + const playerMode = player.getGameMode(); + //anti fly idk + let debugMenu = { + velocity: playerVelocity, + } + //world.sendMessage(`-------------\n§e${JSON.stringify(velocity, null, 2)}§r\n-------------`); + //if(config.default.debug) console.warn(`§e${JSON.stringify(debugMenu, null, 2)}§r\n-------------`); + + + + const invalidVelocityCheckOn = (world.scoreboard.getObjective('safeguard:velocity_check') === undefined) ? false : true; + + + if(playerVelocity.y < -3.919921875 && invalidVelocityCheckOn){ + //while testing for a fly detection, I noticed that the terminal velocity for falling on y coordinate is -3.919921875 + //this seems to be a a better detection fly because when flying the velocity sometimes tends to set the velocity below that number which I assume is impossible + //this also sometimes detects other movement cheats + sendMessageToAllAdmins(`§6[§eSafeGuard Beta§6] §c${player.name}§4 reached invalid y velocity: §c${playerVelocity.y.toFixed(3)}§4`); + teleportToGround(player); + player.runCommandAsync(`scoreboard players add @s "safeguard:velocity_check" 1`); + //player.tryTeleport({x:player.location.x + playerVelocity.x, y:player.location.y + playerVelocity.y,z:player.location.z + playerVelocity.z},{keepVelocity:false}) + } + if(playerVelocity.y === 0 && !player.isOnGround && playerHealth.currentValue > 0 && !player.isFlying && !player.isSwimming && playerMode !== Minecraft.GameMode.creative && !player.isJumping){ + //even though this seems like a great check to detect NoFall it tends to false positive on low tps servers + //until I figure out how to improve this, this is gonna stay here with no handling + //world.sendMessage(`§6[§eSafeGuard Beta§6] §4Invalid properties: §c${player.name}§4 is not grounded and has no y velocity`); + } +} + + +Minecraft.system.runInterval(() => { + [...world.getPlayers()].forEach(player => { + if(player.hasTag("admin")) return; + const antiFly = (world.scoreboard.getObjective('safeguard:fly_check') === undefined) ? false : true; + const maxYVelocityThreshold = config.default.movement.fly.maxYVelocityThreshold; + const playerVelocity = player.getVelocity(); + const currentYVelocity = playerVelocity.y; + + if(!player.previousYVelocity) player.previousYVelocity = 0; + + const velocityDifference = Math.round(currentYVelocity - player.previousYVelocity); + + + if (velocityDifference > maxYVelocityThreshold && !player.isGliding && antiFly && player.previousYVelocity !== 0 && currentYVelocity !== 0) { + teleportToGround(player); + sendMessageToAllAdmins(`§6[§eSafeGuard Beta§6] §c${player.name}§4 reached a high velocity difference (§c${velocityDifference}§4), potentially indicating fly behavior.`); + player.runCommandAsync(`scoreboard players add @s "safeguard:fly_check" 1`); + //world.sendMessage(`DIFF[§e${velocityDifference}§r] PREV[§e${previousYVelocity}§r] CURR[§e${currentYVelocity}§r]`); + } + + player.previousYVelocity = currentYVelocity; + }) +}, 10); + + //combat cheats detection and shi world.afterEvents.entityHitEntity.subscribe(async (data) => { const player = data.damagingEntity; @@ -298,7 +398,61 @@ world.afterEvents.entityHitEntity.subscribe(async (data) => { world.afterEvents.playerSpawn.subscribe((data) => { const player = data.player; - + if(data.initialSpawn){ + if(!world.recievedInitialBorder){ + //get intial world border + world.scoreboard.getObjectives().forEach((objective) => { + const objectiveId = objective.id; + if (objectiveId.startsWith("safeguard:worldBorder:")){ + console.warn(`[SafeGuard] Recieved intial world border: ${objectiveId}`) + world.worldBorder = parseInt(objectiveId.split("safeguard:worldBorder:")[1]); + } + }); + if(!world.worldBorder){ + console.warn("[SafeGuard] No world border detected") + world.worldBorder = null; + } + world.recievedInitialBorder = true; + } + if(player.hasTag("safeguard:isInCombat")){ + player.removeTag("safeguard:isInCombat"); + if(config.default.combat.combatLogging.alwaysSendAlert) world.sendMessage(`§r§6[§eSafeGuard§6]§e ${player.name}§r Was detected combat logging!`); + switch(config.default.combat.combatLogging.punishmentType){ + case 0: + //check for alwaysSendAlert option to prevent spam + if(!config.default.combat.combatLogging.alwaysSendAlert) world.sendMessage(`§r§6[§eSafeGuard§6]§e ${player.name}§r Was detected combat logging!`); + break; + case 1: + player.sendMessage(`§r§6[§eSafeGuard§6]§r You were killed for combat logging`); + player.kill(); + break; + case 2: + player.sendMessage(`§r§6[§eSafeGuard§6]§r Your inventory was cleared for combat logging`); + const inv = player.getComponent("inventory").container; + inv.clearAll(); + break; + case 3: + const punishment = config.default.combat.combatLogging.punishmentTime.split(" "); + const punishmentTime = parsePunishmentTime(punishment); + + if (!punishmentTime) { + console.error(`§4[SafeGuard] Invalid punishment time format in config.`); + break; + } + + const now = Date.now(); + const unbanTime = now + punishmentTime; + + player.addTag("safeguard:Ban"); + player.addTag(`safeguardBanInfo**false**${unbanTime}**SafeGuard AntiCheat**Combat Logging`); + player.runCommandAsync(`kick "${player.name}" §r§6[§eSafeGuard§6]§r You were temporarily banned for combat logging.`); + break; + default: + console.error(`§4[SafeGuard] Unknown punishment type(${config.default.combat.combatLogging.punishmentType}) was entered, no punishment will be given`); + break; + } + } + } //if(!player.hasTag("Ban") || !player.hasTag("safeguard:Ban")) return; if(globalBanList.includes(player.name)) return player.runCommandAsync(`kick "${player.name}" §r§6[§eSafeGuard§6]§r §4Your name was found in the SafeGuard global ban list.`) @@ -311,7 +465,7 @@ world.afterEvents.playerSpawn.subscribe((data) => { player.removeTag("safeguard:Ban"); player.removeTag("ac_ban"); player.removeTag("ban"); - player.runCommandAsync("scoreboard players reset @s ac_banned"); + player.runCommand("scoreboard players reset @s ac_banned"); player.removeTag("Ban"); player.sendMessage(`§6[§eSafeGuard§6]§r §aYou were unbanned!`); player.teleport({x: player.location.x, y: 325, z: player.location.z},{dimension: player.dimension, rotation: {x: 0, y: 0}, keepVelocity: false}); @@ -401,8 +555,9 @@ world.afterEvents.entityHurt.subscribe((data) => { const hp = player.getComponent("health").currentValue; if(hp <= 0) { - - const inv = player.getComponent("inventory").container; + player.combatLogTimer = null; + if(player.hasTag("safeguard:isInCombat")) player.removeTag("safeguard:isInCombat"); + player.runCommandAsync("function assets/death_effect"); //death coords @@ -412,4 +567,48 @@ world.afterEvents.entityHurt.subscribe((data) => { player.sendMessage(`§6[§eSafeGuard§6]§r §eYou died at ${Math.round(x)}, ${Math.round(y)}, ${Math.round(z)} (in ${player.dimension.id.replace("minecraft:","")})`); } } + if (data.damageSource.damagingEntity) { + const damager = data.damageSource.damagingEntity; + if (damager.typeId !== "minecraft:player") return; + + const adminsBypassCombatLogging = config.default.combat.combatLogging.adminsBypass; + const now = Date.now(); + const antiCombatLogEnabled = (world.scoreboard.getObjective('safeguard:anti_combatlog') === undefined) ? false : true; + + if (!player.hasTag("safeguard:isInCombat") && antiCombatLogEnabled) { + if (player.hasTag("admin") && adminsBypassCombatLogging) { + player.combatLogTimer = 0; + } else { + player.addTag("safeguard:isInCombat"); + + if (!player.combatLogWarningDisplayed) { + player.sendMessage(`§r§6[§eSafeGuard§6]§r You are now in combat, leaving during combat will result in a punishment.`); + player.combatLogWarningDisplayed = true; + } else { + player.sendMessage(`§r§6[§eSafeGuard§6]§r You are now in combat`); + } + } + } + + if (!damager.hasTag("safeguard:isInCombat") && antiCombatLogEnabled) { + if (damager.hasTag("admin") && adminsBypassCombatLogging) { + damager.combatLogTimer = 0; + } else { + damager.addTag("safeguard:isInCombat"); + + if (!damager.combatLogWarningDisplayed) { + damager.sendMessage(`§r§6[§eSafeGuard§6]§r You are now in combat, leaving during combat will result in a punishment.`); + damager.combatLogWarningDisplayed = true; + } else { + damager.sendMessage(`§r§6[§eSafeGuard§6]§r You are now in combat.`); + } + } + } + + if(antiCombatLogEnabled){ + damager.combatLogTimer = now; + player.combatLogTimer = now; + } + } + }) \ No newline at end of file diff --git a/Safeguard anti-cheat B/structures/safeguard/spawnPlayer.mcstructure b/Safeguard anti-cheat B/structures/safeguard/spawnPlayer.mcstructure new file mode 100644 index 0000000000000000000000000000000000000000..155a5ce386e84dec204d1939d506f277a3691ad5 GIT binary patch literal 272 zcmYL^%?biB41}Wp1t@I9(|D#ce4`QZI?Ey;Jb^ai$8(FgbXuZ9e`Ow6H|xc zZ=Gyl3sW8s zZUH^EBtoicYH(=f7xlfAl;sQpcC>