Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Docs/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Commands available to all players by default.

### General

- **/team**
- Opens the team panel.
- _Chat Alias: `!team`_
- **/teamchat [message]**
- Toggles or sends a message in team chat.
- _Chat Alias: `!tc`_
- **/xhelp [command]**
- Shows a list of available commands or help for a specific command.
- _Chat Alias: `!help`_
Expand Down
13 changes: 12 additions & 1 deletion Docs/FeaturesOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,18 @@ This document provides a detailed breakdown of the features available in AddonEx
- **Server Rules Display:** Players can view server rules using the `/rules` command. The rules are defined as an array of strings in the configuration.
- _Key Configs: `config.js` (under the `playerInfo` and `serverInfo` sections)_

### I. Customizable Sound Events
### I. Team System

- **Description:** A comprehensive team system that allows players to form groups, chat privately, manage a shared balance, and set a team home.
- **Commands:** `/team` opens the main team UI, `/teamchat` (`/tc`) allows for private team communication.
- **Features:**
- Team creation (costs a configurable amount of money).
- Team members can deposit money into the team's shared balance.
- Admins/Owners can set a team home (`/setteamhome` via UI), teleport to it, or delete it.
- Support for joining through invites and join requests, which can be managed from the UI.
- Search for a specific team or browse available teams.

### J. Customizable Sound Events

- Customize sounds for specific in-game events to provide auditory feedback to players and admins.
- Events include:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "AddonExe",
"version": "0.7.0",
"private": true,
"description": "<p align=\"center\"> <!-- TODO: Add a cool project logo/banner here. Example: <img src=\"link_to_your_logo.png\" alt=\"AddonExe Logo\" width=\"200\"/> --> <h1 align=\"center\">AddonExe for Minecraft BE</h1> </p>",
"description": "<p align=\"center\"> <h1 align=\"center\">AddonExe for Minecraft BE</h1> </p>",
"keywords": [],
"homepage": "https://github.com/SjnExe/AddonExe#readme",
"bugs": {
Expand Down
22 changes: 22 additions & 0 deletions src/features/team/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,28 @@ export function updateTeamSetting(teamId: number, setting: string, value: boolea
return { success: false, message: 'Unknown setting.' };
}

export function depositToTeam(player: mc.Player, amount: number): ActionResult {
if (Number.isNaN(amount) || amount <= 0) {
return { success: false, message: '§cInvalid amount.' };
}

const team = getTeamByPlayer(player.id);
if (!isDefined(team)) {
return { success: false, message: '§cYou are not in a team.' };
}

const pData = getPlayer(player.id);
if (!isDefined(pData) || pData.balance < amount) {
return { success: false, message: '§cInsufficient funds.' };
}

incrementPlayerBalance(player.id, -amount);
team.balance += amount;
saveTeam(team.id);

return { success: true, message: `§aDeposited $${amount} to the team.` };
}

export function teleportToTeamHome(player: mc.Player): void {
const team = getTeamByPlayer(player.id);
if (!isDefined(team) || !isDefined(team.home)) {
Expand Down
33 changes: 28 additions & 5 deletions src/features/team/ui/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,25 @@ export class TeamPanelHandler implements IPanelHandler {
return;
}

// Search logic ignored for now
player.sendMessage('Search not implemented yet, showing browser.');
await showPanel(player, 'teamBrowserPanel', context);
const [teamName] = res.formValues as [string];
if (!isNonEmptyString(teamName)) {
player.sendMessage('§cTeam name required.');
await showPanel(player, 'teamSearchPanel', context);
return;
}

const allTeams = teamManager.getAllTeam();
const foundTeam = allTeams.find((t) => t.name.toLowerCase() === teamName.toLowerCase());

if (!foundTeam) {
player.sendMessage('§cTeam not found.');
await showPanel(player, 'teamBrowserPanel', context);
return;
}

const applyRes = teamManager.applyToTeam(player, foundTeam.id);
player.sendMessage(applyRes.message ?? (applyRes.success ? '§aApplication sent.' : '§cFailed to apply.'));
await showPanel(player, 'teamMainPanel', context);
return;
}

Expand All @@ -596,8 +612,15 @@ export class TeamPanelHandler implements IPanelHandler {

const [amountStr] = res.formValues as [string];
const amount = Number.parseFloat(amountStr);
// Implement deposit logic here or in manager
player.sendMessage(`Deposit logic for ${amount} pending implementation.`);

if (Number.isNaN(amount) || amount <= 0) {
player.sendMessage('§cInvalid amount.');
await showPanel(player, 'teamMainPanel', context);
return;
}

const depositRes = teamManager.depositToTeam(player, amount);
player.sendMessage(depositRes.message ?? (depositRes.success ? '§aDeposit successful.' : '§cDeposit failed.'));
await showPanel(player, 'teamMainPanel', context);
}
}
Expand Down