Skip to content

Commit ea0a316

Browse files
committed
v1.0.5
1 parent 93fe071 commit ea0a316

File tree

18 files changed

+490
-147
lines changed

18 files changed

+490
-147
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = 'plazmer'
6-
version = '1.0.4'
6+
version = '1.0.5'
77

88
repositories {
99
mavenCentral()
@@ -36,7 +36,7 @@ dependencies {
3636
// PAPI
3737
compileOnly 'me.clip:placeholderapi:2.10.10'
3838
// Engine
39-
compileOnly 'com.github.getplusm:Engine:2.4.3'
39+
compileOnly 'com.github.getplusm:Engine:2.4.4'
4040
compileOnly files('D:/eclipse work/plazmer-engine-coins/build/libs/CoinsEngine-1.0.0.jar')
4141
}
4242

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ 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%";
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%";
1717

1818
// currency
1919

2020
public static final String CURRENCY_NAME = "%currency_name%";
21-
public static final String CURRENCY_ID = "%currency_id%";
21+
public static final String CURRENCY_ID = "%currency_id%";
2222

2323
// region
2424
public static final String REGION_ID = "%region_id%";
@@ -28,6 +28,7 @@ public class Placeholders extends t.me.p1azmer.engine.utils.Placeholders {
2828
public static final String REGION_MEMBERS_AMOUNT = "%region_members_amount%";
2929
public static final String REGION_EXPIRE_IN = "%region_expire_in%";
3030
public static final String REGION_CREATION_TIME = "%region_creation_time%";
31+
public static final String REGION_SIZE = "%region_size%";
3132

3233
// members
3334
public static final String MEMBER_JOIN_TIME = "%member_join_time%";
@@ -40,7 +41,9 @@ public class Placeholders extends t.me.p1azmer.engine.utils.Placeholders {
4041
public static final String REGION_BLOCK_STRENGTH = "%region_block_strength%";
4142
public static final String REGION_BLOCK_DEPOSIT_PRICE = "%region_block_deposit_price%";
4243
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%";
44+
public static final String REGION_BLOCK_LIFE_TIME_ENABLED = "%region_block_life_time_enabled%";
45+
public static final String REGION_BLOCK_PLACE_LIMIT_ENABLED = "%region_block_place_limit_enabled%";
46+
public static final String REGION_BLOCK_GROUP_SIZE_ENABLED = "%region_block_group_size_enabled%";
4447
public static final String REGION_BLOCK_HOLOGRAM_TEMPLATE = "%region_block_hologram_template%";
4548
public static final String REGION_BLOCK_HOLOGRAM_ENABLED = "%region_block_hologram_enabled%";
4649
public static final String REGION_BLOCK_HOLOGRAM_IN_REGION = "%region_block_hologram_in_region%";

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.jetbrains.annotations.Nullable;
55
import t.me.p1azmer.engine.NexPlugin;
66
import t.me.p1azmer.engine.api.command.GeneralCommand;
7+
import t.me.p1azmer.engine.api.data.UserDataHolder;
78
import t.me.p1azmer.engine.command.list.ReloadSubCommand;
89
import t.me.p1azmer.engine.utils.EngineUtils;
910
import t.me.p1azmer.plugin.protectionblocks.api.integration.HologramHandler;
@@ -12,12 +13,19 @@
1213
import t.me.p1azmer.plugin.protectionblocks.config.Config;
1314
import t.me.p1azmer.plugin.protectionblocks.config.Lang;
1415
import t.me.p1azmer.plugin.protectionblocks.currency.CurrencyManager;
16+
import t.me.p1azmer.plugin.protectionblocks.data.DataHandler;
17+
import t.me.p1azmer.plugin.protectionblocks.data.UserManager;
18+
import t.me.p1azmer.plugin.protectionblocks.data.impl.RegionUser;
1519
import t.me.p1azmer.plugin.protectionblocks.editor.EditorLocales;
1620
import t.me.p1azmer.plugin.protectionblocks.integration.holograms.HologramDecentHandler;
1721
import t.me.p1azmer.plugin.protectionblocks.integration.holograms.HologramDisplaysHandler;
1822
import t.me.p1azmer.plugin.protectionblocks.region.RegionManager;
1923

20-
public class ProtectionPlugin extends NexPlugin<ProtectionPlugin> {
24+
public class ProtectionPlugin extends NexPlugin<ProtectionPlugin> implements UserDataHolder<ProtectionPlugin, RegionUser> {
25+
private DataHandler userData;
26+
private UserManager userManager;
27+
28+
2129
private RegionManager regionManager;
2230
private HologramHandler hologramHandler;
2331
private CurrencyManager currencyManager;
@@ -103,6 +111,28 @@ public void registerPermissions() {
103111
this.registerPermissions(Perms.class);
104112
}
105113

114+
@Override
115+
public boolean setupDataHandlers() {
116+
this.userData = DataHandler.getInstance(this);
117+
this.userData.setup();
118+
119+
this.userManager = new UserManager(this);
120+
this.userManager.setup();
121+
return true;
122+
}
123+
124+
@Override
125+
@NotNull
126+
public DataHandler getData() {
127+
return this.userData;
128+
}
129+
130+
@NotNull
131+
@Override
132+
public UserManager getUserManager() {
133+
return userManager;
134+
}
135+
106136
@NotNull
107137
public RegionManager getRegionManager() {
108138
return regionManager;

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package t.me.p1azmer.plugin.protectionblocks.api;
22

33
import org.bukkit.Material;
4-
import org.bukkit.block.Block;
5-
import org.bukkit.entity.FallingBlock;
64
import org.bukkit.inventory.ItemStack;
75
import org.jetbrains.annotations.NotNull;
86
import org.jetbrains.annotations.Nullable;
@@ -33,10 +31,6 @@ public static RegionManager.DamageType foundDMGType(@NotNull Material material)
3331
return RegionManager.DamageType.EXPLODE;
3432
if (material.isItem())
3533
return RegionManager.DamageType.TOOLS;
36-
if (material.isBlock())
37-
return RegionManager.DamageType.BLOCK_PLACE;
38-
if (material.isCollidable())
39-
return RegionManager.DamageType.FALLING_BLOCK;
4034
return RegionManager.DamageType.HAND;
4135
}
4236

@@ -45,7 +39,7 @@ public static RegionBreaker read(@NotNull JYML cfg, @NotNull String path) {
4539
if (item == null)
4640
item = new ItemStack(Material.BARRIER);
4741
RegionManager.DamageType damageType = cfg.getEnum(path + ".Damage_Type", RegionManager.DamageType.class, RegionManager.DamageType.HAND);
48-
return new RegionBreaker( item, damageType);
42+
return new RegionBreaker(item, damageType);
4943
}
5044

5145
public void write(@NotNull JYML cfg, @NotNull String path) {
@@ -66,20 +60,8 @@ public boolean tryBreak(@NotNull RegionManager.DamageType damageType, @Nullable
6660
}
6761
return false;
6862
}
69-
case BLOCK_PLACE -> {
70-
if (blockOrItem == null) return false;
71-
if (blockOrItem instanceof Block block && block.getType().isBlock()) {
72-
return this.getItem().getType().equals(block.getType());
73-
}
74-
}
75-
case FALLING_BLOCK -> {
76-
if (blockOrItem == null) return false;
77-
if (blockOrItem instanceof FallingBlock fallingBlock) {
78-
return fallingBlock.getBlockState().getType().equals(this.getItem().getType());
79-
}
80-
}
8163
case EXPLODE -> {
82-
return this.getItem().getType().equals(Material.TNT) || this.getItem().getType().equals(Material.TNT_MINECART);
64+
return this.getItem().getType().equals(Material.TNT) || this.getItem().getType().equals(Material.TNT_MINECART) || this.getItem().getType().equals(Material.CREEPER_SPAWN_EGG);
8365
}
8466
}
8567
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/config/Lang.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@
99
public class Lang extends EngineLang {
1010
public static final LangKey COMMAND_EDITOR_DESC = LangKey.of("Command.Editor.Desc", "Open the region editor.");
1111

12-
public static final LangKey COMMAND_GIVE_DESC = LangKey.of("Command.Give.Desc", "Give specified region block to a player.");
12+
public static final LangKey COMMAND_GIVE_DESC = LangKey.of("Command.Give.Desc", "Give specified region block to a player.");
1313
public static final LangKey COMMAND_GIVE_USAGE = LangKey.of("Command.Give.Usage", "<region block> <player> <amount>");
14-
public static final LangKey COMMAND_GIVE_DONE = LangKey.of("Command.Give.Done", "Given &ax%amount% %region_block_name%&7 to &a%player_name%&7.");
14+
public static final LangKey COMMAND_GIVE_DONE = LangKey.of("Command.Give.Done", "Given &ax%amount% %region_block_name%&7 to &a%player_name%&7.");
1515

1616
public static final LangKey ERROR_REGION_BLOCK_INVALID = LangKey.of("Error.Region_Block.Invalid", RED + "Invalid Region Block!");
1717

1818
public static final LangKey REGION_SUCCESS_CREATED = LangKey.of("Messages.Region.Success.Created", GREEN + "New Region successfully created!");
1919
public static final LangKey REGION_ERROR_CREATED_NEARBY_RG = LangKey.of("Messages.Region.Error.Nearby_Region", RED + "You cannot create a region here, as it will cross over with another one!");
20-
public static final LangKey REGION_SUCCESS_DELETED = LangKey.of("Messages.Region.Success.Deleted", GREEN + "Region " + GRAY + "\u29c8" + Placeholders.REGION_ID + GREEN + " successfully removed!");
20+
public static final LangKey REGION_ERROR_CREATED_LIMIT = LangKey.of("Messages.Region.Error.Limit", RED + "You cannot create a region of this type because you have reached the limit!");
2121
public static final LangKey REGION_SUCCESS_DESTROY_SELF = LangKey.of("Messages.Region.Success.Destroy.Self", GREEN + "Region " + GRAY + "\u29c8" + Placeholders.REGION_ID + GREEN + " successfully removed!");
22-
public static final LangKey REGION_SUCCESS_DESTROY_TARGET = LangKey.of("Messages.Region.Success.Destroy.Target", LIGHT_PURPLE + "You've just destroyed a region "+GRAY+"\u29c8 "+LIGHT_PURPLE+"!");
23-
public static final LangKey REGION_SUCCESS_DAMAGED_TARGET = LangKey.of("Messages.Region.Success.Damaged.Target", GREEN + "Region "+GRAY+"\u29c8"+Placeholders.REGION_ID+GREEN+" has been damaged, but it's not destroyed yet");
24-
public static final LangKey REGION_SUCCESS_DAMAGED_SELF = LangKey.of("Messages.Region.Success.Damaged.Self", NO_PREFIX+
25-
RED+BOLD+"!! ALARM !!\n"+
22+
public static final LangKey REGION_SUCCESS_DESTROY_TARGET = LangKey.of("Messages.Region.Success.Destroy.Target", LIGHT_PURPLE + "You've just destroyed a region " + GRAY + "\u29c8 " + LIGHT_PURPLE + "!");
23+
public static final LangKey REGION_SUCCESS_DAMAGED_TARGET = LangKey.of("Messages.Region.Success.Damaged.Target", GREEN + "Region " + GRAY + "\u29c8" + Placeholders.REGION_ID + GREEN + " has been damaged, but it's not destroyed yet");
24+
public static final LangKey REGION_SUCCESS_DAMAGED_SELF = LangKey.of("Messages.Region.Success.Damaged.Self", NO_PREFIX +
25+
RED + BOLD + "!! ALARM !!\n" +
2626
BLUE + "Your Region " + ORANGE + Placeholders.REGION_LOCATION + BLUE + " has been damaged!" +
27-
RED+"\nHe has "+BOLD+Placeholders.REGION_HEALTH+RED+" health(s) left and will be destroyed!\n");
28-
public static final LangKey REGION_DESTROY_NOTIFY = LangKey.of("Messages.Region.Notify.Destroy", NO_PREFIX+
29-
RED+BOLD+"!! ALARM !!\n"+
27+
RED + "\nHe has " + BOLD + Placeholders.REGION_HEALTH + RED + " health(s) left and will be destroyed!\n");
28+
public static final LangKey REGION_DESTROY_NOTIFY = LangKey.of("Messages.Region.Notify.Destroy", NO_PREFIX +
29+
RED + BOLD + "!! ALARM !!\n" +
3030
BLUE + "Your Region " + ORANGE + Placeholders.REGION_LOCATION + BLUE + " was destroyed!\n");
3131

32-
public static final LangKey REGION_ENTER_NOTIFY = LangKey.of("Messages.Region.Notify.Enter", GRAY + "You've entered a "+LIGHT_PURPLE+Placeholders.REGION_OWNER_NAME+GRAY+" region");
33-
public static final LangKey REGION_EXIT_NOTIFY = LangKey.of("Messages.Region.Notify.Exit", GRAY + "You've leave a "+LIGHT_PURPLE+Placeholders.REGION_OWNER_NAME+GRAY+" region");
34-
public static final LangKey REGION_ERROR_BREAK = LangKey.of("Messages.Region.Notify.Break", ORANGE + "Hey!"+GRAY+" I'm sorry, but you "+ORANGE+"can't break this block"+GRAY+" here!");
35-
public static final LangKey REGION_ERROR_INTERACT = LangKey.of("Messages.Region.Notify.Interact", ORANGE + "Hey!"+GRAY+" I'm sorry, but you "+ORANGE+"can't interact with this"+GRAY+" here!");
32+
public static final LangKey REGION_ENTER_NOTIFY = LangKey.of("Messages.Region.Notify.Enter", GRAY + "You've entered a " + LIGHT_PURPLE + Placeholders.REGION_OWNER_NAME + GRAY + " region");
33+
public static final LangKey REGION_EXIT_NOTIFY = LangKey.of("Messages.Region.Notify.Exit", GRAY + "You've leave a " + LIGHT_PURPLE + Placeholders.REGION_OWNER_NAME + GRAY + " region");
34+
public static final LangKey REGION_ERROR_BREAK = LangKey.of("Messages.Region.Notify.Break", ORANGE + "Hey!" + GRAY + " I'm sorry, but you " + ORANGE + "can't break this block" + GRAY + " here!");
35+
public static final LangKey REGION_ERROR_INTERACT = LangKey.of("Messages.Region.Notify.Interact", ORANGE + "Hey!" + GRAY + " I'm sorry, but you " + ORANGE + "can't interact with this" + GRAY + " here!");
3636

3737

3838
public static final LangKey MENU_REGION_NO_ACCESS = LangKey.of("Messages.Menu.No_Access", RED + "You don't have access to edit members!");
3939
public static final LangKey MENU_REGION_DEPOSIT_NO_ENOUGH_MONEY = LangKey.of("Messages.Menu.Deposit.No_Enough_Money", RED + "You don't have enough money to pay for it!");
4040
public static final LangKey MENU_REGION_DEPOSIT_SUCCESS = LangKey.of("Messages.Menu.Deposit.Success", GREEN + "The life of the region has been successfully paid for!");
41-
public static final LangKey MENU_MEMBERS_KICK_SUCCESS = LangKey.of("Messages.Menu.Members.Kick.Success", GREEN + "Member "+LIGHT_YELLOW+Placeholders.MEMBER_NAME+GREEN+" success removed from region!");
42-
43-
public static final LangKey Editor_Region_Block_Enter_Create = new LangKey("Editor.Region.Block.Enter.Create", GRAY+"Enter "+GREEN+"unique "+GRAY+"block "+GREEN+"identifier"+GRAY+"...");
44-
public static final LangKey Editor_Region_Block_Enter_Name = new LangKey("Editor.Region.Block.Enter.Name", GRAY+"Enter "+GREEN+"name"+GRAY+"...");
45-
public static final LangKey Editor_Region_Enter_Player_name = new LangKey("Editor.Region.Enter.Player_Name", GRAY+"Enter "+GREEN+"player name"+GRAY+"...");
46-
public static final LangKey Editor_Region_Block_Enter_Currency = new LangKey("Editor.Region.Block.Enter.Currency", GRAY+"Enter "+GREEN+"currency"+GRAY+"...");
47-
public static final LangKey Editor_Region_Block_Enter_Value = new LangKey("Editor.Region.Block.Enter.Value", GRAY+"Enter "+GREEN+"value"+GRAY+"...");
48-
public static final LangKey Editor_Region_Block_Enter_LifeTime = new LangKey("Editor.Region.Block.Enter.Life_Time", GRAY+"Enter "+GREEN+"name "+GRAY+"and "+GREEN+"time in seconds"+GRAY+"...");
49-
public static final LangKey Editor_Region_Block_Enter_Hologram_Template = LangKey.of("Editor.Region.Block.Enter.HologramTemplate", GRAY+"Enter "+GREEN+"hologram template "+GRAY+"...");
50-
public static final LangKey Editor_Region_Block_Error_Exist = new LangKey("Editor.Region.Block.Error.Exist", "&cBlock already exists!");
51-
public static final LangKey Editor_Region_Members_Player_NF = new LangKey("Editor.Region.Members.Error.Player.Not_Found", "&cPlayer not found!");
52-
public static final LangKey Editor_Region_Members_Player_Already = new LangKey("Editor.Region.Members.Error.Player.Already", "&cPlayer is already in your region!");
53-
public static final LangKey Editor_Region_Block_Error_Currency_NF = new LangKey("Editor.Region.Block.Error.Currency.Not_Found", "&cCurrency not found!");
41+
public static final LangKey MENU_MEMBERS_KICK_SUCCESS = LangKey.of("Messages.Menu.Members.Kick.Success", GREEN + "Member " + LIGHT_YELLOW + Placeholders.MEMBER_NAME + GREEN + " success removed from region!");
42+
43+
public static final LangKey Editor_Region_Block_Enter_Create = new LangKey("Editor.Region.Block.Enter.Create", GRAY + "Enter " + GREEN + "unique " + GRAY + "block " + GREEN + "identifier" + GRAY + "...");
44+
public static final LangKey Editor_Region_Block_Enter_Name = new LangKey("Editor.Region.Block.Enter.Name", GRAY + "Enter " + GREEN + "name" + GRAY + "...");
45+
public static final LangKey Editor_Region_Enter_Player_name = new LangKey("Editor.Region.Enter.Player_Name", GRAY + "Enter " + GREEN + "player name" + GRAY + "...");
46+
public static final LangKey Editor_Region_Block_Enter_Currency = new LangKey("Editor.Region.Block.Enter.Currency", GRAY + "Enter " + GREEN + "currency" + GRAY + "...");
47+
public static final LangKey Editor_Region_Block_Enter_Value = new LangKey("Editor.Region.Block.Enter.Value", GRAY + "Enter " + GREEN + "value" + GRAY + "...");
48+
public static final LangKey Editor_Region_Block_Enter_LifeTime = new LangKey("Editor.Region.Block.Enter.Life_Time", GRAY + "Enter " + GREEN + "name " + GRAY + "and " + GREEN + "time in seconds" + GRAY + "...");
49+
public static final LangKey Editor_Region_Block_Enter_Hologram_Template = LangKey.of("Editor.Region.Block.Enter.HologramTemplate", GRAY + "Enter " + GREEN + "hologram template " + GRAY + "...");
50+
public static final LangKey Editor_Region_Block_Error_Exist = new LangKey("Editor.Region.Block.Error.Exist", "&cBlock already exists!");
51+
public static final LangKey Editor_Region_Members_Player_NF = new LangKey("Editor.Region.Members.Error.Player.Not_Found", "&cPlayer not found!");
52+
public static final LangKey Editor_Region_Members_Player_Already = new LangKey("Editor.Region.Members.Error.Player.Already", "&cPlayer is already in your region!");
53+
public static final LangKey Editor_Region_Block_Error_Currency_NF = new LangKey("Editor.Region.Block.Error.Currency.Not_Found", "&cCurrency not found!");
5454
}

src/main/java/t/me/p1azmer/plugin/protectionblocks/currency/handler/ItemStackHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public ItemStack getItem() {
2525

2626
@Override
2727
public double getBalance(@NotNull Player player) {
28-
return Math.floor(PlayerUtil.countItem(player, this.getItem()));
28+
return PlayerUtil.countItem(player, this.getItem());
2929
}
3030

3131
@Override

0 commit comments

Comments
 (0)