Skip to content

Commit 1ba567b

Browse files
committed
v1.0.6
1 parent ea0a316 commit 1ba567b

File tree

7 files changed

+70
-14
lines changed

7 files changed

+70
-14
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

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

88
repositories {
99
mavenCentral()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Placeholders extends t.me.p1azmer.engine.utils.Placeholders {
4747
public static final String REGION_BLOCK_HOLOGRAM_TEMPLATE = "%region_block_hologram_template%";
4848
public static final String REGION_BLOCK_HOLOGRAM_ENABLED = "%region_block_hologram_enabled%";
4949
public static final String REGION_BLOCK_HOLOGRAM_IN_REGION = "%region_block_hologram_in_region%";
50+
public static final String REGION_BLOCK_WORLDS = "%region_block_worlds%";
5051

5152
// region block breaker
5253
public static final String REGION_BLOCK_BREAKER_DMG_TYPE = "%region_block_breaker_damage_type%";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class Lang extends EngineLang {
4141
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!");
4242

4343
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_World = new LangKey("Editor.Region.Block.Enter.World", GRAY + "Enter " + GREEN + "world name" + GRAY + "...");
4445
public static final LangKey Editor_Region_Block_Enter_Name = new LangKey("Editor.Region.Block.Enter.Name", GRAY + "Enter " + GREEN + "name" + GRAY + "...");
4546
public static final LangKey Editor_Region_Enter_Player_name = new LangKey("Editor.Region.Enter.Player_Name", GRAY + "Enter " + GREEN + "player name" + GRAY + "...");
4647
public static final LangKey Editor_Region_Block_Enter_Currency = new LangKey("Editor.Region.Block.Enter.Currency", GRAY + "Enter " + GREEN + "currency" + GRAY + "...");

src/main/java/t/me/p1azmer/plugin/protectionblocks/editor/EditorLocales.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public class EditorLocales extends t.me.p1azmer.engine.api.editor.EditorLocales
6464
GRAY + "Example:",
6565
GRAY + "You can disable hologram and create 'invisible' region",
6666
"",
67-
GRAY+"If set to "+LIGHT_YELLOW+"In Region"+GRAY+",",
68-
GRAY+"the region hologram will only be displayed",
69-
GRAY+"when the player is in the region")
67+
GRAY + "If set to " + LIGHT_YELLOW + "In Region" + GRAY + ",",
68+
GRAY + "the region hologram will only be displayed",
69+
GRAY + "when the player is in the region")
7070
.emptyLine()
7171
.currentHeader()
7272
.current("In Region Only", Placeholders.REGION_BLOCK_HOLOGRAM_IN_REGION + GRAY + " (" + WHITE + DROP_KEY + GRAY + ")")
@@ -86,7 +86,7 @@ public class EditorLocales extends t.me.p1azmer.engine.api.editor.EditorLocales
8686
RED + "You can only change it in the " + BOLD + "config.yml" + RED + " file"
8787
)
8888
.currentHeader()
89-
.current("Enabled", Placeholders.REGION_BLOCK_LIFE_TIME_ENABLED+ GRAY + " (" + WHITE + LMB + GRAY + ")")
89+
.current("Enabled", Placeholders.REGION_BLOCK_LIFE_TIME_ENABLED + GRAY + " (" + WHITE + LMB + GRAY + ")")
9090
.build();
9191
public static final EditorLocale REGION_BLOCK_PLACE_LIMIT = builder(PREFIX + "Region.Block.Change.Place_Limit")
9292
.name("Region Place Limit")
@@ -98,7 +98,7 @@ public class EditorLocales extends t.me.p1azmer.engine.api.editor.EditorLocales
9898
RED + "You can only change it in the " + BOLD + "config.yml" + RED + " file"
9999
)
100100
.currentHeader()
101-
.current("Enabled", Placeholders.REGION_BLOCK_PLACE_LIMIT_ENABLED+ GRAY + " (" + WHITE + LMB + GRAY + ")")
101+
.current("Enabled", Placeholders.REGION_BLOCK_PLACE_LIMIT_ENABLED + GRAY + " (" + WHITE + LMB + GRAY + ")")
102102
.build();
103103
public static final EditorLocale REGION_BLOCK_GROUP_SIZE = builder(PREFIX + "Region.Block.Change.Group_Size")
104104
.name("Region Groups Size")
@@ -109,7 +109,19 @@ public class EditorLocales extends t.me.p1azmer.engine.api.editor.EditorLocales
109109
RED + "You can only change it in the " + BOLD + "config.yml" + RED + " file"
110110
)
111111
.currentHeader()
112-
.current("Enabled", Placeholders.REGION_BLOCK_GROUP_SIZE_ENABLED+ GRAY + " (" + WHITE + LMB + GRAY + ")")
112+
.current("Enabled", Placeholders.REGION_BLOCK_GROUP_SIZE_ENABLED + GRAY + " (" + WHITE + LMB + GRAY + ")")
113+
.build();
114+
115+
public static final EditorLocale REGION_BLOCK_WORLDS = builder(PREFIX + "Region.Block.Change.Worlds")
116+
.name("Region Worlds")
117+
.text("List of worlds where this",
118+
"region block will be available")
119+
.emptyLine()
120+
.currentHeader()
121+
.current("List", Placeholders.REGION_BLOCK_WORLDS)
122+
.emptyLine()
123+
.click(LMB, "Add world")
124+
.click(SHIFT_RMB, "Clear")
113125
.build();
114126
public static final EditorLocale REGION_BLOCK_BREAKERS_ICON = builder(PREFIX + "Region.Block.Breakers.Navigate")
115127
.name("Region Breakers")
@@ -120,7 +132,7 @@ public class EditorLocales extends t.me.p1azmer.engine.api.editor.EditorLocales
120132
public static final EditorLocale REGION_BLOCK_BREAKERS_CREATE = builder(PREFIX + "Region.Block.Breakers.Create")
121133
.name("New Breaker")
122134
.emptyLine()
123-
.text(GREEN + "Note" + GRAY + ":", "If you added TNT,","it means that the block can be","broken with a TNT blast")
135+
.text(GREEN + "Note" + GRAY + ":", "If you added TNT,", "it means that the block can be", "broken with a TNT blast")
124136
.emptyLine()
125137
.click(DRAG_DROP, "Add")
126138
.build();

src/main/java/t/me/p1azmer/plugin/protectionblocks/region/RegionManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public boolean create(@NotNull String id) {
172172
public void tryCreateRegion(@NotNull Player player, @NotNull Block block, @NotNull ItemStack item, @NotNull RegionBlock regionBlock) {
173173
Region region = this.getRegionByBlock(block);
174174
if (region != null && !region.isAllowed(player)) return;
175+
if (!regionBlock.getWorlds().contains(block.getWorld().getName())) return;
175176

176177
if (regionBlock.isPlaceLimitEnabled() && regionBlock.getPlaceLimit() != null) {
177178
RegionUser regionUser = plugin.getUserManager().getUserData(player);

src/main/java/t/me/p1azmer/plugin/protectionblocks/region/editor/RGBlockMainEditor.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package t.me.p1azmer.plugin.protectionblocks.region.editor;
22

3+
import org.bukkit.Bukkit;
34
import org.bukkit.Material;
45
import org.bukkit.event.inventory.ClickType;
56
import org.bukkit.event.inventory.InventoryClickEvent;
@@ -18,6 +19,7 @@
1819
import t.me.p1azmer.plugin.protectionblocks.region.editor.breakers.RGBlockBreakersListEditor;
1920
import t.me.p1azmer.plugin.protectionblocks.region.impl.RegionBlock;
2021

22+
import java.util.ArrayList;
2123
import java.util.List;
2224

2325
public class RGBlockMainEditor extends EditorMenu<ProtectionPlugin, RegionBlock> {
@@ -58,28 +60,28 @@ public RGBlockMainEditor(@NotNull RegionBlock regionBlock) {
5860
.writeMeta();
5961
}));
6062

61-
this.addItem(Material.NAME_TAG, EditorLocales.REGION_BLOCK_NAME, 11).setClick((viewer, event) ->
63+
this.addItem(Material.NAME_TAG, EditorLocales.REGION_BLOCK_NAME, 10).setClick((viewer, event) ->
6264
this.handleInput(viewer, Lang.Editor_Region_Block_Enter_Name, wrapper -> {
6365
regionBlock.setName(wrapper.getText());
6466
regionBlock.save();
6567
return true;
6668
}));
67-
this.addItem(Material.MOSS_BLOCK, EditorLocales.REGION_BLOCK_SIZE, 13).setClick((viewer, event) ->
69+
this.addItem(Material.MOSS_BLOCK, EditorLocales.REGION_BLOCK_SIZE, 12).setClick((viewer, event) ->
6870
this.handleInput(viewer, Lang.Editor_Region_Block_Enter_Value, wrapper -> {
6971
regionBlock.setRegionSize(wrapper.asInt(1));
7072
regionBlock.save();
7173
return true;
7274
}));
7375
this.addItem(ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmQzNmMzMjkxZmUwMmQxNDJjNGFmMjhkZjJmNTViYjAzOTdlMTk4NTU0ZTgzNDU5OTBkYmJjZDRjMTQwMzE2YiJ9fX0="),
74-
EditorLocales.REGION_BLOCK_STRENGTH, 15).setClick((viewer, event) ->
76+
EditorLocales.REGION_BLOCK_STRENGTH, 14).setClick((viewer, event) ->
7577
this.handleInput(viewer, Lang.Editor_Region_Block_Enter_Value, wrapper -> {
7678
regionBlock.setStrength(wrapper.asInt(1));
7779
regionBlock.save();
7880
return true;
7981
}));
80-
this.addItem(Material.IRON_PICKAXE, EditorLocales.REGION_BLOCK_BREAKERS_ICON, 21).setClick((viewer, event) -> this.plugin.runTask(task -> this.getEditorBreakers().open(viewer.getPlayer(), 1)));
82+
this.addItem(Material.IRON_PICKAXE, EditorLocales.REGION_BLOCK_BREAKERS_ICON, 16).setClick((viewer, event) -> this.plugin.runTask(task -> this.getEditorBreakers().open(viewer.getPlayer(), 1)));
8183

82-
this.addItem(Material.ARMOR_STAND, EditorLocales.REGION_HOLOGRAM, 23).setClick((viewer, event) -> {
84+
this.addItem(Material.ARMOR_STAND, EditorLocales.REGION_HOLOGRAM, 20).setClick((viewer, event) -> {
8385
if (event.getClick().equals(ClickType.DROP)) {
8486
regionBlock.setHologramInRegion(!regionBlock.isHologramInRegion());
8587
regionBlock.getManager().getRegionsWithBlocks(regionBlock).forEach(regionBlock::updateHologram);
@@ -100,7 +102,7 @@ public RGBlockMainEditor(@NotNull RegionBlock regionBlock) {
100102
}
101103
});
102104
this.addItem(ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjg4OWNmY2JhY2JlNTk4ZThhMWNkODYxMGI0OWZjYjYyNjQ0ZThjYmE5ZDQ5MTFkMTIxMTM0NTA2ZDhlYTFiNyJ9fX0="),
103-
EditorLocales.REGION_BLOCK_DEPOSIT, 31)
105+
EditorLocales.REGION_BLOCK_DEPOSIT, 22)
104106
.setClick((viewer, event) -> {
105107
if (event.isLeftClick()) {
106108
this.handleInput(viewer, Lang.Editor_Region_Block_Enter_Value, wrapper -> {
@@ -122,6 +124,26 @@ public RGBlockMainEditor(@NotNull RegionBlock regionBlock) {
122124
EditorManager.suggestValues(viewer.getPlayer(), plugin().getCurrencyManager().getCurrencyIds(), true);
123125
}
124126
});
127+
this.addItem(ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjgwZDMyOTVkM2Q5YWJkNjI3NzZhYmNiOGRhNzU2ZjI5OGE1NDVmZWU5NDk4YzRmNjlhMWMyYzc4NTI0YzgyNCJ9fX0="),
128+
EditorLocales.REGION_BLOCK_WORLDS, 24).setClick((viewer, event) -> {
129+
if (event.isShiftClick()) {
130+
if (event.isRightClick()) {
131+
regionBlock.setWorlds(new ArrayList<>());
132+
this.save(viewer);
133+
}
134+
} else {
135+
if (event.isLeftClick()) {
136+
EditorManager.suggestValues(viewer.getPlayer(), CollectionsUtil.worldNames(), true);
137+
this.handleInput(viewer, Lang.Editor_Region_Block_Enter_World, wrapper -> {
138+
List<String> list = regionBlock.getWorlds();
139+
list.add(wrapper.getText());
140+
regionBlock.setWorlds(list);
141+
regionBlock.save();
142+
return true;
143+
});
144+
}
145+
}
146+
});
125147
this.addItem(ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTRiZDlhNDViOTY4MWNlYTViMjhjNzBmNzVhNjk1NmIxZjU5NGZlYzg0MGI5NjA3Nzk4ZmIxZTcwNzc2NDQzMCJ9fX0="),
126148
EditorLocales.REGION_BLOCK_LIFE_TIME, 39)
127149
.setClick((viewer, event) -> {

src/main/java/t/me/p1azmer/plugin/protectionblocks/region/impl/RegionBlock.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import t.me.p1azmer.engine.api.placeholder.PlaceholderMap;
1010
import t.me.p1azmer.engine.lang.LangManager;
1111
import t.me.p1azmer.engine.utils.Colorizer;
12+
import t.me.p1azmer.engine.utils.Colors;
1213
import t.me.p1azmer.engine.utils.PlayerRankMap;
1314
import t.me.p1azmer.plugin.protectionblocks.Placeholders;
1415
import t.me.p1azmer.plugin.protectionblocks.ProtectionPlugin;
@@ -35,6 +36,7 @@ public class RegionBlock extends AbstractConfigHolder<ProtectionPlugin> implemen
3536
private PlayerRankMap<Integer> placeLimit;
3637
private int regionSize;
3738
private List<RegionBreaker> breakers;
39+
private List<String> worlds;
3840
private boolean hologramEnabled;
3941
private boolean hologramInRegion;
4042
private String hologramTemplate;
@@ -52,6 +54,7 @@ public RegionBlock(@NotNull RegionManager manager, @NotNull JYML cfg) {
5254
this.manager = manager;
5355

5456
this.breakers = new ArrayList<>();
57+
this.worlds = List.of("world");
5558

5659
this.placeholderMap = new PlaceholderMap()
5760
.add(Placeholders.REGION_BLOCK_ID, this::getId)
@@ -66,6 +69,7 @@ public RegionBlock(@NotNull RegionManager manager, @NotNull JYML cfg) {
6669
.add(Placeholders.REGION_BLOCK_HOLOGRAM_ENABLED, () -> LangManager.getBoolean(this.isHologramEnabled()))
6770
.add(Placeholders.REGION_BLOCK_HOLOGRAM_IN_REGION, () -> LangManager.getBoolean(this.isHologramInRegion()))
6871
.add(Placeholders.REGION_BLOCK_HOLOGRAM_TEMPLATE, this::getHologramTemplate)
72+
.add(Placeholders.REGION_BLOCK_WORLDS, ()-> Colorizer.apply(Colors.LIGHT_PURPLE + String.join(", ", this.getWorlds())))
6973
;
7074
}
7175

@@ -102,6 +106,10 @@ public boolean load() {
102106
this.getBreakers().add(RegionBreaker.read(cfg, "Region.Breakers.List." + sId));
103107
}
104108
this.setCurrencyId(cfg.getString("Region.Deposit.Currency_Id", "Vault"));
109+
110+
if (!cfg.contains("Worlds") && cfg.getStringList("Worlds").isEmpty())
111+
cfg.set("Worlds", List.of("world"));
112+
this.setWorlds(cfg.getStringList("Worlds"));
105113
return true;
106114
}
107115

@@ -133,6 +141,8 @@ protected void onSave() {
133141
for (RegionBreaker breaker : this.getBreakers()){
134142
breaker.write(cfg, "Region.Breakers.List."+ (i++));
135143
}
144+
145+
cfg.set("Worlds", this.getWorlds());
136146
}
137147

138148
public void clear() {
@@ -228,6 +238,15 @@ public List<RegionBreaker> getBreakers() {
228238
return breakers;
229239
}
230240

241+
@NotNull
242+
public List<String> getWorlds() {
243+
return worlds;
244+
}
245+
246+
public void setWorlds(@NotNull List<String> worlds) {
247+
this.worlds = worlds;
248+
}
249+
231250
@NotNull
232251
public String getCurrencyId() {
233252
return currencyId;

0 commit comments

Comments
 (0)