-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Paradox AntiCheat v5.1.0 with enhanced moderation tools
- Updated version to v5.1.0 in `manifest.json`, `package.json`, and `versioning.ts`. - Increased minimum Minecraft engine version to 1.21.50 and updated module dependencies to their latest beta versions. - Added a new `whitelist` command for managing player access, including add, remove, and list functionalities. - Enhanced `ban` command to integrate whitelist checks, preventing bans for whitelisted players. - Improved `player-spawn` listener: - Added whitelist validation to bypass local ban checks. - Adjusted ban logic for memory-tier-based disconnections. - Streamlined command parsing and error handling in moderation utilities. - Registered the `whitelist` command in `paradox.ts` to enable its functionality. This update strengthens player moderation while ensuring smoother integration with Minecraft's latest features.
- Loading branch information
1 parent
edaebda
commit 3a8e7aa
Showing
8 changed files
with
202 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Command } from "../../classes/command-handler"; | ||
import { ChatSendBeforeEvent } from "@minecraft/server"; | ||
import { MinecraftEnvironment } from "../../classes/container/dependencies"; | ||
|
||
// Define the whitelist command | ||
export const whitelistCommand: Command = { | ||
name: "whitelist", | ||
description: "Manage the whitelist by adding or removing a player, or list all whitelisted players.", | ||
usage: "{prefix}whitelist <add|remove|list> <player>", | ||
examples: [`{prefix}whitelist add Steve`, `{prefix}whitelist remove Steve`, `{prefix}whitelist list`], | ||
category: "Moderation", | ||
securityClearance: 3, | ||
|
||
/** | ||
* Executes the whitelist command. | ||
* @param {ChatSendBeforeEvent} message - The message object containing information about the command execution context. | ||
* @param {string[]} args - The command arguments, where the first element specifies the action and the second (optional) is the player name. | ||
* @param {MinecraftEnvironment} minecraftEnvironment - The Minecraft environment instance providing access to world and other utilities. | ||
* @returns {void} | ||
*/ | ||
execute: (message: ChatSendBeforeEvent, args: string[], minecraftEnvironment: MinecraftEnvironment): void => { | ||
const world = minecraftEnvironment.getWorld(); | ||
const dynamicProperty = "whitelistedPlayers"; | ||
|
||
// Retrieve the whitelist from dynamic properties and parse it | ||
const whitelistString = world.getDynamicProperty(dynamicProperty) as string; | ||
let whitelistedPlayers: string[]; | ||
|
||
try { | ||
whitelistedPlayers = whitelistString ? JSON.parse(whitelistString) : []; | ||
} catch (error) { | ||
message.sender.sendMessage("§cFailed to retrieve the whitelist. Please contact an admin."); | ||
console.error("Error parsing whitelist:", error); | ||
return; | ||
} | ||
|
||
// Validate the command arguments | ||
const action = args.shift()?.toLowerCase(); | ||
if (!["add", "remove", "list"].includes(action)) { | ||
message.sender.sendMessage("§cInvalid action. Use `add`, `remove`, or `list`."); | ||
return; | ||
} | ||
|
||
// Handle listing all whitelisted players | ||
if (action === "list") { | ||
if (whitelistedPlayers.length === 0) { | ||
message.sender.sendMessage("§2[§7Paradox§2]§o§7 No players are currently whitelisted."); | ||
} else { | ||
message.sender.sendMessage("\n§2[§7Paradox§2]§o§7 Whitelisted Players:"); | ||
whitelistedPlayers.forEach((player) => { | ||
message.sender.sendMessage(` §o§7| [§f${player}§7]`); | ||
}); | ||
} | ||
return; | ||
} | ||
|
||
// Extract player name for add/remove actions | ||
const playerName = args.join(" ").trim().replace(/["@]/g, ""); | ||
if (!playerName) { | ||
message.sender.sendMessage("§cPlease provide a valid player name."); | ||
return; | ||
} | ||
|
||
// Handle adding a player to the whitelist | ||
if (action === "add") { | ||
if (whitelistedPlayers.includes(playerName)) { | ||
message.sender.sendMessage(`§cPlayer "${playerName}" is already in the whitelist.`); | ||
return; | ||
} | ||
|
||
whitelistedPlayers.push(playerName); | ||
world.setDynamicProperty(dynamicProperty, JSON.stringify(whitelistedPlayers)); | ||
message.sender.sendMessage(`§2[§7Paradox§2]§o§7 Player "${playerName}" has been added to the whitelist.`); | ||
} | ||
|
||
// Handle removing a player from the whitelist | ||
if (action === "remove") { | ||
if (!whitelistedPlayers.includes(playerName)) { | ||
message.sender.sendMessage(`§cPlayer "${playerName}" is not in the whitelist.`); | ||
return; | ||
} | ||
|
||
whitelistedPlayers = whitelistedPlayers.filter((player) => player !== playerName); | ||
world.setDynamicProperty(dynamicProperty, JSON.stringify(whitelistedPlayers)); | ||
message.sender.sendMessage(`§2[§7Paradox§2]§o§7 Player "${playerName}" has been removed from the whitelist.`); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const paradoxVersion = "v5.0.3"; | ||
export const paradoxVersion = "v5.1.0"; |
Oops, something went wrong.