Skip to content

Commit bd429ce

Browse files
Fix unfinished codes, implement team logic and update docs (#1166)
- Removed unused TODO comment for banner from package.json description. - Implemented `depositToTeam` logic in the team feature. - Implemented exact-match searching logic in `teamSearchPanel`. - Updated `Commands.md` and `FeaturesOverview.md` to properly include team functionality and related commands. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 0776b34 commit bd429ce

5 files changed

Lines changed: 69 additions & 7 deletions

File tree

Docs/Commands.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Commands available to all players by default.
3838

3939
### General
4040

41+
- **/team**
42+
- Opens the team panel.
43+
- _Chat Alias: `!team`_
44+
- **/teamchat [message]**
45+
- Toggles or sends a message in team chat.
46+
- _Chat Alias: `!tc`_
4147
- **/xhelp [command]**
4248
- Shows a list of available commands or help for a specific command.
4349
- _Chat Alias: `!help`_

Docs/FeaturesOverview.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,18 @@ This document provides a detailed breakdown of the features available in AddonEx
133133
- **Server Rules Display:** Players can view server rules using the `/rules` command. The rules are defined as an array of strings in the configuration.
134134
- _Key Configs: `config.js` (under the `playerInfo` and `serverInfo` sections)_
135135

136-
### I. Customizable Sound Events
136+
### I. Team System
137+
138+
- **Description:** A comprehensive team system that allows players to form groups, chat privately, manage a shared balance, and set a team home.
139+
- **Commands:** `/team` opens the main team UI, `/teamchat` (`/tc`) allows for private team communication.
140+
- **Features:**
141+
- Team creation (costs a configurable amount of money).
142+
- Team members can deposit money into the team's shared balance.
143+
- Admins/Owners can set a team home (`/setteamhome` via UI), teleport to it, or delete it.
144+
- Support for joining through invites and join requests, which can be managed from the UI.
145+
- Search for a specific team or browse available teams.
146+
147+
### J. Customizable Sound Events
137148

138149
- Customize sounds for specific in-game events to provide auditory feedback to players and admins.
139150
- Events include:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "AddonExe",
33
"version": "0.7.0",
44
"private": true,
5-
"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>",
5+
"description": "<p align=\"center\"> <h1 align=\"center\">AddonExe for Minecraft BE</h1> </p>",
66
"keywords": [],
77
"homepage": "https://github.com/SjnExe/AddonExe#readme",
88
"bugs": {

src/features/team/manager.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,28 @@ export function updateTeamSetting(teamId: number, setting: string, value: boolea
579579
return { success: false, message: 'Unknown setting.' };
580580
}
581581

582+
export function depositToTeam(player: mc.Player, amount: number): ActionResult {
583+
if (Number.isNaN(amount) || amount <= 0) {
584+
return { success: false, message: '§cInvalid amount.' };
585+
}
586+
587+
const team = getTeamByPlayer(player.id);
588+
if (!isDefined(team)) {
589+
return { success: false, message: '§cYou are not in a team.' };
590+
}
591+
592+
const pData = getPlayer(player.id);
593+
if (!isDefined(pData) || pData.balance < amount) {
594+
return { success: false, message: '§cInsufficient funds.' };
595+
}
596+
597+
incrementPlayerBalance(player.id, -amount);
598+
team.balance += amount;
599+
saveTeam(team.id);
600+
601+
return { success: true, message: `§aDeposited $${amount} to the team.` };
602+
}
603+
582604
export function teleportToTeamHome(player: mc.Player): void {
583605
const team = getTeamByPlayer(player.id);
584606
if (!isDefined(team) || !isDefined(team.home)) {

src/features/team/ui/panel.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,25 @@ export class TeamPanelHandler implements IPanelHandler {
573573
return;
574574
}
575575

576-
// Search logic ignored for now
577-
player.sendMessage('Search not implemented yet, showing browser.');
578-
await showPanel(player, 'teamBrowserPanel', context);
576+
const [teamName] = res.formValues as [string];
577+
if (!isNonEmptyString(teamName)) {
578+
player.sendMessage('§cTeam name required.');
579+
await showPanel(player, 'teamSearchPanel', context);
580+
return;
581+
}
582+
583+
const allTeams = teamManager.getAllTeam();
584+
const foundTeam = allTeams.find((t) => t.name.toLowerCase() === teamName.toLowerCase());
585+
586+
if (!foundTeam) {
587+
player.sendMessage('§cTeam not found.');
588+
await showPanel(player, 'teamBrowserPanel', context);
589+
return;
590+
}
591+
592+
const applyRes = teamManager.applyToTeam(player, foundTeam.id);
593+
player.sendMessage(applyRes.message ?? (applyRes.success ? '§aApplication sent.' : '§cFailed to apply.'));
594+
await showPanel(player, 'teamMainPanel', context);
579595
return;
580596
}
581597

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

597613
const [amountStr] = res.formValues as [string];
598614
const amount = Number.parseFloat(amountStr);
599-
// Implement deposit logic here or in manager
600-
player.sendMessage(`Deposit logic for ${amount} pending implementation.`);
615+
616+
if (Number.isNaN(amount) || amount <= 0) {
617+
player.sendMessage('§cInvalid amount.');
618+
await showPanel(player, 'teamMainPanel', context);
619+
return;
620+
}
621+
622+
const depositRes = teamManager.depositToTeam(player, amount);
623+
player.sendMessage(depositRes.message ?? (depositRes.success ? '§aDeposit successful.' : '§cDeposit failed.'));
601624
await showPanel(player, 'teamMainPanel', context);
602625
}
603626
}

0 commit comments

Comments
 (0)