Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.8.0 #52

Merged
merged 20 commits into from
Oct 5, 2024
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
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.DS_Store
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 16
uses: actions/setup-java@v2
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'
- name: Cache SonarCloud packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand All @@ -37,7 +37,7 @@ jobs:
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
- run: mkdir staging && cp target/*.jar staging
- name: Save artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Package
path: staging
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Created and maintained by [tastybento](https://github.com/tastybento).

Each island has a bank account. Players can deposit or withdraw money from their regular economy accounts into the island account where it is pooled. The island owner can decide which rank of team member can access the account via the settings menu. There is a `baltop` command that players can use to see which island has the most, or least money.

<img src=https://github.com/BentoBoxWorld/Bank/assets/4407265/b496e8d1-6342-4c70-86a2-49f203a7ce93 width="400">

### Features

* Save or spend money as an island team
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<spigot.version>1.20.6-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.5.4</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.7.1</build.version>
<build.version>1.8.0</build.version>
<sonar.projectKey>BentoBoxWorld_Bank</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/world/bentobox/bank/BankPladdon.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
*
*/
public class BankPladdon extends Pladdon {
private Addon addon;

@Override
public Addon getAddon() {
return new Bank();
if (addon == null) {
addon = new Bank();
}
return addon;
}

}
6 changes: 6 additions & 0 deletions src/main/java/world/bentobox/bank/data/BankAccounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ public class BankAccounts implements DataObject {
@Expose
private Double balance;

/**
* The balance in {@link Money}
*/
@Expose
private Money moneyBalance;

@Expose
private final Map<Long, String> history = new TreeMap<>();

/**
* Timestamp for when interest was last paid
*/
@Expose
private Long interestLastPaid;

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bank:
description: déposer le montant sur votre compte insulaire
parameters: "<montant>"
success: "&a Succès! Le nouveau solde bancaire de votre île est de [number]."
alert: "&a [name] a déposé [number] à la banque de l'île."
errors:
bank-error: "&c Erreur lors du chargement des informations du compte bancaire
- veuillez réessayer plus tard"
Expand Down Expand Up @@ -70,6 +71,7 @@ bank:
description: retirer le montant de votre compte insulaire
parameters: "<montant>"
success: "&a Succès! Le nouveau solde bancaire de votre île est de [number]."
alert: "&a [name] a retiré [number] de la banque de l'île."
protection:
flags:
BANK_ACCESS:
Expand Down
81 changes: 81 additions & 0 deletions src/main/resources/locales/it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
bank:
admin:
description: comando di amministrazione per la banca dell'isola
give:
parameters: "<giocatore> <importo>"
description: aggiungi importo al conto dell'isola del giocatore
success: "&aFatto! Il saldo bancario dell'isola di [nome] è ora [numero]."
take:
parameters: "<giocatore> <importo>"
description: preleva l'importo dal conto dell'isola del giocatore
balance:
parameters: "<giocatore>"
description: visualizzare il saldo del conto dell'isola del giocatore
set:
parameters: "<giocatore> <importo>"
description: imposta l'importo nel conto dell'isola del giocatore
success: "&aIl bilancio di [name] è stato impostato su [number]."
statement:
parameters: "<giocatore>"
description: visualizza l'estratto conto dell'isola per il giocatore
balance:
description: mostra il bilancio della tua isola
island-balance: "&aIl bilancio dell'isola è [number]."
baltop:
description: mostra la classifica dei bilanci
description-syntax: "&d [number]"
highest: Ordina per più alto
lowest: Ordina per più basso
name-syntax: "&d [name]"
title: I bilanci più alti
deposit:
description: deposita l'importo nella banca dell'isola
parameters: "<importo>"
success: "&Fatto! Il tuo nuovo saldo bancario sull'isola è [number]."
alert: "&a[name] ha depositato [number] nella banca dell'isola."
errors:
bank-error: "&c Errore durante il caricamento dei dati del conto bancario: riprova
più tardi"
low-balance: "&c Il saldo della tua isola non è abbastanza alto!"
too-low: "&c Il saldo dell'isola è troppo basso."
must-be-a-number: "&c L'importo deve essere un numero"
no-rank: "&c Il tuo grado non è sufficientemente alto per utilizzare la banca."
too-much: "&c Non hai quell'importo da depositare."
value-must-be-positive: "&c L'importo deve essere positivo."
scientific: "&c La notazione scientifica non è supportata."
too-long: "&c Il valore deve essere inferiore a 10 cifre"
statement:
balance:
name: "&9 Saldo:"
description: "&6 [number]"
deposit: Deposito
description: mostra la cronologia della banca della tua isola
give: Regalo amministratore
interest: Interesse
latest: Ordina per più recente
oldest: Ordina per più vecchio
set: Impostazione amministratore
syntax: |
&9 [date]
&9 [time]
&7 [name]
&6 [number]
take: Presa amministrativa
title: Cronologia del conto
unknown: Tipo sconosciuto
withdrawal: Ritiro
user:
description: comando della banca dell'isola
withdraw:
description: prelevare l'importo dal conto dell'isola
parameters: "<importo>"
success: "&Fatto! Il tuo nuovo saldo bancario sull'isola è [number]."
alert: "&un [name] ritirò [number] dalla banca dell'isola."
protection:
flags:
BANK_ACCESS:
description: |-
&f Consenti accesso a
&f la banca dell'isola
name: Accesso alla banca dell'isola
42 changes: 22 additions & 20 deletions src/main/resources/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
---
bank:
admin:
description: 岛岸管理员命令
description: 岛屿银行管理员命令
give:
parameters: "<玩家> <金额>"
description: 增加金额到玩家的岛屿账户
success: "&a成功! [name] 的岛屿银行余额现在是 [number]"
description: 向玩家的空岛银行增加金钱
success: "&a成功! [name] 的岛屿银行余额现在是 [number]"
take:
parameters: "<玩家> <金额>"
description: 从玩家的岛屿账户中提取金额
description: 从玩家的岛屿账户中取出金钱
balance:
parameters: "<玩家>"
description: 查看玩家的岛屿账户余额
set:
parameters: "<玩家> <金额>"
description: 在玩家的岛屿账户中设置金额
success: "&a [name]的帐户设置为[number]"
description: 设置玩家岛屿账户的金额
success: "&a [name] 的帐户金额设置为[number]"
statement:
parameters: "<玩家>"
description: 查看玩家的岛上银行对帐单
description: 查看玩家的岛上银行帐单
balance:
description: 显示您的岛屿银行余额
island-balance: "&a岛银行的余额为[number]。"
baltop:
description: 显示余额排名
description-syntax: "&d[number]"
highest: 按最高排序
lowest: 最低排序
highest: 降序排序
lowest: 升序排序
name-syntax: "&d[name]"
title: 最高余额
deposit:
description: 将金额存入您的岛屿账户
parameters: "<金额>"
success: "&成功!您的新岛银行余额为[number]。"
alert: "&a [name]向岛屿银行存入了[number]。"
errors:
bank-error: "&c加载银行帐户信息时出错-请稍后重试"
low-balance: "&c您的岛屿银行余额不够高!"
too-low: "&c 岛平衡太低。"
low-balance: "&c您的岛屿银行余额不足!"
too-low: "&c 空岛余额太少"
must-be-a-number: "&c金额必须是数字"
no-rank: "&c您的等级不够高,无法使用银行。"
too-much: "&c您没有那笔存款。"
value-must-be-positive: "&c金额必须为正。"
too-much: "&c您没有足够的钱来存入。"
value-must-be-positive: "&c金额必须为正数。"
scientific: "&c 不支持科学记数法。"
too-long: "&c 值必须小于 10 位"
statement:
balance:
name: "&9 银行存款余额:"
description: "&6 [number]"
deposit: 存款
deposit: 存入
description: 显示您的岛屿银行历史
give: 管理员给
give: 管理员给予
interest: 银行利息
latest: 按最新排序
oldest: 按最旧排序
set: 管理员集
set: 管理员设置
syntax: "&9 [date] \n&9 [time] \n&7 [name]\n &6 [number]"
take: 管理员请
take: 管理员拿走
title: 账户历史
unknown: 未知类型
withdrawal: 退出
withdrawal: 取出
user:
description: 岛屿银行命令
withdraw:
description: 从您的岛屿账户中提款
parameters: "<金额>"
success: "&a成功!您的新岛银行余额为[number]。"
alert: "&a [name]从岛屿银行取出了[number]。"
protection:
flags:
BANK_ACCESS:
description: "&f允许进入岛岸"
name: 岛银行访问
description: "&f允许使用空岛银行"
name: 空岛银行权限
3 changes: 2 additions & 1 deletion src/test/java/world/bentobox/bank/BankManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class, DatabaseSetup.class, Util.class})
@PrepareForTest({ Bukkit.class, BentoBox.class, DatabaseSetup.class, Util.class, IslandsManager.class })
public class BankManagerTest {

@Mock
Expand Down Expand Up @@ -105,6 +105,7 @@ public void setUp() {
Whitebox.setInternalState(BentoBox.class, "instance", plugin);

PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
// The database type has to be created one line before the thenReturn() to work!
DatabaseType value = DatabaseType.JSON;
when(plugin.getSettings()).thenReturn(pluginSettings);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/world/bentobox/bank/BankTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

@SuppressWarnings("deprecation")
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class, User.class})
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, IslandsManager.class })
public class BankTest {

private static File jFile;
Expand Down Expand Up @@ -135,6 +135,8 @@ public static void beforeClass() throws IOException {

@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
// Set up plugin
Whitebox.setInternalState(BentoBox.class, "instance", plugin);

Expand Down Expand Up @@ -169,7 +171,6 @@ public void setUp() throws Exception {
when(user.getTranslation(anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));

// Server
PowerMockito.mockStatic(Bukkit.class);
Server server = mock(Server.class);
when(Bukkit.getServer()).thenReturn(server);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
Expand Down Expand Up @@ -204,7 +205,6 @@ public void setUp() throws Exception {


// Bukkit
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
when(Bukkit.getScheduler()).thenReturn(scheduler);
ItemMeta meta = mock(ItemMeta.class);
ItemFactory itemFactory = mock(ItemFactory.class);
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/world/bentobox/bank/PhManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

Expand All @@ -33,6 +35,7 @@
import world.bentobox.bentobox.api.addons.AddonDescription;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.managers.IslandsManager;
Expand All @@ -44,7 +47,7 @@
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class})
@PrepareForTest({ Bukkit.class, BentoBox.class, DatabaseSetup.class, IslandsManager.class })
public class PhManagerTest {

// Class under test
Expand Down Expand Up @@ -73,12 +76,11 @@ public class PhManagerTest {
@Mock
private PlayersManager plm;


/**
*/
@Before
public void setUp() {

PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);

AddonDescription desc = new AddonDescription.Builder("main", "AcidIsland", "1.0.2").build();
when(gm.getDescription()).thenReturn(desc);
when(addon.getPlugin()).thenReturn(plugin);
Expand All @@ -91,6 +93,7 @@ public void setUp() {
when(addon.getVault()).thenReturn(vh);
when(addon.getIslands()).thenReturn(im);
when(user.getLocation()).thenReturn(location);

when(im.getIslandAt(eq(location))).thenReturn(Optional.of(island));
when(bm.getBalance(eq(island))).thenReturn(new Money(1234.56D));
map = new LinkedHashMap<>();
Expand Down
Loading
Loading