diff --git a/Safeguard anti-cheat B/functions/credit.mcfunction b/Safeguard anti-cheat B/functions/credit.mcfunction index 7d9bf66..c34e6a6 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.9"}]} \ No newline at end of file +tellraw @s {"rawtext":[{"text":"Version 1.9.1"}]} \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction b/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction index 13402b5..346b8b0 100644 --- a/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction +++ b/Safeguard anti-cheat B/functions/punishment/warning/warning.mcfunction @@ -14,17 +14,8 @@ execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:cps_c execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:fly_check execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:nuker_check execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:killaura_check +execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:velocity_check +execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:scaffold_check +execute as @a[tag=warning_reset] run scoreboard players reset @s safeguard:anti_combatlog execute as @a[tag=warning_reset] run tellraw @s {"rawtext": [{"text": "§6[§eSafeGuard§6]§r§l§c "},{"text": "§aWarnings reset by admin!§r"}]} tag @a[tag=warning_reset] remove warning_reset -#other warnings -execute as @a[scores={safeguard:cps_check=5,auto_mod_on=0}] run tag @s add softban_five -execute as @a[scores={safeguard:cps_check=5,auto_mod_on=0}] run scoreboard players add @s safeguard:cps_check 1 - -execute as @a[scores={safeguard:fly_check=5,auto_mod_on=0}] run tag @s add softban_five -execute as @a[scores={safeguard:fly_check=5,auto_mod_on=0}] run scoreboard players add @s safeguard:fly_check 1 - -execute as @a[scores={safeguard:nuker_check=5,auto_mod_on=0}] run tag @s add softban_five -execute as @a[scores={safeguard:nuker_check=5,auto_mod_on=0}] run scoreboard players add @s safeguard:nuker_check 1 - -execute as @a[scores={safeguard:killaura_check=5,auto_mod_on=0}] run tag @s add softban_five -execute as @a[scores={safeguard:killaura_check=5,auto_mod_on=0}] run scoreboard players add @s safeguard:killaura_check 1 \ No newline at end of file diff --git a/Safeguard anti-cheat B/functions/settings/anti_fly.mcfunction b/Safeguard anti-cheat B/functions/settings/anti_fly.mcfunction deleted file mode 100644 index 06098e8..0000000 --- a/Safeguard anti-cheat B/functions/settings/anti_fly.mcfunction +++ /dev/null @@ -1,14 +0,0 @@ -#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/manifest.json b/Safeguard anti-cheat B/manifest.json index 6e3c8dd..90e77d4 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.9\nBeta API §cREQUIRED", + "description": "§l§fMade by §eBlazer#9677 §fV1.9.1\nBeta API §cREQUIRED", "uuid": "81b13565-181a-42ee-abd9-a7bd3cb2dba4", "min_engine_version": [ 1, @@ -12,7 +12,7 @@ "version": [ 1, 9, - 0 + 1 ] }, "modules": [ @@ -42,7 +42,7 @@ "dependencies": [ { "module_name": "@minecraft/server", - "version": "1.10.0-beta" + "version": "1.11.0-beta" }, { "module_name": "@minecraft/server-gametest", diff --git a/Safeguard anti-cheat B/scripts/command/src/report.js b/Safeguard anti-cheat B/scripts/command/src/report.js index bee8288..56e7bc7 100644 --- a/Safeguard anti-cheat B/scripts/command/src/report.js +++ b/Safeguard anti-cheat B/scripts/command/src/report.js @@ -1,5 +1,7 @@ import { canFindPlayer, getPlayerByName, sendMessageToAllAdmins } from '../../assets/util'; import {newCommand} from '../handle'; +import * as config from "../../config"; +import { world } from '@minecraft/server'; newCommand({ name: "report", @@ -41,12 +43,27 @@ newCommand({ } function reportPlayer(reportedPlayer,reason){ - if(!reportedPlayer.reports) reportedPlayer.reports = []; + let reportedPlayerReportsProperty = reportedPlayer.getDynamicProperty("safeguard:reports"); + if(reportedPlayerReportsProperty === undefined){ + reportedPlayer.setDynamicProperty("safeguard:reports",""); + reportedPlayerReportsProperty = reportedPlayer.getDynamicProperty("safeguard: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!`); + const tempProperty = reportedPlayerReportsProperty.split(","); + + + + if(player.hasTag("admin")){ + console.warn(tempProperty) + player.sendMessage(`§6[§eSafeGuard§6]§f This player has been reported §e${tempProperty.length - 1}§r times.`); + return; + } + + if(tempProperty.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); + tempProperty.push(player.id); + reportedPlayer.setDynamicProperty("safeguard:reports",tempProperty.toString()); player.sendMessage(`§6[§eSafeGuard§6]§f Sent your report to all online admins!`); diff --git a/Safeguard anti-cheat B/scripts/config.js b/Safeguard anti-cheat B/scripts/config.js index b535236..4c0095e 100644 --- a/Safeguard anti-cheat B/scripts/config.js +++ b/Safeguard anti-cheat B/scripts/config.js @@ -77,6 +77,10 @@ export default { //chat command prefix "prefix": "!", "spammer":{ + //maximum amount characters the message can have before it's considered spam + "maxMessageCharLimit": 512, + //maximum amount of words the message can have before it's considered spam + "maxMessageWordLimit": 512, //minimum time between messages in milliseconds "minTime": 1500, //if a message starts with this word/symbol/letter or whatever you enter it won't be flagged for spam diff --git a/Safeguard anti-cheat B/scripts/index.js b/Safeguard anti-cheat B/scripts/index.js index 7a9d865..634d67e 100644 --- a/Safeguard anti-cheat B/scripts/index.js +++ b/Safeguard anti-cheat B/scripts/index.js @@ -57,25 +57,39 @@ world.beforeEvents.chatSend.subscribe((data) => { const prefix = config.default.chat.prefix; const whitelistedPrefixes = config.default.chat.spammer.whitelistedPrefixes; let checkSpam = false; + const isAdmin = player.hasTag("admin"); const antiSpam = (world.scoreboard.getObjective('safeguard:spammer_protection') === undefined) ? false : true; //message spam protection - if(message == player.lastMessage && !player.hasTag("admin") && antiSpam){ + if(message == player.lastMessage && !isAdmin && antiSpam){ data.cancel = true; player.sendMessage(`§6[§eSafeGuard§6]§r§c Please don't send repeating messages!`); return; } - else if(Date.now() - player.lastMessageDate <= config.default.chat.spammer.minTime && !player.hasTag("admin") && antiSpam){ + else if(Date.now() - player.lastMessageDate <= config.default.chat.spammer.minTime && !isAdmin && antiSpam){ data.cancel = true; player.sendMessage(`§6[§eSafeGuard§6]§r§c You're sending messages too quickly!`); return; } + + else if(message.length > config.default.chat.spammer.maxMessageCharLimit && !isAdmin && antiSpam){ + data.cancel = true; + player.sendMessage(`§6[§eSafeGuard§6]§r§c Sorry! Your message has too many characters!`); + return; + } + else if(message.split(" ").length > config.default.chat.spammer.maxMessageWordLimit && !isAdmin && antiSpam){ + data.cancel = true; + player.sendMessage(`§6[§eSafeGuard§6]§r§c Please keep your message below ${config.default.chat.spammer.maxMessageWordLimit} words!`); + return; + } + whitelistedPrefixes.forEach(wPrefix => { if(message.startsWith(wPrefix)){ checkSpam = true; } }) + if(!checkSpam){ player.lastMessage = message; player.lastMessageDate = Date.now(); @@ -166,11 +180,12 @@ Minecraft.system.runInterval(() => { const plrName = player.name; const inv = player.getComponent("inventory").container; const velocity = player.getVelocity(); + const isAdmin = player.hasTag("admin"); player.blocksBroken = 0; player.hitEntities = []; - betaFeatures(player); + betaFeatures(player,velocity); //check if player received too many warnings if(player.hasTag("safeguard:reachingWarningsTooFast")){ @@ -208,7 +223,7 @@ Minecraft.system.runInterval(() => { } else if(item.typeId !== "minecraft:trident") player.removeTag("safeguard:hasRiptide"); - if (player.hasTag('admin')) return; + if (isAdmin) return; else{ //illegal name check if (itemName.length > config.default.item.anti_items.maxItemNameLength && antiItemsOn) { @@ -248,7 +263,7 @@ Minecraft.system.runInterval(() => { const finalcps = world.scoreboard.getObjective("safeguard:finalcps").getScore(player.scoreboardIdentity); - if(finalcps > config.default.combat.autoclicker.maxCps && !player.hasTag("admin") && antiAutoClicker){ + if(finalcps > config.default.combat.autoclicker.maxCps && isAdmin && antiAutoClicker){ world.sendMessage(`§6[§eSafeGuard§6]§r §c§l${player.name}§r§4 was detected using autoclicker with a cps of §l§c${finalcps}`); player.runCommandAsync(`scoreboard players add @s "safeguard:cps_check" 1`) player.addEffect("weakness", 40, { amplifier: 255, showParticles: false }) @@ -276,7 +291,7 @@ Minecraft.system.runInterval(() => { 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; + if(isAdmin && 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; @@ -309,10 +324,10 @@ Minecraft.system.runInterval(() => { }); -function betaFeatures(player){ +function betaFeatures(player,velocity){ if(player.hasTag("admin")) return; - const playerVelocity = player.getVelocity(); + const playerVelocity = velocity; const playerHealth = player.getComponent("minecraft:health"); const playerMode = player.getGameMode(); //anti fly idk