Skip to content

Commit f2cb7dc

Browse files
committed
v1.0.0 release
1 parent 760e4c2 commit f2cb7dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1939
-427
lines changed

src/main/java/t/me/p1azmer/plugin/protectionblocks/Perms.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ public class Perms {
1313
public static final JPermission COMMAND_EDITOR = new JPermission(PREFIX_COMMAND + "editor", "Access to the 'editor' sub-command.");
1414
public static final JPermission COMMAND_GIVE = new JPermission(PREFIX_COMMAND + "give", "Access to the 'give' sub-command.");
1515

16+
public static final JPermission COMMAND_DEPOSIT = new JPermission(PREFIX_COMMAND + "deposit", "Access to the 'deposit' sub-command.");
17+
public static final JPermission COMMAND_DEPOSIT_OTHER = new JPermission(PREFIX_COMMAND + "deposit.other", "Access to the 'deposit other' sub-command.");
18+
1619
static {
1720
PLUGIN.addChildren(COMMAND);
1821

19-
COMMAND.addChildren(COMMAND_RELOAD, COMMAND_EDITOR, COMMAND_GIVE);
22+
COMMAND.addChildren(COMMAND_RELOAD, COMMAND_EDITOR, COMMAND_GIVE,
23+
COMMAND_DEPOSIT, COMMAND_DEPOSIT_OTHER);
2024
}
2125
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/Placeholders.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,46 @@ public class Placeholders extends t.me.p1azmer.engine.utils.Placeholders {
44
public static final String WIKI_URL = "https://github.com/getplusm/ProtectionBlocks/wiki/";
55
public static final String WIKI_PLACEHOLDERS = "https://github.com/getplusm/ProtectionBlocks/wiki/Internal-Placeholders";
66

7+
public static final String GENERIC_NAME = "%name%";
8+
public static final String GENERIC_ITEM = "%item%";
9+
public static final String GENERIC_TOTAL = "%total%";
10+
public static final String GENERIC_LORE = "%lore%";
11+
public static final String GENERIC_AMOUNT = "%amount%";
12+
public static final String GENERIC_UNITS = "%units%";
13+
public static final String GENERIC_TYPE = "%type%";
14+
public static final String GENERIC_TIME = "%time%";
15+
public static final String GENERIC_PRICE = "%price%";
16+
public static final String GENERIC_BALANCE = "%balance%";
17+
18+
// currency
19+
20+
public static final String CURRENCY_NAME = "%currency_name%";
21+
public static final String CURRENCY_ID = "%currency_id%";
22+
23+
// region
724
public static final String REGION_ID = "%region_id%";
825
public static final String REGION_OWNER_NAME = "%region_owner_name%";
926
public static final String REGION_LOCATION = "%region_location%";
1027
public static final String REGION_HEALTH = "%region_health%";
28+
public static final String REGION_MEMBERS_AMOUNT = "%region_members_amount%";
29+
public static final String REGION_EXPIRE_IN = "%region_expire_in%";
30+
public static final String REGION_CREATION_TIME = "%region_creation_time%";
31+
32+
// members
33+
public static final String MEMBER_JOIN_TIME = "%member_join_time%";
34+
public static final String MEMBER_NAME = "%member_name%";
1135

1236
// region block
1337
public static final String REGION_BLOCK_ID = "%region_block_id%";
1438
public static final String REGION_BLOCK_NAME = "%region_block_name%";
1539
public static final String REGION_BLOCK_SIZE = "%region_block_size%";
1640
public static final String REGION_BLOCK_STRENGTH = "%region_block_strength%";
41+
public static final String REGION_BLOCK_DEPOSIT_PRICE = "%region_block_deposit_price%";
42+
public static final String REGION_BLOCK_DEPOSIT_CURRENCY = "%region_block_deposit_currency%";
43+
public static final String REGION_BLOCK_LIFE_TIME_ENABLED= "%region_block_life_time_enabled%";
1744
public static final String REGION_BLOCK_HOLOGRAM_TEMPLATE = "%region_block_hologram_template%";
1845
public static final String REGION_BLOCK_HOLOGRAM_ENABLED = "%region_block_hologram_enabled%";
19-
public static final String REGION_BLOCK_HOLOGRAM_IN_REGION = "%region_block_hologram_in_region";
46+
public static final String REGION_BLOCK_HOLOGRAM_IN_REGION = "%region_block_hologram_in_region%";
2047

2148
// region block breaker
2249
public static final String REGION_BLOCK_BREAKER_DMG_TYPE = "%region_block_breaker_damage_type%";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package t.me.p1azmer.plugin.protectionblocks;
22

3+
import org.jetbrains.annotations.NotNull;
4+
import t.me.p1azmer.plugin.protectionblocks.currency.CurrencyManager;
5+
36
public class ProtectionAPI {
47
public static final ProtectionPlugin PLUGIN = ProtectionPlugin.getPlugin(ProtectionPlugin.class);
8+
9+
@NotNull
10+
public static CurrencyManager getCurrencyManager() {
11+
return PLUGIN.getCurrencyManager();
12+
}
513
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/ProtectionPlugin.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import t.me.p1azmer.plugin.protectionblocks.commands.GiveCommand;
1212
import t.me.p1azmer.plugin.protectionblocks.config.Config;
1313
import t.me.p1azmer.plugin.protectionblocks.config.Lang;
14+
import t.me.p1azmer.plugin.protectionblocks.currency.CurrencyManager;
1415
import t.me.p1azmer.plugin.protectionblocks.editor.EditorLocales;
1516
import t.me.p1azmer.plugin.protectionblocks.integration.holograms.HologramDecentHandler;
1617
import t.me.p1azmer.plugin.protectionblocks.integration.holograms.HologramDisplaysHandler;
@@ -19,6 +20,7 @@
1920
public class ProtectionPlugin extends NexPlugin<ProtectionPlugin> {
2021
private RegionManager regionManager;
2122
private HologramHandler hologramHandler;
23+
private CurrencyManager currencyManager;
2224

2325
@Override
2426
protected @NotNull ProtectionPlugin getSelf() {
@@ -29,6 +31,9 @@ public class ProtectionPlugin extends NexPlugin<ProtectionPlugin> {
2931
public void enable() {
3032
this.setupHologramHandler();
3133

34+
this.currencyManager = new CurrencyManager(this);
35+
this.currencyManager.setup();
36+
3237
this.regionManager = new RegionManager(this);
3338
this.regionManager.setup();
3439
}
@@ -44,14 +49,20 @@ public void disable() {
4449
this.regionManager.shutdown();
4550
this.regionManager = null;
4651
}
52+
if (this.currencyManager != null){
53+
this.currencyManager.shutdown();
54+
this.currencyManager = null;
55+
}
4756
}
4857

4958
private void setupHologramHandler() {
5059
boolean hd = EngineUtils.hasPlugin("HolographicDisplays");
5160
if (hd) {
5261
this.hologramHandler = new HologramDisplaysHandler(this);
62+
this.hologramHandler.setup();
5363
} else if (EngineUtils.hasPlugin("DecentHolograms")) {
5464
this.hologramHandler = new HologramDecentHandler(this);
65+
this.hologramHandler.setup();
5566
}
5667

5768

@@ -101,4 +112,9 @@ public RegionManager getRegionManager() {
101112
public HologramHandler getHologramHandler() {
102113
return hologramHandler;
103114
}
115+
116+
@NotNull
117+
public CurrencyManager getCurrencyManager() {
118+
return currencyManager;
119+
}
104120
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/api/RegionBreaker.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
import t.me.p1azmer.plugin.protectionblocks.region.RegionManager;
1515

1616
public class RegionBreaker implements IPlaceholderMap {
17-
private final String id;
1817
private ItemStack item;
1918
private RegionManager.DamageType damageType;
2019

2120
private final PlaceholderMap placeholderMap;
2221

23-
public RegionBreaker(@NotNull String id, @NotNull ItemStack item, @NotNull RegionManager.DamageType damageType) {
24-
this.id = id;
22+
public RegionBreaker(@NotNull ItemStack item, @NotNull RegionManager.DamageType damageType) {
2523
this.item = item;
2624
this.damageType = damageType;
2725

@@ -42,16 +40,15 @@ public static RegionManager.DamageType foundDMGType(@NotNull Material material)
4240
return RegionManager.DamageType.HAND;
4341
}
4442

45-
public static RegionBreaker read(@NotNull JYML cfg, @NotNull String path, @NotNull String id) {
43+
public static RegionBreaker read(@NotNull JYML cfg, @NotNull String path) {
4644
ItemStack item = cfg.getItemEncoded(path + ".Item");
4745
if (item == null)
4846
item = new ItemStack(Material.BARRIER);
4947
RegionManager.DamageType damageType = cfg.getEnum(path + ".Damage_Type", RegionManager.DamageType.class, RegionManager.DamageType.HAND);
50-
return new RegionBreaker(id, item, damageType);
48+
return new RegionBreaker( item, damageType);
5149
}
5250

5351
public void write(@NotNull JYML cfg, @NotNull String path) {
54-
cfg.set(path + ".Id", this.getId());
5552
cfg.setItemEncoded(path + ".Item", this.getItem());
5653
cfg.set(path + ".Damage_Type", this.getDamageType());
5754
}
@@ -89,11 +86,6 @@ public boolean tryBreak(@NotNull RegionManager.DamageType damageType, @Nullable
8986
return false;
9087
}
9188

92-
@NotNull
93-
public String getId() {
94-
return id;
95-
}
96-
9789
@NotNull
9890
public ItemStack getItem() {
9991
return new ItemStack(item);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package t.me.p1azmer.plugin.protectionblocks.api.currency;
2+
3+
import org.bukkit.inventory.ItemStack;
4+
import org.jetbrains.annotations.NotNull;
5+
import org.jetbrains.annotations.Nullable;
6+
import t.me.p1azmer.engine.api.placeholder.IPlaceholderMap;
7+
import t.me.p1azmer.engine.utils.NumberUtil;
8+
import t.me.p1azmer.plugin.protectionblocks.Placeholders;
9+
10+
public interface Currency extends IPlaceholderMap {
11+
12+
@NotNull
13+
default String formatValue(double price) {
14+
return NumberUtil.format(price);
15+
}
16+
17+
@NotNull
18+
default String format(double price) {
19+
return this.replacePlaceholders().apply(this.getFormat())
20+
.replace(Placeholders.GENERIC_AMOUNT, this.formatValue(price))
21+
.replace(Placeholders.GENERIC_PRICE, this.formatValue(price));
22+
}
23+
24+
@Nullable
25+
default CurrencyOfflineHandler getOfflineHandler() {
26+
if (this instanceof CurrencyOfflineHandler handler) return handler;
27+
if (this.getHandler() instanceof CurrencyOfflineHandler handler) return handler;
28+
29+
return null;
30+
}
31+
32+
@NotNull CurrencyHandler getHandler();
33+
34+
@NotNull String getId();
35+
36+
@NotNull String getName();
37+
38+
@NotNull String getFormat();
39+
40+
@NotNull ItemStack getIcon();
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package t.me.p1azmer.plugin.protectionblocks.api.currency;
2+
3+
import org.bukkit.entity.Player;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
public interface CurrencyHandler {
7+
8+
double getBalance(@NotNull Player player);
9+
10+
void give(@NotNull Player player, double amount);
11+
12+
void take(@NotNull Player player, double amount);
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package t.me.p1azmer.plugin.protectionblocks.api.currency;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.util.UUID;
6+
7+
public interface CurrencyOfflineHandler {
8+
9+
double getBalance(@NotNull UUID playerId);
10+
11+
void give(@NotNull UUID playerId, double amount);
12+
13+
void take(@NotNull UUID playerId, double amount);
14+
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/api/events/BlockBreakRegionEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.entity.Player;
55
import org.jetbrains.annotations.NotNull;
66
import org.jetbrains.annotations.Nullable;
7-
import t.me.p1azmer.plugin.protectionblocks.region.Region;
7+
import t.me.p1azmer.plugin.protectionblocks.region.impl.Region;
88
import t.me.p1azmer.plugin.protectionblocks.region.RegionManager;
99

1010
import java.util.Optional;

src/main/java/t/me/p1azmer/plugin/protectionblocks/api/events/BlockPlaceRegionEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.bukkit.entity.Player;
55
import org.jetbrains.annotations.NotNull;
66
import org.jetbrains.annotations.Nullable;
7-
import t.me.p1azmer.plugin.protectionblocks.region.Region;
7+
import t.me.p1azmer.plugin.protectionblocks.region.impl.Region;
88

99

1010
public class BlockPlaceRegionEvent extends RegionEvent {

0 commit comments

Comments
 (0)