Skip to content

Commit 6dbed12

Browse files
author
Jan Kluka
committed
1.2
Updated currency api + multipliers api
1 parent 21ee098 commit 6dbed12

4 files changed

Lines changed: 25 additions & 60 deletions

File tree

src/main/java/dev/drawethree/xprison/api/currency/model/XPrisonCurrency.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ public interface XPrisonCurrency {
2424
*/
2525
double getStartingAmount();
2626

27+
/**
28+
* Gets the maximum amount of a currency player can have
29+
*
30+
* @return maximum amount (cap) of a currency for player
31+
*/
32+
double getMaxAmount();
33+
2734
/**
2835
* Gets the display name of the currency (e.g., "Money", "Tokens").
2936
*
Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.drawethree.xprison.api.multipliers;
22

3+
import dev.drawethree.xprison.api.currency.model.XPrisonCurrency;
34
import dev.drawethree.xprison.api.multipliers.model.Multiplier;
4-
import dev.drawethree.xprison.api.multipliers.model.MultiplierType;
55
import dev.drawethree.xprison.api.multipliers.model.PlayerMultiplier;
66
import org.bukkit.entity.Player;
77

@@ -11,61 +11,34 @@
1111
public interface XPrisonMultipliersAPI {
1212

1313
/**
14-
* Gets the current global sell multiplier.
14+
* Gets the global multiplier for currency
1515
*
1616
* @return the global sell {@link Multiplier}
1717
*/
18-
Multiplier getGlobalSellMultiplier();
19-
20-
/**
21-
* Gets the current global token multiplier.
22-
*
23-
* @return the global token {@link Multiplier}
24-
*/
25-
Multiplier getGlobalTokenMultiplier();
18+
Multiplier getGlobalMultiplier(XPrisonCurrency currency);
2619

2720
/**
2821
* Gets the player's sell multiplier.
2922
*
3023
* @param p the player
3124
* @return the {@link PlayerMultiplier} for selling
3225
*/
33-
PlayerMultiplier getSellMultiplier(Player p);
34-
35-
/**
36-
* Gets the player's token multiplier.
37-
*
38-
* @param p the player
39-
* @return the {@link PlayerMultiplier} for tokens
40-
*/
41-
PlayerMultiplier getTokenMultiplier(Player p);
26+
PlayerMultiplier getPlayerMultiplier(Player p, XPrisonCurrency currency);
4227

43-
/**
44-
* Gets the player's rank multiplier.
45-
*
46-
* @param p the player
47-
* @return the {@link PlayerMultiplier} for the player's rank
48-
*/
49-
PlayerMultiplier getRankMultiplier(Player p);
50-
51-
/**
52-
* Gets the overall multiplier for a player based on the specified multiplier type.
53-
*
54-
* @param p the player
55-
* @param multiplierType the type of multiplier (SELL / TOKENS)
56-
* @return the overall multiplier as a double
57-
*/
58-
double getPlayerMultiplier(Player p, MultiplierType multiplierType);
5928

6029
/**
6130
* Calculates the total amount to deposit after applying the player's multiplier.
6231
*
6332
* @param p the player
6433
* @param deposit the original amount to deposit
65-
* @param type the multiplier type (tokens or money)
34+
* @param currency the currency affected
6635
* @return the new amount to deposit after applying multiplier
6736
*/
68-
default double getTotalToDeposit(Player p, double deposit, MultiplierType type) {
69-
return deposit * (1.0 + this.getPlayerMultiplier(p, type));
37+
default double getTotalToDeposit(Player p, double deposit, XPrisonCurrency currency) {
38+
PlayerMultiplier multiplier = this.getPlayerMultiplier(p, currency);
39+
if (multiplier == null) {
40+
return deposit;
41+
}
42+
return deposit * (1.0 + multiplier.getMultiplier());
7043
}
7144
}

src/main/java/dev/drawethree/xprison/api/multipliers/events/PlayerMultiplierReceiveEvent.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.drawethree.xprison.api.multipliers.events;
22

3-
import dev.drawethree.xprison.api.multipliers.model.MultiplierType;
3+
import dev.drawethree.xprison.api.currency.model.XPrisonCurrency;
44
import dev.drawethree.xprison.api.shared.events.player.XPrisonPlayerEvent;
55
import lombok.Getter;
66
import org.bukkit.entity.Player;
@@ -17,13 +17,14 @@ public final class PlayerMultiplierReceiveEvent extends XPrisonPlayerEvent {
1717

1818
private static final HandlerList handlers = new HandlerList();
1919

20+
private final XPrisonCurrency currency;
21+
2022
private final double multiplier;
2123

2224
private final TimeUnit timeUnit;
2325

2426
private final long duration;
2527

26-
private final MultiplierType type;
2728

2829
/**
2930
* Constructs a new PlayerMultiplierReceiveEvent.
@@ -32,14 +33,14 @@ public final class PlayerMultiplierReceiveEvent extends XPrisonPlayerEvent {
3233
* @param multiplier the multiplier value
3334
* @param timeUnit the unit of time for the multiplier duration
3435
* @param duration the duration of the multiplier
35-
* @param type the type of multiplier (e.g., SELL, TOKENS)
36+
* @param currency the currency affected
3637
*/
37-
public PlayerMultiplierReceiveEvent(Player player, double multiplier, TimeUnit timeUnit, long duration, MultiplierType type) {
38+
public PlayerMultiplierReceiveEvent(Player player, XPrisonCurrency currency, double multiplier, TimeUnit timeUnit, long duration) {
3839
super(player);
39-
this.multiplier = multiplier;
40+
this.currency = currency;
41+
this.multiplier = multiplier;
4042
this.timeUnit = timeUnit;
4143
this.duration = duration;
42-
this.type = type;
4344
}
4445

4546
/**

src/main/java/dev/drawethree/xprison/api/multipliers/model/MultiplierType.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)