diff --git a/src/commands/debug_commands/listitems.ts b/src/commands/debug_commands/listitems.ts index eef9313..3c7bfbd 100644 --- a/src/commands/debug_commands/listitems.ts +++ b/src/commands/debug_commands/listitems.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, ItemStack, Player } from "@minecraft/server"; import { MinecraftItemTypes } from "../../node_modules/@minecraft/vanilla-data/lib/index"; import config from "../../data/config.js"; -import { crypto, getPrefix, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager"; function listItems(player: Player, prefix: string) { let commandStatus: string; @@ -43,10 +44,10 @@ export function listitems(message: ChatSendAfterEvent, args: string[]) { const key = config.encryption.password ? config.encryption.password : player.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); // Make sure the user has permissions to run the command - if (hash === undefined || encode !== hash) { - return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者権限がないと実行できません!!`); + if (!encode || hash === undefined || encode !== hash) { + return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者しか実行できません`); } // Check for custom prefix diff --git a/src/commands/moderation/deop.ts b/src/commands/moderation/deop.ts index 0609c82..b7a4b89 100644 --- a/src/commands/moderation/deop.ts +++ b/src/commands/moderation/deop.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; function deopHelp(player: Player, prefix: string) { let commandStatus: string; @@ -42,7 +43,7 @@ export function deop(message: ChatSendAfterEvent, args: string[]) { // Make sure the user has permissions to run the command if (uniqueId !== player.name) { - return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者権限がないと実行できません!!`); + return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者しか実行できません`); } // Check for custom prefix @@ -73,7 +74,7 @@ export function deop(message: ChatSendAfterEvent, args: string[]) { } if (!member) { - return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f プレイヤーが存在しない又はオフラインです`); + return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f ユーザーが見つかりません`); } // Check for hash/salt and validate password from member @@ -85,7 +86,7 @@ export function deop(message: ChatSendAfterEvent, args: string[]) { const memberKey = config.encryption.password ? config.encryption.password : member.id; // Generate the hash - memberEncode = crypto(memberSalt, memberKey); + memberEncode = EncryptionManager.hashWithSalt(memberSalt as string, memberKey); } catch (error) {} if (memberHash !== undefined && memberHash === memberEncode) { diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index 99b53ae..455b1db 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; function lockdownHelp(player: Player, prefix: string, lockdownBoolean: string | number | boolean) { let commandStatus: string; @@ -99,7 +100,7 @@ async function handleLockdown(message: ChatSendAfterEvent, args: string[]) { const key = config.encryption.password ? config.encryption.password : pl.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); if (hash !== undefined && encode === hash) { continue; } diff --git a/src/commands/moderation/modules.ts b/src/commands/moderation/modules.ts index 72249fb..e4743c0 100644 --- a/src/commands/moderation/modules.ts +++ b/src/commands/moderation/modules.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, Player } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getScore, getPrefix, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { ScoreManager } from "../../classes/ScoreManager.js"; function modulesHelp(player: Player, prefix: string) { let commandStatus: string; @@ -55,10 +56,10 @@ export function modules(message: ChatSendAfterEvent, args: string[]) { } // scores - const commandblocks = getScore("commandblocks", player); - const cmds = getScore("cmds", player); - const encharmor = getScore("encharmor", player); - const antikb = getScore("antikb", player); + const commandblocks = ScoreManager.getScore("commandblocks", player); + const cmds = ScoreManager.getScore("cmds", player); + const encharmor = ScoreManager.getScore("encharmor", player); + const antikb = ScoreManager.getScore("antikb", player); // Booleans const worldBorderBoolean = dynamicPropertyRegistry.get("worldborder_b"); diff --git a/src/commands/moderation/op.ts b/src/commands/moderation/op.ts index d9d2879..22f1d6a 100644 --- a/src/commands/moderation/op.ts +++ b/src/commands/moderation/op.ts @@ -1,7 +1,9 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, UUID, getPrefix, sendMsg, sendMsgToPlayer, isValidUUID } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; +import { UUIDManager } from "../../classes/UUIDManager.js"; function opHelp(player: Player, prefix: string) { let commandStatus: string; @@ -48,10 +50,10 @@ export function op(message: ChatSendAfterEvent, args: string[]) { const operatorHash = operator.getDynamicProperty("hash"); const operatorSalt = operator.getDynamicProperty("salt"); - if (!operatorHash || !operatorSalt || (operatorHash !== crypto?.(operatorSalt, config.encryption.password || operator.id) && isValidUUID(operatorSalt as string))) { + if (!operatorHash || !operatorSalt || (operatorHash !== EncryptionManager.hashWithSalt(operatorSalt as string, config.encryption.password || operator.id) && UUIDManager.isValidUUID(operatorSalt as string))) { if (!config.encryption.password) { if (!operator.isOp()) { - return sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f 管理者しか実行できません.`); + return sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f You need to be Operator to use this command.`); } } } @@ -63,19 +65,19 @@ export function op(message: ChatSendAfterEvent, args: string[]) { if (args.length === 0 && !config.encryption.password) { // Operator wants to change their own password - const targetSalt = UUID.generate(); + const targetSalt = UUIDManager.generateRandomUUID(); // Use either the operator's ID or the encryption password as the key const key = config.encryption.password ? config.encryption.password : operator.id; // Generate the hash - const newHash = crypto?.(targetSalt, key); + const newHash = EncryptionManager.hashWithSalt(targetSalt, key); operator.setDynamicProperty("hash", newHash); operator.setDynamicProperty("salt", targetSalt); operator.addTag("paradoxOpped"); - sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f 管理者になりました`); + sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f You are now Paradox-Opped!`); dynamicPropertyRegistry.set(operator.id, operator.name); @@ -83,22 +85,22 @@ export function op(message: ChatSendAfterEvent, args: string[]) { } else if (args.length === 1 && config.encryption.password) { // Allow the user to gain Paradox-Op using the password if (config.encryption.password === args[0]) { - const targetSalt = UUID.generate(); + const targetSalt = UUIDManager.generateRandomUUID(); // Generate the hash using the provided password - const newHash = crypto?.(targetSalt, args[0]); + const newHash = EncryptionManager.hashWithSalt(targetSalt, args[0]); operator.setDynamicProperty("hash", newHash); operator.setDynamicProperty("salt", targetSalt); operator.addTag("paradoxOpped"); - sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f パスワードを使用して管理者になりました`); + sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f You are now Paradox-Opped using the password.`); dynamicPropertyRegistry.set(operator.id, operator.name); } else { // Incorrect password - sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f 不明なパスワードですまた管理者しか実行できません.`); + sendMsgToPlayer(operator, `§f§4[§6Paradox§4]§f Incorrect password. You need to be Operator to use this command.`); } - } else if (args.length >= 1 && operatorHash === crypto?.(operatorSalt, config.encryption.password || operator.id)) { + } else if (args.length >= 1 && operatorHash === EncryptionManager.hashWithSalt(operatorSalt as string, config.encryption.password || operator.id)) { // Operator wants to grant "Paradox-Op" to another player const targetPlayerName = args.join(" "); // Combine all arguments into a single string // Try to find the player requested @@ -117,14 +119,14 @@ export function op(message: ChatSendAfterEvent, args: string[]) { const targetHash = targetPlayer.getDynamicProperty("hash"); if (targetHash === undefined) { - const targetSalt = UUID.generate(); + const targetSalt = UUIDManager.generateRandomUUID(); targetPlayer.setDynamicProperty("salt", targetSalt); // Use either the operator's ID or the encryption password as the key const targetKey = config.encryption.password ? config.encryption.password : targetPlayer.id; // Generate the hash - const newHash = crypto?.(targetSalt, targetKey); + const newHash = EncryptionManager.hashWithSalt(targetSalt, targetKey); targetPlayer.setDynamicProperty("hash", newHash); diff --git a/src/commands/settings/enchantedarmor.ts b/src/commands/settings/enchantedarmor.ts index f962d68..9915f55 100644 --- a/src/commands/settings/enchantedarmor.ts +++ b/src/commands/settings/enchantedarmor.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, Player } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getPrefix, getScore, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { ScoreManager } from "../../classes/ScoreManager.js"; function enchantedArmorHelp(player: Player, prefix: string, encharmorscore: number) { let commandStatus: string; @@ -64,7 +65,7 @@ async function handleEnchantedArmor(message: ChatSendAfterEvent, args: string[]) return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者権限がないと実行できません!!`); } - const encharmorscore = getScore("encharmor", player); + const encharmorscore = ScoreManager.getScore("encharmor", player); // Check for custom prefix const prefix = getPrefix(player); diff --git a/src/commands/settings/overidecommandblocksenabled.ts b/src/commands/settings/overidecommandblocksenabled.ts index 6989f31..2d03f93 100644 --- a/src/commands/settings/overidecommandblocksenabled.ts +++ b/src/commands/settings/overidecommandblocksenabled.ts @@ -1,7 +1,8 @@ import { ChatSendAfterEvent, Player } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getPrefix, getScore, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { ScoreManager } from "../../classes/ScoreManager.js"; function overrideCBEHelp(player: Player, prefix: string, cmdsscore: number) { let commandStatus: string; @@ -64,7 +65,7 @@ async function handleOverideCommandBlocksEnabled(message: ChatSendAfterEvent, ar return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者権限がないと実行できません!!`); } - const cmdsscore = getScore("cmds", player); + const cmdsscore = ScoreManager.getScore("cmds", player); // Check for custom prefix const prefix = getPrefix(player); diff --git a/src/commands/settings/removecommandblocks.ts b/src/commands/settings/removecommandblocks.ts index 1e29493..5c8a425 100644 --- a/src/commands/settings/removecommandblocks.ts +++ b/src/commands/settings/removecommandblocks.ts @@ -1,7 +1,9 @@ import { ChatSendAfterEvent, Player } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getPrefix, getScore, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsg, sendMsgToPlayer } from "../../util.js"; +import { ScaffoldA } from "../../penrose/BlockPlaceAfterEvent/scaffold/scaffold_a.js"; +import { ScoreManager } from "../../classes/ScoreManager.js"; function removeCBEHelp(player: Player, prefix: string, commandblocksscore: number) { let commandStatus: string; @@ -64,7 +66,7 @@ async function handleRemoveCommandBlocks(message: ChatSendAfterEvent, args: stri return sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者権限がないと実行できません!!`); } - const commandblocksscore = getScore("commandblocks", player); + const commandblocksscore = ScoreManager.getScore("commandblocks", player); // Check for custom prefix const prefix = getPrefix(player); diff --git a/src/commands/utility/delhome.ts b/src/commands/utility/delhome.ts index 95e4a1d..df69320 100644 --- a/src/commands/utility/delhome.ts +++ b/src/commands/utility/delhome.ts @@ -1,6 +1,7 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; -import { decryptString, getPrefix, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; function delhomeHelp(player: Player, prefix: string) { let commandStatus: string; @@ -70,7 +71,7 @@ export function delhome(message: ChatSendAfterEvent, args: string[]) { if (tags[i].startsWith("1337")) { encryptedString = tags[i]; // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); } if (tags[i].startsWith(args[0].toString() + " X", 13)) { verify = true; diff --git a/src/commands/utility/fullreport.ts b/src/commands/utility/fullreport.ts index 1891826..f431f35 100644 --- a/src/commands/utility/fullreport.ts +++ b/src/commands/utility/fullreport.ts @@ -103,7 +103,7 @@ async function handleFullReport(message: ChatSendAfterEvent, args: string[]) { let divider = false; ScoreManager.allscores.forEach((objective) => { vlCount++; - const score = ScoreManager.getScore(objective, member); + const score = ScoreManager.ScoreManager.getscore(objective, member); if (score > 0) { violationsFound++; if (violationsFound === 1) { diff --git a/src/commands/utility/give.ts b/src/commands/utility/give.ts index 007a80e..677f124 100644 --- a/src/commands/utility/give.ts +++ b/src/commands/utility/give.ts @@ -2,7 +2,8 @@ import { ChatSendAfterEvent, Player, world, ItemStack } from "@minecraft/server" import { MinecraftItemTypes } from "../../node_modules/@minecraft/vanilla-data/lib/index"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getPrefix, sendMsgToPlayer, toPascalCase } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { StringTransformation } from "../../classes/StringTransformation"; function giveHelp(player: Player, prefix: string) { let commandStatus: string; @@ -91,7 +92,7 @@ export function give(message: ChatSendAfterEvent, args: string[]) { * args[3] = data (optional) */ let confirmItem = false; - const itemStringConvert = toPascalCase(args[1]); + const itemStringConvert = StringTransformation.toPascalCase(args[1]); for (const itemValidate in MinecraftItemTypes) { if (itemStringConvert === itemValidate) { confirmItem = true; diff --git a/src/commands/utility/gohome.ts b/src/commands/utility/gohome.ts index 3591566..aef030f 100644 --- a/src/commands/utility/gohome.ts +++ b/src/commands/utility/gohome.ts @@ -1,7 +1,8 @@ import { world, Player, ChatSendAfterEvent } from "@minecraft/server"; import config from "../../data/config.js"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { decryptString, getPrefix, sendMsgToPlayer, setTimer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer, setTimer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; const cooldownTimer = new WeakMap(); @@ -111,7 +112,7 @@ async function handleGoHome(message: ChatSendAfterEvent, args: string[]) { for (let i = 0; i < tagsLength; i++) { if (tags[i].startsWith("1337")) { // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); } if (tags[i].startsWith(args[0].toString() + " X", 13)) { // Split string into array diff --git a/src/commands/utility/listhome.ts b/src/commands/utility/listhome.ts index d9a6026..54067a5 100644 --- a/src/commands/utility/listhome.ts +++ b/src/commands/utility/listhome.ts @@ -1,6 +1,7 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; -import { decryptString, getPrefix, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; function listHomeHelp(player: Player, prefix: string) { let commandStatus: string; @@ -57,7 +58,7 @@ export function listhome(message: ChatSendAfterEvent, args: string[]) { for (let i = 0; i < tagsLength; i++) { if (tags[i].startsWith("1337")) { // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] =EncryptionManager.decryptString(tags[i], salt as string); // If invalid then skip it if (tags[i].startsWith("LocationHome:") === false) { continue; diff --git a/src/commands/utility/sethome.ts b/src/commands/utility/sethome.ts index 21bce5f..bd85db0 100644 --- a/src/commands/utility/sethome.ts +++ b/src/commands/utility/sethome.ts @@ -1,6 +1,7 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config.js"; -import { decryptString, getPrefix, encryptString, sendMsgToPlayer } from "../../util.js"; +import { getPrefix, sendMsgToPlayer } from "../../util.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; function setHomeHelp(player: Player, prefix: string) { let commandStatus: string; @@ -75,7 +76,7 @@ export function sethome(message: ChatSendAfterEvent, args: string[]) { for (let i = 0; i < tagsLength; i++) { if (tags[i].startsWith("1337")) { // Decode it so we can verify if it already exists - tags[i] = decryptString(tags[i], String(salt)); + tags[i] = EncryptionManager.decryptString(tags[i], String(salt)); } if (tags[i].startsWith(args[0].toString() + " X", 13)) { verify = true; @@ -107,7 +108,7 @@ export function sethome(message: ChatSendAfterEvent, args: string[]) { } const decryptedLocationString = `LocationHome:${args[0]} X:${homex} Y:${homey} Z:${homez} Dimension:${currentDimension}`; - const security = encryptString(decryptedLocationString, String(salt)); + const security = EncryptionManager.encryptString(decryptedLocationString, String(salt)); // Store their new home coordinates player.addTag(security); diff --git a/src/commands/utility/stats.ts b/src/commands/utility/stats.ts index 3ebba83..9bfe833 100644 --- a/src/commands/utility/stats.ts +++ b/src/commands/utility/stats.ts @@ -115,75 +115,74 @@ async function handleStats(message: ChatSendAfterEvent, args: string[]) { } let violationsFound = 0; - let vlCount = 0; - let divider = false; - ScoreManager.allscores.forEach((objective) => { - vlCount++; - const score = ScoreManager.getScore(objective, member); - if (score > 0) { - violationsFound++; - if (violationsFound === 1) { - divider = true; - reportBody.push(`§f§4[§6Paradox§4]§4 ----------------------------------§f`); - } - reportBody.push(`§f§4[§6Paradox§4]§f §f§4[§6${objective.replace("vl", "").toUpperCase()}§4]§f: ${score}回検知されています`); - } - if (vlCount === ScoreManager.allscores.length && divider === true) { + let vlCount = 0; + let divider = false; + ScoreManager.allscores.forEach((objective) => { + vlCount++; + const score = ScoreManager.ScoreManager.getscore(objective, member); + if (score > 0) { + violationsFound++; + if (violationsFound === 1) { + divider = true; reportBody.push(`§f§4[§6Paradox§4]§4 ----------------------------------§f`); } - }); - - const equipment = member.getComponent("equipment_inventory") as EntityEquipmentInventoryComponent; - const helmet = equipment.getEquipment("head" as EquipmentSlot); - const chest = equipment.getEquipment("chest" as EquipmentSlot); - const legs = equipment.getEquipment("legs" as EquipmentSlot); - const feet = equipment.getEquipment("feet" as EquipmentSlot); - const mainhand = equipment.getEquipment("mainhand" as EquipmentSlot); - const offhand = equipment.getEquipment("offhand" as EquipmentSlot); - - const materialColors: { [key: string]: string } = { - golden: "§6", // gold - iron: "§7", // light gray - diamond: "§b", // aqua - leather: "§e", // yellow - chainmail: "§8", // dark gray - turtle: "§a", // green - netherite: "§4", // dark red - elytra: "§5", // purple - none: "§f", // white - }; - - for (const [verification, armorType] of [ - [helmet, "帽子"], - [chest, "服"], - [legs, "ズボン"], - [feet, "靴"], - [mainhand, "メインハンド"], - [offhand, "オフハンド"], - ]) { - if (!(verification instanceof ItemStack)) { - continue; - } - const enchantedEquipment = verification.getComponent("enchantments") as ItemEnchantsComponent; - const enchantList = enchantedEquipment.enchantments; - if (!enchantList) { - continue; - } - let isEnchanted = false; - for (const enchant in MinecraftEnchantmentTypes) { - const enchantNumber = enchantList.hasEnchantment(MinecraftEnchantmentTypes[enchant as keyof typeof MinecraftEnchantmentTypes]); - if (enchantNumber > 0) { - isEnchanted = true; - } - } - let materialType = verification.typeId.split(":")[1].replace(/_\w+/, ""); - if (armorType === "Mainhand" || armorType === "Offhand") { - materialType = verification.typeId.split(":")[1]; - } - const materialColor = materialColors[materialType] || materialColors["none"]; - reportBody.push(`§f§4[§6Paradox§4]§f ${armorType}: ${isEnchanted ? "§aエンチャ有§f" : "§4エンチャ無§f"} || ${materialColor}${materialType}`); + reportBody.push(`§f§4[§6Paradox§4]§f §f§4[§6${objective.replace("vl", "").toUpperCase()}§4]§f: ${score}回検知されています`); + } + if (vlCount === ScoreManager.allscores.length && divider === true) { + reportBody.push(`§f§4[§6Paradox§4]§4 ----------------------------------§f`); } + }); - sendMsgToPlayer(player, reportBody); + const equipment = member.getComponent("equipment_inventory") as EntityEquipmentInventoryComponent; + const helmet = equipment.getEquipment("head" as EquipmentSlot); + const chest = equipment.getEquipment("chest" as EquipmentSlot); + const legs = equipment.getEquipment("legs" as EquipmentSlot); + const feet = equipment.getEquipment("feet" as EquipmentSlot); + const mainhand = equipment.getEquipment("mainhand" as EquipmentSlot); + const offhand = equipment.getEquipment("offhand" as EquipmentSlot); + + const materialColors: { [key: string]: string } = { + golden: "§6", // gold + iron: "§7", // light gray + diamond: "§b", // aqua + leather: "§e", // yellow + chainmail: "§8", // dark gray + turtle: "§a", // green + netherite: "§4", // dark red + elytra: "§5", // purple + none: "§f", // white + }; + + for (const [verification, armorType] of [ + [helmet, "帽子"], + [chest, "服"], + [legs, "ズボン"], + [feet, "靴"], + [mainhand, "メインハンド"], + [offhand, "オフハンド"], + ]) { + if (!(verification instanceof ItemStack)) { + continue; + } + const enchantedEquipment = verification.getComponent("enchantments") as ItemEnchantsComponent; + const enchantList = enchantedEquipment.enchantments; + if (!enchantList) { + continue; + } + let isEnchanted = false; + for (const enchant in MinecraftEnchantmentTypes) { + const enchantNumber = enchantList.hasEnchantment(MinecraftEnchantmentTypes[enchant as keyof typeof MinecraftEnchantmentTypes]); + if (enchantNumber > 0) { + isEnchanted = true; + } + } + let materialType = verification.typeId.split(":")[1].replace(/_\w+/, ""); + if (armorType === "Mainhand" || armorType === "Offhand") { + materialType = verification.typeId.split(":")[1]; + } + const materialColor = materialColors[materialType] || materialColors["none"]; + reportBody.push(`§f§4[§6Paradox§4]§f ${armorType}: ${isEnchanted ? "§aエンチャ有§f" : "§4エンチャ無§f"} || ${materialColor}${materialType}`); } + sendMsgToPlayer(player, reportBody); +} diff --git a/src/commands/utility/tpr.ts b/src/commands/utility/tpr.ts index 5ee5f53..17fde2f 100644 --- a/src/commands/utility/tpr.ts +++ b/src/commands/utility/tpr.ts @@ -1,6 +1,7 @@ import { ChatSendAfterEvent, Player, world } from "@minecraft/server"; import config from "../../data/config"; -import { decryptString, getPrefix, sendMsgToPlayer, setTimer } from "../../util"; +import { getPrefix, sendMsgToPlayer, setTimer } from "../../util"; +import { EncryptionManager } from "../../classes/EncryptionManager"; interface TeleportRequest { requester: Player; @@ -95,7 +96,7 @@ function teleportRequestHandler({ sender, message }: ChatSendAfterEvent) { function teleportRequestApprovalHandler(object: ChatSendAfterEvent) { const { sender, message } = object; - const lowercaseMessage = decryptString(message, sender.id).toLowerCase(); + const lowercaseMessage =EncryptionManager.decryptString(message, sender.id).toLowerCase(); // Extract the response from the decrypted string const refChar = lowercaseMessage.split("§r"); const extractedPhrase = refChar[1]; diff --git a/src/gui/guiHandler/guiHandlerModules/results/commandblocks.ts b/src/gui/guiHandler/guiHandlerModules/results/commandblocks.ts index 567f19e..e56404b 100644 --- a/src/gui/guiHandler/guiHandlerModules/results/commandblocks.ts +++ b/src/gui/guiHandler/guiHandlerModules/results/commandblocks.ts @@ -1,12 +1,12 @@ import { Player } from "@minecraft/server"; import { ModalFormData } from "@minecraft/server-ui"; -import { getScore } from "../../../../util"; import { uiCOMMANDBLOCKS } from "../../../modules/uiCommandBlocks"; +import { ScoreManager } from "../../../../classes/ScoreManager"; export function commandBlocksHandler(player: Player) { const modulescommandblocksui = new ModalFormData(); - const cmdsscore = getScore("cmds", player); - const commandblocksscore = getScore("commandblocks", player); + const cmdsscore = ScoreManager.getScore("cmds", player); + const commandblocksscore = ScoreManager.getScore("commandblocks", player); let removecmdblocksBoolean; Boolean; let cmdoBoolean: boolean; diff --git a/src/gui/guiHandler/guiHandlerModules/results/enchantedarmor.ts b/src/gui/guiHandler/guiHandlerModules/results/enchantedarmor.ts index d93226a..c856cb9 100644 --- a/src/gui/guiHandler/guiHandlerModules/results/enchantedarmor.ts +++ b/src/gui/guiHandler/guiHandlerModules/results/enchantedarmor.ts @@ -1,11 +1,11 @@ import { Player } from "@minecraft/server"; import { ModalFormData } from "@minecraft/server-ui"; -import { getScore } from "../../../../util"; import { uiENCHANTEDARMOR } from "../../../modules/uiEnchantedArmor"; +import { ScoreManager } from "../../../../classes/ScoreManager"; export function antiEnchantedArmorHandler(player: Player) { const modulesenchantedarmorui = new ModalFormData(); - const encharmorscore = getScore("encharmor", player); + const encharmorscore = ScoreManager.getScore("encharmor", player); let enchantedarmorBoolean: boolean; /**get the score value and then check to see if its already enable or already disabled * so we can then update the control boolean to disaply its current setting to the player diff --git a/src/gui/guiHandler/results/location.ts b/src/gui/guiHandler/results/location.ts index 73649df..0ac18b1 100644 --- a/src/gui/guiHandler/results/location.ts +++ b/src/gui/guiHandler/results/location.ts @@ -1,8 +1,9 @@ import { Player, world } from "@minecraft/server"; import { ModalFormData } from "@minecraft/server-ui"; -import { decryptString, sendMsgToPlayer } from "../../../util"; +import { sendMsgToPlayer } from "../../../util"; import config from "../../../data/config"; import { uiSAVEDLOCATIONS } from "../../playerui/uiSavedLocations"; +import { EncryptionManager } from "../../../classes/EncryptionManager"; export function locationHandler(player: Player) { //No Opped Menu to show Saved Locations @@ -17,7 +18,7 @@ export function locationHandler(player: Player) { for (let i = 0; i < tagsLength; i++) { if (tags[i].startsWith("1337")) { // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); // If invalid then skip it if (tags[i].startsWith("LocationHome:") === false) { continue; diff --git a/src/gui/moderation/uiDeop.ts b/src/gui/moderation/uiDeop.ts index 0dc55d6..ada3435 100644 --- a/src/gui/moderation/uiDeop.ts +++ b/src/gui/moderation/uiDeop.ts @@ -1,9 +1,10 @@ import { Player, world } from "@minecraft/server"; import { ModalFormResponse } from "@minecraft/server-ui"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, sendMsg, sendMsgToPlayer } from "../../util"; +import { sendMsg, sendMsgToPlayer } from "../../util"; import { paradoxui } from "../paradoxui.js"; import config from "../../data/config.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; //Function provided by Visual1mpact export function uiDEOP(opResult: ModalFormResponse, onlineList: string[], player: Player) { @@ -29,7 +30,7 @@ export function uiDEOP(opResult: ModalFormResponse, onlineList: string[], player const key = config.encryption.password ? config.encryption.password : member.id; // Generate the hash - const memberEncode: string = crypto(memberSalt, key) ?? null; + const memberEncode: string = EncryptionManager.hashWithSalt(memberSalt as string, key) ?? null; if (memberHash !== undefined && memberHash === memberEncode) { member.removeDynamicProperty("hash"); diff --git a/src/gui/moderation/uiLockdown.ts b/src/gui/moderation/uiLockdown.ts index 2d36db2..476e721 100644 --- a/src/gui/moderation/uiLockdown.ts +++ b/src/gui/moderation/uiLockdown.ts @@ -1,9 +1,10 @@ import { Player, world } from "@minecraft/server"; import { ModalFormResponse } from "@minecraft/server-ui"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, sendMsg, sendMsgToPlayer } from "../../util"; +import { sendMsg, sendMsgToPlayer } from "../../util"; import { paradoxui } from "../paradoxui.js"; import config from "../../data/config.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; /** * Handles the result of a modal form used for initiating a server lockdown. @@ -51,7 +52,7 @@ async function handleUILockdown(lockdownResult: ModalFormResponse, player: Playe const key = config.encryption.password ? config.encryption.password : pl.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); if (hash !== undefined && encode === hash) { continue; } diff --git a/src/gui/moderation/uiManagePlayerSavedLocations.ts b/src/gui/moderation/uiManagePlayerSavedLocations.ts index 875b54d..509311e 100644 --- a/src/gui/moderation/uiManagePlayerSavedLocations.ts +++ b/src/gui/moderation/uiManagePlayerSavedLocations.ts @@ -1,8 +1,9 @@ import { Player, world } from "@minecraft/server"; import { ModalFormData, ModalFormResponse } from "@minecraft/server-ui"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry"; -import { decryptString, sendMsgToPlayer } from "../../util"; +import { sendMsgToPlayer } from "../../util"; import { paradoxui } from "../paradoxui"; +import { EncryptionManager } from "../../classes/EncryptionManager"; export function uiManagePlayerSavedLocations(managePlayerSavedLocationsUIResult: ModalFormResponse, onlineList: string[], player: Player) { handleUImanagePlayerSavedLocations(managePlayerSavedLocationsUIResult, onlineList, player).catch((error) => { @@ -49,7 +50,7 @@ async function handleUImanagePlayerSavedLocations(managePlayerSavedLocationsUIRe for (let i = 0; i < tagsLength; i++) { if (tags[i].startsWith("1337")) { // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); // If invalid then skip it if (tags[i].startsWith("LocationHome:") === false) { continue; @@ -96,7 +97,7 @@ async function handleUImanagePlayerSavedLocations(managePlayerSavedLocationsUIRe if (tags[i].startsWith("1337")) { encryptedString = tags[i]; // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); } if (tags[i].startsWith("LocationHome:" && Locations[selectedLocationvalue as number] + " X", 13)) { member.removeTag(encryptedString); diff --git a/src/gui/moderation/uiOp.ts b/src/gui/moderation/uiOp.ts index fb85080..a8ae24e 100644 --- a/src/gui/moderation/uiOp.ts +++ b/src/gui/moderation/uiOp.ts @@ -1,9 +1,11 @@ import { Player, world } from "@minecraft/server"; import { ActionFormResponse, ModalFormResponse } from "@minecraft/server-ui"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { crypto, isValidUUID, sendMsg, sendMsgToPlayer, UUID } from "../../util"; +import { sendMsg, sendMsgToPlayer } from "../../util"; import { paradoxui } from "../paradoxui.js"; import config from "../../data/config.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; +import { UUIDManager } from "../../classes/UUIDManager.js"; //Function provided by Visual1mpact export function uiOP(opResult: ModalFormResponse | ActionFormResponse, salt: string | number | boolean, hash: string | number | boolean, player: Player, onlineList?: string[]) { @@ -11,7 +13,7 @@ export function uiOP(opResult: ModalFormResponse | ActionFormResponse, salt: str // Handle canceled form or undefined result return; } - if (!hash || !salt || (hash !== crypto?.(salt, config.encryption.password || player.id) && isValidUUID(salt as string))) { + if (!hash || !salt || (hash !== EncryptionManager.hashWithSalt(salt as string, config.encryption.password || player.id) && UUIDManager.isValidUUID(salt as string))) { if (!config.encryption.password) { if (!player.isOp()) { sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 管理者しか実行できません.`); @@ -48,14 +50,14 @@ export function uiOP(opResult: ModalFormResponse | ActionFormResponse, salt: str const targetHash = targetPlayer.getDynamicProperty("hash"); if (targetHash === undefined) { - const targetSalt = UUID.generate(); + const targetSalt = UUIDManager.generateRandomUUID(); targetPlayer.setDynamicProperty("salt", targetSalt); // Use either the operator's ID or the encryption password as the key const targetKey = config.encryption.password ? config.encryption.password : targetPlayer.id; // Generate the hash - const newHash = crypto?.(targetSalt, targetKey); + const newHash = EncryptionManager.hashWithSalt(targetSalt, targetKey); targetPlayer.setDynamicProperty("hash", newHash); @@ -78,8 +80,8 @@ export function uiOP(opResult: ModalFormResponse | ActionFormResponse, salt: str // It's an ActionFormResponse if (opResult.selection === 0) { // player wants to change their own password - const targetSalt = UUID.generate(); - const newHash = crypto?.(targetSalt, player.id); + const targetSalt = UUIDManager.generateRandomUUID(); + const newHash = EncryptionManager.hashWithSalt(targetSalt, player.id); player.setDynamicProperty("hash", newHash); player.setDynamicProperty("salt", targetSalt); diff --git a/src/gui/moderation/uiStats.ts b/src/gui/moderation/uiStats.ts index b660a22..a546960 100644 --- a/src/gui/moderation/uiStats.ts +++ b/src/gui/moderation/uiStats.ts @@ -46,7 +46,9 @@ export function uiSTATS(statsResult: ModalFormResponse, onlineList: string[], pl switch (true) { case member.hasTag("paradoxFreeze"): - reportBody.push(`§f§4[§6Paradox§4]§f §6${member.name}§f フリーズ 検知内容=> ${member.hasTag("freezeAura") ? "AntiKillAura" : member.hasTag("freezeNukerA") ? "AntiNukerA" : member.hasTag("freezeScaffoldA") ? "AntiScaffoldA" : "Staff"}`); + reportBody.push( + `§f§4[§6Paradox§4]§f §6${member.name}§f フリーズ 検知内容=> ${member.hasTag("freezeAura") ? "AntiKillAura" : member.hasTag("freezeNukerA") ? "AntiNukerA" : member.hasTag("freezeScaffoldA") ? "AntiScaffoldA" : "Staff"}` + ); break; case member.hasTag("flying"): reportBody.push(`§f§4[§6Paradox§4]§f §6${member.name}§f 飛行有効`); @@ -57,7 +59,7 @@ export function uiSTATS(statsResult: ModalFormResponse, onlineList: string[], pl } allObjectives.forEach((objective) => { - const score = ScoreManager.getScore(objective, member); + const score = ScoreManager.ScoreManager.getscore(objective, member); if (score > 0) { reportBody.push(`§f§4[§6${objective.replace("vl", "").toUpperCase()}§4]§f number of Violations: ${score}\n`); } diff --git a/src/gui/modules/uiCommandBlocks.ts b/src/gui/modules/uiCommandBlocks.ts index a87eba8..1873c8a 100644 --- a/src/gui/modules/uiCommandBlocks.ts +++ b/src/gui/modules/uiCommandBlocks.ts @@ -1,8 +1,9 @@ import { Player } from "@minecraft/server"; import { ModalFormResponse } from "@minecraft/server-ui"; import { dynamicPropertyRegistry } from "../../penrose/WorldInitializeAfterEvent/registry.js"; -import { getScore, sendMsg, sendMsgToPlayer } from "../../util"; +import { sendMsg, sendMsgToPlayer } from "../../util"; import { paradoxui } from "../paradoxui.js"; +import { ScoreManager } from "../../classes/ScoreManager.js"; /** * Handles the result of a modal form used for toggling command blocks mode. @@ -36,8 +37,8 @@ async function handleUICommandBlocks(commandblocksResult: ModalFormResponse, pla // Get Dynamic Property Boolean //get the current scores - const cmdsscore = getScore("cmds", player); - const commandblocksscore = getScore("commandblocks", player); + const cmdsscore = ScoreManager.getScore("cmds", player); + const commandblocksscore = ScoreManager.getScore("commandblocks", player); let removecmdblocksBoolean; Boolean; let cmdoBoolean: boolean; diff --git a/src/gui/playerui/uiSavedLocations.ts b/src/gui/playerui/uiSavedLocations.ts index 4c78c1f..8c34462 100644 --- a/src/gui/playerui/uiSavedLocations.ts +++ b/src/gui/playerui/uiSavedLocations.ts @@ -1,8 +1,9 @@ import { Player, world } from "@minecraft/server"; import { ModalFormResponse } from "@minecraft/server-ui"; import config from "../../data/config.js"; -import { decryptString, encryptString, sendMsgToPlayer, setTimer } from "../../util.js"; +import { sendMsgToPlayer, setTimer } from "../../util.js"; import { paradoxui } from "../paradoxui.js"; +import { EncryptionManager } from "../../classes/EncryptionManager.js"; export function uiSAVEDLOCATIONS(savedlocationsResult: ModalFormResponse, Locations: string[], player: Player, coordArray: string[]) { if (!savedlocationsResult || savedlocationsResult.canceled) { @@ -46,7 +47,7 @@ export function uiSAVEDLOCATIONS(savedlocationsResult: ModalFormResponse, Locati if (tags[i].startsWith("1337")) { encryptedString = tags[i]; // Decode it so we can verify it - tags[i] = decryptString(tags[i], salt as string); + tags[i] = EncryptionManager.decryptString(tags[i], salt as string); } if (tags[i].startsWith("LocationHome:" && Locations[selectedLocationvalue as number] + " X", 13)) { player.removeTag(encryptedString); @@ -106,7 +107,7 @@ export function uiSAVEDLOCATIONS(savedlocationsResult: ModalFormResponse, Locati } if (doSave === true) { const decryptedLocationString = `LocationHome:${newLocationName} X:${currentX} Y:${currentY} Z:${currentZ} Dimension:${currentDimension}`; - const security = encryptString(decryptedLocationString, salt as string); + const security = EncryptionManager.encryptString(decryptedLocationString, salt as string); player.addTag(security); sendMsgToPlayer(player, `§f§4[§6Paradox§4]§f 新しい座標を保存しました.`); } diff --git a/src/penrose/BlockPlaceAfterEvent/illegalitems/illegalitems_b.ts b/src/penrose/BlockPlaceAfterEvent/illegalitems/illegalitems_b.ts index 84b0f6c..88da21d 100644 --- a/src/penrose/BlockPlaceAfterEvent/illegalitems/illegalitems_b.ts +++ b/src/penrose/BlockPlaceAfterEvent/illegalitems/illegalitems_b.ts @@ -1,10 +1,11 @@ import { world, ItemStack, Enchantment, Player, Block, BlockPlaceAfterEvent, BlockInventoryComponent, ItemEnchantsComponent, EnchantmentList, PlayerLeaveAfterEvent } from "@minecraft/server"; import { illegalitems } from "../../../data/itemban.js"; import config from "../../../data/config.js"; -import { flag, titleCase, sendMsgToPlayer, sendMsg } from "../../../util.js"; +import { flag, sendMsgToPlayer, sendMsg } from "../../../util.js"; import { kickablePlayers } from "../../../kickcheck.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; import { illegalItemsBWhitelist } from "../../../data/illegalItemsB_whitelist.js"; +import { StringTransformation } from "../../../classes/StringTransformation.js"; // Create a map of player objects and their enchantment presence const enchantmentPresenceMap = new Map>(); @@ -288,7 +289,7 @@ async function illegalitemsb(object: BlockPlaceAfterEvent) { // Iterate over the unverifiedItemMap for (const [slot, itemStackData] of unverifiedItemMap.get(player.id)) { // Create a new name tag for the item - const newNameTag = titleCase(itemStackData.typeId.replace("minecraft:", "")); + const newNameTag = StringTransformation.titleCase(itemStackData.typeId.replace("minecraft:", "")); // Create a new ItemStack with the same type as the original item const applyCustomProperties = new ItemStack(itemStackData.typeId); // Get the original enchantment component from the item diff --git a/src/penrose/PlayerSpawnAfterEvent/hash/hash.ts b/src/penrose/PlayerSpawnAfterEvent/hash/hash.ts index b47a707..16ab05c 100644 --- a/src/penrose/PlayerSpawnAfterEvent/hash/hash.ts +++ b/src/penrose/PlayerSpawnAfterEvent/hash/hash.ts @@ -1,7 +1,7 @@ import { PlayerSpawnAfterEvent, world } from "@minecraft/server"; -import { crypto } from "../../../util"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry"; import config from "../../../data/config"; +import { EncryptionManager } from "../../../classes/EncryptionManager"; function verification(object: PlayerSpawnAfterEvent) { // Properties from class @@ -19,7 +19,7 @@ function verification(object: PlayerSpawnAfterEvent) { const key = config.encryption.password ? config.encryption.password : player.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); if (encode === hash) { // Store as an element using player scoreboard id to uniquely identify them dynamicPropertyRegistry.set(player.id, player.name); diff --git a/src/penrose/PlayerSpawnAfterEvent/onjoin/onjoin.ts b/src/penrose/PlayerSpawnAfterEvent/onjoin/onjoin.ts index 28296b4..62e10e8 100644 --- a/src/penrose/PlayerSpawnAfterEvent/onjoin/onjoin.ts +++ b/src/penrose/PlayerSpawnAfterEvent/onjoin/onjoin.ts @@ -1,8 +1,9 @@ import { Player, PlayerSpawnAfterEvent, world } from "@minecraft/server"; import { onJoinPrimaryData, onJoinSecondaryData } from "../../../data/onjoindata.js"; -import { getPrefix, setScore, setTimer } from "../../../util.js"; +import { getPrefix, setTimer } from "../../../util.js"; import { kickablePlayers } from "../../../kickcheck.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { ScoreManager } from "../../../classes/ScoreManager.js"; async function onJoinTime(object: PlayerSpawnAfterEvent) { /** @@ -50,7 +51,7 @@ async function onJoinTime(object: PlayerSpawnAfterEvent) { const verifyObjective = world.scoreboard.getObjective(onJoinPrimaryData[i]); if (!verifyObjective) { world.scoreboard.addObjective(onJoinPrimaryData[i], onJoinPrimaryData[i]); - setScore(player, onJoinPrimaryData[i], 0, true); + ScoreManager.setScore(player, onJoinPrimaryData[i], 0, true); } } diff --git a/src/penrose/TickEvent/ban/autoban.ts b/src/penrose/TickEvent/ban/autoban.ts index 92215ee..1631d59 100644 --- a/src/penrose/TickEvent/ban/autoban.ts +++ b/src/penrose/TickEvent/ban/autoban.ts @@ -36,7 +36,7 @@ function autoban(id: number) { return; } scores.forEach((score) => { - const playerScore = ScoreManager.getScore(score, player); + const playerScore = ScoreManager.ScoreManager.getscore(score, player); if (playerScore > 1000) { const reReason = score.replace("vl", "").toUpperCase() + " 検知内容=>: " + playerScore; return rip(player, reReason); diff --git a/src/penrose/TickEvent/ban/serverban.ts b/src/penrose/TickEvent/ban/serverban.ts index effd909..de496ee 100644 --- a/src/penrose/TickEvent/ban/serverban.ts +++ b/src/penrose/TickEvent/ban/serverban.ts @@ -31,7 +31,7 @@ function serverban() { //clear violations const scores = ScoreManager.allscores; scores.forEach((objective) => { - const score = ScoreManager.getScore(objective, player); + const score = ScoreManager.ScoreManager.getscore(objective, player); //if the player has a violation then we reset the score. if (score > 0) { //reset the score diff --git a/src/penrose/TickEvent/freeze/freeze.ts b/src/penrose/TickEvent/freeze/freeze.ts index 40f18e6..faf78f7 100644 --- a/src/penrose/TickEvent/freeze/freeze.ts +++ b/src/penrose/TickEvent/freeze/freeze.ts @@ -1,6 +1,7 @@ import { world, Player, system, EntityQueryOptions, Vector } from "@minecraft/server"; -import { decryptString, encryptString, sendMsg, setTimer } from "../../../util"; +import { sendMsg, setTimer } from "../../../util"; import { MinecraftEffectTypes } from "../../../node_modules/@minecraft/vanilla-data/lib/index"; +import { EncryptionManager } from "../../../classes/EncryptionManager"; function freezePlayer(player: Player) { // Record the player's original location @@ -21,7 +22,7 @@ function freezePlayer(player: Player) { player.runCommand(`fill ${originalLocation.x + 2} ${245 + 2} ${originalLocation.z + 2} ${originalLocation.x - 2} ${245 - 1} ${originalLocation.z - 2} barrier [] hollow`); // Encrypt the data - const encryptData = encryptString(`${originalLocation.x},${originalLocation.y},${originalLocation.z},${originalDimension.replace("minecraft:", "")}`, player.id); + const encryptData = EncryptionManager.encryptString(`${originalLocation.x},${originalLocation.y},${originalLocation.z},${originalDimension.replace("minecraft:", "")}`, player.id); // Store original location and dimension in a tag player.addTag(`paradoxFreezeData:${encryptData}`); } @@ -36,7 +37,7 @@ function unfreezePlayer(player: Player) { if (freezeTag) { // Decrypt data - const decryptData = decryptString(freezeTag.replace("paradoxFreezeData:", ""), player.id); + const decryptData = EncryptionManager.decryptString(freezeTag.replace("paradoxFreezeData:", ""), player.id); const freezeTagDecrypt = `paradoxFreezeData:${decryptData}`; // Parse the tag to extract location and dimension information const tagParts = freezeTagDecrypt.split(":"); @@ -87,7 +88,7 @@ const freezePlayers = () => { let freezeDataTag = player.getTags().find((tag) => tag.startsWith("paradoxFreezeData:")); if (freezeDataTag) { // Decrypt data - const decryptData = decryptString(freezeDataTag.replace("paradoxFreezeData:", ""), player.id); + const decryptData = EncryptionManager.decryptString(freezeDataTag.replace("paradoxFreezeData:", ""), player.id); freezeDataTag = `paradoxFreezeData:${decryptData}`; // Process data const freezeData = freezeDataTag.split(":")[1]; diff --git a/src/penrose/TickEvent/gamemode/adventure.ts b/src/penrose/TickEvent/gamemode/adventure.ts index 339f3f7..70ff34c 100644 --- a/src/penrose/TickEvent/gamemode/adventure.ts +++ b/src/penrose/TickEvent/gamemode/adventure.ts @@ -1,6 +1,7 @@ import { world, EntityQueryOptions, GameMode, system } from "@minecraft/server"; -import { getScore, sendMsg, setScore } from "../../../util.js"; +import { sendMsg,} from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { ScoreManager } from "../../../classes/ScoreManager.js"; async function adventure(id: number) { // Get Dynamic Property @@ -45,8 +46,8 @@ async function adventure(id: number) { // Survival is allowed so set them to survival player.runCommandAsync(`gamemode survival`); } - setScore(player, "gamemodevl", 1, true); - sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_A)§6.§4 VL= ${getScore("gamemodevl", player)}`); + ScoreManager.setScore(player, "gamemodevl", 1, true); + sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_A)§6.§4 VL= ${ScoreManager.getScore("gamemodevl", player)}`); } } diff --git a/src/penrose/TickEvent/gamemode/creative.ts b/src/penrose/TickEvent/gamemode/creative.ts index 200198a..c62b458 100644 --- a/src/penrose/TickEvent/gamemode/creative.ts +++ b/src/penrose/TickEvent/gamemode/creative.ts @@ -1,6 +1,7 @@ import { world, EntityQueryOptions, GameMode, system } from "@minecraft/server"; -import { getScore, sendMsg, setScore } from "../../../util.js"; +import { sendMsg } from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { ScoreManager } from "../../../classes/ScoreManager.js"; async function creative(id: number) { // Get Dynamic Property @@ -46,8 +47,8 @@ async function creative(id: number) { // Survival is allowed so set them to survival player.runCommandAsync(`gamemode survival`); } - setScore(player, "gamemodevl", 1, true); - sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_C)§6.§4 VL= ${getScore("gamemodevl", player)}`); + ScoreManager.setScore(player, "gamemodevl", 1, true); + sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_C)§6.§4 VL= ${ScoreManager.getScore("gamemodevl", player)}`); } } diff --git a/src/penrose/TickEvent/gamemode/survival.ts b/src/penrose/TickEvent/gamemode/survival.ts index 97bf8e2..0d0f2ee 100644 --- a/src/penrose/TickEvent/gamemode/survival.ts +++ b/src/penrose/TickEvent/gamemode/survival.ts @@ -1,6 +1,7 @@ import { world, EntityQueryOptions, GameMode, system } from "@minecraft/server"; -import { getScore, sendMsg, setScore } from "../../../util.js"; +import { sendMsg } from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { ScoreManager } from "../../../classes/ScoreManager.js"; async function survival(id: number) { // Get Dynamic Property @@ -46,8 +47,8 @@ async function survival(id: number) { // Adventure is allowed so set them to adventure player.runCommandAsync(`gamemode a`); } - setScore(player, "gamemodevl", 1, true); - sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_S)§6.§4 VL= ${getScore("gamemodevl", player)}`); + ScoreManager.setScore(player, "gamemodevl", 1, true); + sendMsg("@a[tag=notify]", `§f§4[§6Paradox§4]§f ${player.name} §6has tried to change their gamemode §7(Gamemode_S)§6.§4 VL= ${ScoreManager.getScore("gamemodevl", player)}`); } } diff --git a/src/penrose/TickEvent/illegalitems/illegalitems_a.ts b/src/penrose/TickEvent/illegalitems/illegalitems_a.ts index 6eaf185..f334368 100644 --- a/src/penrose/TickEvent/illegalitems/illegalitems_a.ts +++ b/src/penrose/TickEvent/illegalitems/illegalitems_a.ts @@ -2,8 +2,9 @@ import { world, ItemStack, Player, EntityInventoryComponent, system, ItemEnchant import config from "../../../data/config.js"; import { illegalitems } from "../../../data/itemban.js"; import { kickablePlayers } from "../../../kickcheck.js"; -import { sendMsg, sendMsgToPlayer, titleCase } from "../../../util.js"; +import { sendMsg, sendMsgToPlayer } from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { StringTransformation } from "../../../classes/StringTransformation.js"; // Create a map of player objects and their enchantment presence const enchantmentPresenceMap = new Map>(); @@ -233,7 +234,7 @@ function illegalitemsa(id: number) { // Iterate over the unverifiedItemMap for (const [slot, itemStackData] of unverifiedItemMap.get(player.id)) { // Create a new name tag for the item - const newNameTag = titleCase(itemStackData.typeId.replace("minecraft:", "")); + const newNameTag = StringTransformation.titleCase(itemStackData.typeId.replace("minecraft:", "")); // Create a new ItemStack with the same type as the original item const applyCustomProperties = new ItemStack(itemStackData.typeId); // Get the original enchantment component from the item diff --git a/src/penrose/TickEvent/noperms/nopermission.ts b/src/penrose/TickEvent/noperms/nopermission.ts index 06cd8fd..a3f98ee 100644 --- a/src/penrose/TickEvent/noperms/nopermission.ts +++ b/src/penrose/TickEvent/noperms/nopermission.ts @@ -1,7 +1,8 @@ import { world, Player, EntityQueryOptions, system } from "@minecraft/server"; -import { crypto, sendMsg } from "../../../util.js"; +import { sendMsg } from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; import config from "../../../data/config.js"; +import { EncryptionManager } from "../../../classes/EncryptionManager.js"; function noperms() { const filter: EntityQueryOptions = { @@ -32,7 +33,7 @@ function noperms() { const key = config.encryption.password ? config.encryption.password : entity.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); entity.removeTag("paradoxOpped"); if (encode === hash) { entity.removeDynamicProperty("hash"); diff --git a/src/penrose/TickEvent/noperms/verifypermission.ts b/src/penrose/TickEvent/noperms/verifypermission.ts index ea6efcb..b339289 100644 --- a/src/penrose/TickEvent/noperms/verifypermission.ts +++ b/src/penrose/TickEvent/noperms/verifypermission.ts @@ -1,7 +1,8 @@ import { world, EntityQueryOptions, system } from "@minecraft/server"; import config from "../../../data/config.js"; -import { crypto, sendMsg } from "../../../util.js"; +import { sendMsg } from "../../../util.js"; import { dynamicPropertyRegistry } from "../../WorldInitializeAfterEvent/registry.js"; +import { EncryptionManager } from "../../../classes/EncryptionManager.js"; function verifypermission() { const filter: EntityQueryOptions = { @@ -28,7 +29,7 @@ function verifypermission() { const key = config.encryption.password ? config.encryption.password : player.id; // Generate the hash - const encode = crypto?.(salt, key); + const encode = EncryptionManager.hashWithSalt(salt as string, key); if (encode === hash) { // Make sure their unique ID exists in case of a reload if (dynamicPropertyRegistry.has(player.id) === false) { diff --git a/src/penrose/WorldInitializeAfterEvent/registry.ts b/src/penrose/WorldInitializeAfterEvent/registry.ts index 3821667..9d09062 100644 --- a/src/penrose/WorldInitializeAfterEvent/registry.ts +++ b/src/penrose/WorldInitializeAfterEvent/registry.ts @@ -1,6 +1,6 @@ import { world, DynamicPropertiesDefinition, MinecraftEntityTypes, WorldInitializeAfterEvent } from "@minecraft/server"; import config from "../../data/config.js"; -import { UUID } from "../../util.js"; +import { UUIDManager } from "../../classes/UUIDManager.js"; export const dynamicPropertyRegistry = new Map(); @@ -174,7 +174,7 @@ function registry(data: WorldInitializeAfterEvent) { */ const salt = world.getDynamicProperty("crypt"); if (salt === undefined) { - world.setDynamicProperty("crypt", UUID.generate()); + world.setDynamicProperty("crypt", UUIDManager.generateRandomUUID()); } }