Skip to content

Commit bb90333

Browse files
committed
Merge branch main into 95-automatic-invoice-notifications
2 parents 2d60eef + 768c980 commit bb90333

File tree

24 files changed

+1005
-269
lines changed

24 files changed

+1005
-269
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7+
day: "monday"
8+
time: "06:00"

.github/workflows/codeql.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ name: "CodeQL"
1414
on:
1515
push:
1616
branches: [ "master" ]
17+
paths-ignore:
18+
- '**/*.md'
19+
- '**/*.yml'
20+
- '**/*.xml'
1721
pull_request:
1822
# The branches below must be a subset of the branches above
1923
branches: [ "master" ]
24+
paths-ignore:
25+
- '**/*.md'
26+
- '**/*.yml'
27+
- '**/*.xml'
2028
schedule:
2129
- cron: '40 22 * * 2'
2230

@@ -51,7 +59,7 @@ jobs:
5159

5260
- uses: actions/setup-java@v3
5361
with:
54-
distribution: 'corretto'
62+
distribution: 'temurin'
5563
java-version: 17
5664

5765
# Initializes the CodeQL tools for scanning.

.github/workflows/maven.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
name: Java CI with Maven
1010

11+
permissions:
12+
contents: write
13+
1114
on:
1215
push:
1316
branches: [ "master" ]

README.md

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,81 @@
1-
[![Banner](https://i.ibb.co/2yFTQ8X/banner-optimised.png)](https://modrinth.com/plugin/Dc8RS2En/)
2-
31
# Bank Accounts
4-
[![Available on Modrinth](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/modrinth_vector.svg)](https://modrinth.com/plugin/Dc8RS2En)
5-
[![Available for Paper](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/paper_vector.svg)](https://papermc.io/software/paper)
6-
[![Available on GitHub](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/github_vector.svg)](https://github.com/cloudnode-pro/BankAccounts/)
2+
[![Available on Modrinth](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/modrinth_vector.svg)](https://modrinth.com/plugin/Dc8RS2En) [![Available for Paper](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/supported/paper_vector.svg)](https://papermc.io/software/paper) [![Available on GitHub](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact/available/github_vector.svg)](https://github.com/cloudnode-pro/BankAccounts/)
3+
4+
[![Java CI with Maven](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/maven.yml/badge.svg)](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/maven.yml) [![CodeQL](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/codeql.yml/badge.svg)](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/codeql.yml) [![Version](https://img.shields.io/modrinth/v/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/version/latest) [![Game Versions](https://img.shields.io/modrinth/game-versions/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/) [![Downloads](https://img.shields.io/modrinth/dt/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/)
5+
6+
A Minecraft economy plugin that enables players to hold multiple bank accounts.
7+
8+
[**`Download`**](https://modrinth.com/plugin/Dc8RS2En/version/latest)
9+
10+
## Features
11+
12+
See also: [Commands](https://github.com/cloudnode-pro/BankAccounts/wiki/Commands) · [Permissions](https://github.com/cloudnode-pro/BankAccounts/wiki/Permissions)
13+
14+
### Multiple Accounts/Balances
15+
Players can have multiple independent bank accounts. You can have both personal and business accounts.
16+
17+
### Transaction History
18+
See the history of your account’s transactions using the `/bank history` command.
19+
20+
### Payment Requests (Invoices)
21+
Request money from players and track the payment status.
22+
23+
### Vault Support
24+
25+
If [Vault](https://github.com/MilkBowl/Vault/releases/latest) is installed on your server,
26+
you can [enable its integration in the configuration](https://github.com/cloudnode-pro/BankAccounts/blob/dad253525b6bc3ee9647cd01c75e2c425a921f58/src/main/resources/config.yml#L38-L44).
27+
This allows BankAccounts to function as a Vault economy provider,
28+
enabling compatibility with third-party plugins that support Vault.
29+
30+
### POS and Bank Cards
31+
32+
You can create a [Point of Sale](https://github.com/cloudnode-pro/BankAccounts/wiki/POS), which is a type of single-use chest shop. Players can pay using a bank card (`/bank card`).
733

8-
[![CodeQL](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/codeql.yml/badge.svg)](https://github.com/cloudnode-pro/BankAccounts/actions/workflows/codeql.yml)
9-
[![Version](https://img.shields.io/modrinth/v/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/)
10-
[![Game Versions](https://img.shields.io/modrinth/game-versions/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/)
11-
[![Downloads](https://img.shields.io/modrinth/dt/Dc8RS2En)](https://modrinth.com/plugin/Dc8RS2En/)
34+
### Extensive Configuration
1235

13-
A multi-account economy plugin.
36+
All functionality is fully configurable. See [default config](https://github.com/cloudnode-pro/BankAccounts/blob/master/src/main/resources/config.yml).
1437

15-
[**`Features (Wiki)`**](https://github.com/cloudnode-pro/BankAccounts/wiki)
16-
· [**`Commands`**](https://github.com/cloudnode-pro/BankAccounts/wiki/Commands)
17-
· [**`Permissions`**](https://github.com/cloudnode-pro/BankAccounts/wiki/Permissions)
18-
· [**`Download`**](https://modrinth.com/plugin/Dc8RS2En/version/latest)
38+
## Support
39+
40+
| Matrix | [bankaccounts:cloudnode.pro](https://matrix.to/#/#bankaccounts:cloudnode.pro) |
41+
|--------|-------------------------------------------------------------------------------|
42+
43+
Join our dedicated BankAccounts community space on Matrix to engage in discussions, receive support, and stay updated on crucial plugin announcements.
44+
45+
If you want to report a problem or request a feature, please [submit a new issue](https://github.com/cloudnode-pro/BankAccounts/issues/new?labels=bug).
46+
47+
## Release Cycle
48+
49+
BankAccounts follows a weekly **time-based release schedule**, with new features or changes typically released every **Tuesday**.
50+
51+
When we merge critical bug fixes, we may publish out-of-band releases on any day of the week.
1952

2053
## Report Issues
21-
If you discover any issues with the plugin, please first check the [known issues](https://github.com/cloudnode-pro/BankAccounts/issues?q=is%3Aopen+is%3Aissue+label%3Abug). If it is not listed there, please [create a new issue](https://github.com/cloudnode-pro/BankAccounts/issues/new?labels=bug). Fixing bugs is the highest priority for this project.
54+
Please ensure that you are using the [latest version](https://modrinth.com/plugin/Dc8RS2En/version/latest) of BankAccounts. The newest bug fixes are only available in the most recent version, and support is provided exclusively for this version.
2255

23-
When reporting an issue, please include as much relevant information as possible, including error logs, screenshots, and steps to reproduce the issue.
56+
If you encounter any problems with the plugin, please first check the [list of known issues](https://github.com/cloudnode-pro/BankAccounts/issues?q=is%3Aopen+is%3Aissue+label%3Abug) on our GitHub repository. If you don’t find a similar fault listed there, we encourage you to [submit a new issue](https://github.com/cloudnode-pro/BankAccounts/issues/new?labels=bug). Resolving bugs is the highest priority for this project.
2457

25-
Please make sure you are using the latest version of BankAccounts.
58+
To help us resolve your issue as quickly as possible, please provide as much relevant information as possible, including error logs, screenshots, and detailed steps to reproduce the problem.
2659

27-
## Request Features
28-
If you would like to request a new feature, please [open a new issue](https://github.com/cloudnode-pro/BankAccounts/issues/new) and describe what you have in mind.
60+
## Feature Requests
2961

30-
Due to each player having multiple accounts, it is difficult to integrate this project with other plugins. BankAccounts provides replacements for some such functionalities.
62+
To suggest a new feature, please [create a new issue](https://github.com/cloudnode-pro/BankAccounts/issues/new), providing a detailed description of your idea.
3163

3264
## Contributing
33-
If you would like to contribute to the project, you can [fork the repository](https://github.com/cloudnode-pro/BankAccounts/fork) and create a pull request.
65+
66+
New contributors are most welcome to the project.
67+
68+
If you're interested in contributing, follow these steps:
69+
70+
1. [Fork the repository](https://github.com/cloudnode-pro/BankAccounts/fork)
71+
2. Create a new branch for your contributions.
72+
3. Make your changes and ensure they align with the project’s goals.
73+
4. Commit your changes with clear and descriptive messages.
74+
5. Push your changes to your fork.
75+
6. Submit a pull request.
76+
77+
## Thanks To
78+
79+
[<img src="https://github.com/JetBrains/logos/raw/master/web/jetbrains/jetbrains-simple.svg" alt="JetBrains logo." height="96">](https://www.jetbrains.com)
80+
81+
[JetBrains](https://www.jetbrains.com/), creators of the IntelliJ IDEA, supports BankAccounts with one of their [Open Source Licenses](https://www.jetbrains.com/opensource/). IntelliJ IDEA is the recommended IDE for working with BankAccounts.

pom.xml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<plugin>
2222
<groupId>org.apache.maven.plugins</groupId>
2323
<artifactId>maven-compiler-plugin</artifactId>
24-
<version>3.12.1</version>
24+
<version>3.13.0</version>
2525
<configuration>
2626
<source>${java.version}</source>
2727
<target>${java.version}</target>
@@ -30,7 +30,7 @@
3030
<plugin>
3131
<groupId>org.apache.maven.plugins</groupId>
3232
<artifactId>maven-shade-plugin</artifactId>
33-
<version>3.5.1</version>
33+
<version>3.6.0</version>
3434
<executions>
3535
<execution>
3636
<phase>package</phase>
@@ -65,6 +65,10 @@
6565
<id>placeholderapi</id>
6666
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
6767
</repository>
68+
<repository>
69+
<id>jitpack.io</id>
70+
<url>https://jitpack.io</url>
71+
</repository>
6872
</repositories>
6973

7074
<dependencies>
@@ -78,16 +82,24 @@
7882
<groupId>com.zaxxer</groupId>
7983
<artifactId>HikariCP</artifactId>
8084
<version>5.1.0</version>
85+
<scope>provided</scope>
8186
</dependency>
8287
<dependency>
8388
<groupId>org.mariadb.jdbc</groupId>
8489
<artifactId>mariadb-java-client</artifactId>
85-
<version>3.3.2</version>
90+
<version>3.4.1</version>
91+
<scope>provided</scope>
8692
</dependency>
8793
<dependency>
8894
<groupId>me.clip</groupId>
8995
<artifactId>placeholderapi</artifactId>
90-
<version>2.11.5</version>
96+
<version>2.11.6</version>
97+
<scope>provided</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>com.github.MilkBowl</groupId>
101+
<artifactId>VaultAPI</artifactId>
102+
<version>1.7.1</version>
91103
<scope>provided</scope>
92104
</dependency>
93105
</dependencies>

src/main/java/pro/cloudnode/smp/bankaccounts/Account.java

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.inventory.ItemStack;
1111
import org.bukkit.inventory.meta.ItemMeta;
1212
import org.bukkit.persistence.PersistentDataType;
13+
import org.jetbrains.annotations.ApiStatus;
1314
import org.jetbrains.annotations.NotNull;
1415

1516
import javax.annotation.Nullable;
@@ -106,7 +107,7 @@ public Account(final @NotNull ResultSet rs) throws @NotNull SQLException {
106107
}
107108

108109
public final @NotNull String name() {
109-
return this.name == null ? (this.type == Type.PERSONAL && this.owner.getName() != null ? this.owner.getName() : this.id) : this.name;
110+
return this.name == null ? (this.type == Type.VAULT && this.owner.getName() != null ? this.owner.getName() : this.id) : this.name;
110111
}
111112

112113
public final @NotNull Component ownerName() {
@@ -194,8 +195,19 @@ public static boolean isInstrument(final @NotNull ItemStack item) {
194195
/**
195196
* Get account by ID
196197
* @param id Account ID
198+
* @deprecated Use {@link #get(Account.Tag)}
197199
*/
200+
@Deprecated
198201
public static @NotNull Optional<@NotNull Account> get(final @NotNull String id) {
202+
return getByID(id);
203+
}
204+
205+
/**
206+
* Get account by ID
207+
* @param id Account ID
208+
*/
209+
@ApiStatus.Internal
210+
private static @NotNull Optional<@NotNull Account> getByID(final @NotNull String id) {
199211
try (final @NotNull Connection conn = BankAccounts.getInstance().getDb().getConnection();
200212
final @NotNull PreparedStatement stmt = conn.prepareStatement("SELECT * FROM `bank_accounts` WHERE `id` = ? LIMIT 1")) {
201213
stmt.setString(1, id);
@@ -208,6 +220,19 @@ public static boolean isInstrument(final @NotNull ItemStack item) {
208220
}
209221
}
210222

223+
/**
224+
* Get account by tag
225+
*/
226+
public static @NotNull Optional<@NotNull Account> get(final @NotNull Account.Tag tag) {
227+
return switch (tag.type) {
228+
case ID -> get(tag.value);
229+
case USERNAME -> {
230+
final @NotNull OfflinePlayer player = BankAccounts.getInstance().getServer().getOfflinePlayer(tag.value);
231+
yield getVaultAccount(player);
232+
}
233+
};
234+
}
235+
211236
/**
212237
* Get account from instrument
213238
* @param instrument Instrument item
@@ -267,6 +292,15 @@ public static boolean isInstrument(final @NotNull ItemStack item) {
267292
}
268293
}
269294

295+
/**
296+
* Get the Vault account of a player
297+
*/
298+
public static @NotNull Optional<@NotNull Account> getVaultAccount(final @NotNull OfflinePlayer player) {
299+
final @NotNull Account @NotNull [] accounts = get(player, Type.VAULT);
300+
if (accounts.length == 0) return Optional.empty();
301+
return Optional.of(accounts[0]);
302+
}
303+
270304
/**
271305
* Get accounts sorted by balance
272306
*
@@ -307,7 +341,6 @@ else if (limit != null) {
307341
* Get the server account
308342
*/
309343
public static @NotNull Optional<@NotNull Account> getServerAccount() {
310-
if (!BankAccounts.getInstance().config().serverAccountEnabled()) return Optional.empty();
311344
final @NotNull Account @NotNull [] accounts = get(BankAccounts.getConsoleOfflinePlayer());
312345
if (accounts.length == 0) return Optional.empty();
313346
return Optional.of(accounts[0]);
@@ -377,7 +410,11 @@ public enum Type {
377410
/**
378411
* Account owned by a company or other corporate entity
379412
*/
380-
BUSINESS;
413+
BUSINESS,
414+
/**
415+
* Vault integration account
416+
*/
417+
VAULT;
381418

382419
/**
383420
* Get type name (as set in config)
@@ -428,4 +465,55 @@ public void update() {}
428465
@Override
429466
public void delete() {}
430467
}
468+
469+
/**
470+
* An account tag is a unique pointer to a specific account.
471+
*/
472+
public record Tag(@NotNull Account.Tag.Type type, @NotNull String value) {
473+
/**
474+
* Create a new account ID tag
475+
* @param id Account ID
476+
*/
477+
public static @NotNull Tag id(final @NotNull String id) {
478+
return new Tag(Account.Tag.Type.ID, id);
479+
}
480+
481+
/**
482+
* Create a new Vault account tag by username
483+
* @param username Username of Vault account holder
484+
*/
485+
public static @NotNull Tag username(final @NotNull String username) {
486+
return new Tag(Account.Tag.Type.USERNAME, username);
487+
}
488+
489+
/**
490+
* Create account tag from string
491+
* @param string Use {@code @} prefix for Vault account owner username.
492+
*/
493+
public static @NotNull Tag from(final @NotNull String string) {
494+
if (string.startsWith("@")) return username(string.substring(1));
495+
return id(string);
496+
}
497+
498+
/**
499+
* Get the account that this tag points to
500+
*/
501+
public @NotNull Optional<@NotNull Account> get() {
502+
return Account.get(this);
503+
}
504+
505+
/**
506+
* Account tag type
507+
*/
508+
public enum Type {
509+
/**
510+
* Account by ID
511+
*/
512+
ID,
513+
/**
514+
* Vault account by username
515+
*/
516+
USERNAME
517+
}
518+
}
431519
}

0 commit comments

Comments
 (0)