Skip to content

Commit c6b6ff0

Browse files
authored
Update 1.1.0: New commands and fixes
Update 1.1.0 (#12) This update adds the following features: - /plot border and /plot wall command, configurable in config.yml - Plot claim and merge limits with permissions This update fixes: - No build of powernukkitx as an artifact in actions. - /plot home and /plot tp do not teleport the player into the world.
1 parent e3470b3 commit c6b6ff0

File tree

22 files changed

+642
-76
lines changed

22 files changed

+642
-76
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/upload-artifact@v3.0.0
3333
with:
3434
name: PowerNukkitX
35-
path: PowerNukkitX/target/powernukkitx-1.6.0.0-PNX-SNAPSHOT-shaded.jar
35+
path: PowerNukkitX/target/powernukkitx-1.6.0.0-PNX-shaded.jar
3636

3737
- name: Get name and version from pom.xml
3838
run: |

README.md

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,50 @@ How can I create a plot world?
3131
Commands and Permissions
3232
------------------------------
3333

34-
| Command | Sub command | Permission | Aliases |
35-
|-----------|-----------------|------------------------------------|-------------------------------|
36-
| /plot | --- | --- | --- |
37-
| ~ | addhelper | --- | add, trust |
38-
| ~ | auto | --- | a |
39-
| ~ | claim | --- | c |
40-
| ~ | clear | --- | --- |
41-
| ~ | delethome | --- | delhome, removehome, rmhome |
42-
| ~ | deny | --- | --- |
43-
| ~ | dispose | --- | reset |
44-
| ~ | generate | plot.command.admin.generate | --- |
45-
| ~ | home | --- | h, visit, v |
46-
| ~ | homes | --- | --- |
47-
| ~ | info | --- | i |
48-
| ~ | kick | --- | --- |
49-
| ~ | merge | plot.command.admin.merge | --- |
50-
| ~ | regenallroads | plot.command.admin.regenallroads | --- |
51-
| ~ | regenroad | plot.command.admin.regenroad | --- |
52-
| ~ | reload | plot.command.admin.reload | --- |
53-
| ~ | removehelper | --- | remove, untrust |
54-
| ~ | sethome | --- | --- |
55-
| ~ | setowner | --- | --- |
56-
| ~ | setroads | plot.command.admin.setroads | --- |
57-
| ~ | setting | --- | config |
58-
| ~ | teleport | plot.command.admin.teleport | tp |
59-
| ~ | undeny | --- | --- |
60-
| ~ | unlink | plot.command.admin.unlink | --- |
61-
| ~ | warp | --- | w |
34+
| Command | Sub command | Permission | Aliases |
35+
|-----------|-----------------|----------------------------------|-------------------------------|
36+
| /plot | --- | --- | --- |
37+
| ~ | addhelper | --- | add, trust |
38+
| ~ | auto | --- | a |
39+
| ~ | claim | --- | c |
40+
| ~ | clear | --- | --- |
41+
| ~ | delethome | --- | delhome, removehome, rmhome |
42+
| ~ | deny | --- | --- |
43+
| ~ | dispose | --- | reset |
44+
| ~ | generate | plot.command.admin.generate | --- |
45+
| ~ | home | --- | h, visit, v |
46+
| ~ | homes | --- | --- |
47+
| ~ | info | --- | i |
48+
| ~ | kick | --- | --- |
49+
| ~ | merge | plot.command.merge | --- |
50+
| ~ | regenallroads | plot.command.admin.regenallroads | --- |
51+
| ~ | regenroad | plot.command.admin.regenroad | --- |
52+
| ~ | reload | plot.command.admin.reload | --- |
53+
| ~ | removehelper | --- | remove, untrust |
54+
| ~ | sethome | --- | --- |
55+
| ~ | setowner | --- | --- |
56+
| ~ | setroads | plot.command.admin.setroads | --- |
57+
| ~ | setting | --- | config |
58+
| ~ | teleport | plot.command.admin.teleport | tp |
59+
| ~ | undeny | --- | --- |
60+
| ~ | unlink | plot.command.unlink | --- |
61+
| ~ | warp | --- | w |
62+
63+
Commands that need to be enabled in config.yml
64+
------------------------------
65+
66+
| Command | Sub command | Permission | Aliases |
67+
|---------|-------------|---------------------|---------|
68+
| /plot | border | plot.command.border | b |
69+
| ~ | wall | plot.command.wall | --- |
6270

6371
Other Permissions
6472
------------------------------
6573

6674
| Permission | Discription |
6775
|---------------------------------|--------------------------------------------------------------------------|
6876
| plot.command.admin.addhelper | Bypasses the owner check when adding a helper to a plot. |
77+
| plot.command.admin.border | Bypasses the owner check when changing the plot border block. |
6978
| plot.command.admin.clear | Bypasses the owner check when clearing a plot. |
7079
| plot.command.admin.deletehome | Bypasses the owner check when deleting the spawn point of a plot |
7180
| plot.command.admin.deny | Bypasses the owner check when denying a player from a plot. |
@@ -79,11 +88,15 @@ Other Permissions
7988
| plot.command.admin.config | Bypasses the owner check when setting the configuration of a plot. |
8089
| plot.command.admin.undeny | Bypasses the owner check when undenying a player from a plot. |
8190
| plot.command.admin.unlink | Bypasses the owner check when unlinking a plot. |
91+
| plot.command.admin.wall | Bypasses the owner check when changing the plot wall block. |
8292
| plot.admin.bypass.deny | Bypasses the denial of a player from a plot. |
8393
| plot.admin.bypass.kick | Bypasses the kick of a player from a plot. |
8494
| plot.admin.interact | Allows you to interact with blocks on the road. |
8595
| plot.admin.damage | Allows you to damage players on roads or if pvp is disabled on the plot. |
8696
| plot.admin.bucket.fill | Allows you to fill up buckets from the road. |
8797
| plot.admin.bucket.emtpy | Allows you to empty buckets from the road. |
8898
| plot.admin.break | Allows you to break blocks on the road. |
89-
| plot.admin.place | Allows you to place blocks on the road. |
99+
| plot.admin.place | Allows you to place blocks on the road. |
100+
| plot.merge.unlimited | Allows you to merge unlimited plots. |
101+
| plot.merge.limit.\<any number> | Limits the player to only merge up to the given amount of plots. |
102+
| plot.limit.\<any number> | Limits the player to only claim up to the given amount of plots. |

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>ms.kevi</groupId>
88
<artifactId>plotplugin</artifactId>
9-
<version>1.0.7</version>
9+
<version>1.1.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>17</maven.compiler.source>

src/main/java/ms/kevi/plotplugin/PlotPlugin.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import ms.kevi.plotplugin.util.PlotLevelRegistration;
3636
import ms.kevi.plotplugin.util.PlotLevelSettings;
3737
import ms.kevi.plotplugin.util.Utils;
38+
import ms.kevi.plotplugin.util.BlockEntry;
3839
import ms.kevi.plotplugin.util.async.TaskExecutor;
3940

4041
import java.io.BufferedReader;
@@ -81,6 +82,15 @@ public class PlotPlugin extends PluginBase {
8182
@Getter
8283
private int plotsPerPage = 5;
8384

85+
@Getter
86+
private boolean addOtherCommands = true;
87+
88+
@Getter
89+
private final List<BlockEntry> borderEntries = new ArrayList<>();
90+
91+
@Getter
92+
private final List<BlockEntry> wallEntries = new ArrayList<>();
93+
8494
@Override
8595
public void onLoad() {
8696
INSTANCE = this;
@@ -126,6 +136,38 @@ public void onEnable() {
126136

127137
this.plotsPerPage = config.getInt("plots_per_page");
128138

139+
if(!config.exists("add_other_commands")) {
140+
config.set("add_other_commands", this.addOtherCommands);
141+
config.save();
142+
}
143+
144+
this.addOtherCommands = config.getBoolean("add_other_commands");
145+
146+
if(!config.exists("borders")) {
147+
final List<Map<String, Object>> defaultWalls = new ArrayList<>();
148+
defaultWalls.add(Utils.createMap(List.of("name", "image_type", "image_data"), List.of("reset_to_default", "PATH", "textures/ui/undoArrow")));
149+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data"), List.of("Diamond", 57, 0, "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/c/c8/Block_of_Diamond_JE5_BE3.png")));
150+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data", "permission"), List.of("Emerald", 133, 0, "plot.wall.emerald", "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/0/0b/Block_of_Emerald_JE4_BE3.png")));
151+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data", "permission"), List.of("Gold", 41, 0, "plot.wall.gold", "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/7/72/Block_of_Gold_JE6_BE3.png")));
152+
153+
config.set("borders", defaultWalls);
154+
config.save();
155+
}
156+
157+
if(!config.exists("walls")) {
158+
final List<Map<String, Object>> defaultWalls = new ArrayList<>();
159+
defaultWalls.add(Utils.createMap(List.of("name", "image_type", "image_data"), List.of("reset_to_default", "PATH", "textures/ui/undoArrow")));
160+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data"), List.of("Diamond", 57, 0, "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/c/c8/Block_of_Diamond_JE5_BE3.png")));
161+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data", "permission"), List.of("Emerald", 133, 0, "plot.wall.emerald", "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/0/0b/Block_of_Emerald_JE4_BE3.png")));
162+
defaultWalls.add(Utils.createMap(List.of("name", "block_id", "block_data", "image_type", "image_data", "permission"), List.of("Gold", 41, 0, "plot.wall.gold", "URL", "https://static.wikia.nocookie.net/minecraft_gamepedia/images/7/72/Block_of_Gold_JE6_BE3.png")));
163+
164+
config.set("walls", defaultWalls);
165+
config.save();
166+
}
167+
168+
this.borderEntries.addAll(config.getMapList("borders").stream().map(BlockEntry::of).toList());
169+
this.wallEntries.addAll(config.getMapList("walls").stream().map(BlockEntry::of).toList());
170+
129171
try {
130172
final String defaultLang = config.getString("default_lang");
131173

src/main/java/ms/kevi/plotplugin/command/PlotCommand.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import cn.nukkit.command.CommandSender;
2222
import ms.kevi.plotplugin.PlotPlugin;
2323
import ms.kevi.plotplugin.command.defaults.*;
24+
import ms.kevi.plotplugin.command.other.BorderCommand;
25+
import ms.kevi.plotplugin.command.other.WallCommand;
2426
import ms.kevi.plotplugin.lang.TranslationKey;
2527

2628
import java.util.Arrays;
@@ -66,6 +68,11 @@ public PlotCommand(PlotPlugin plugin) {
6668
this.subCommands.add(new UndenyCommand(this.plugin, this));
6769
this.subCommands.add(new UnlinkCommand(this.plugin, this));
6870
this.subCommands.add(new WarpCommand(this.plugin, this));
71+
72+
if(this.plugin.isAddOtherCommands()) {
73+
this.subCommands.add(new BorderCommand(this.plugin, this));
74+
this.subCommands.add(new WallCommand(this.plugin, this));
75+
}
6976
}
7077

7178
@Override

src/main/java/ms/kevi/plotplugin/command/defaults/AutoCommand.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ public boolean execute(Player player, String[] args) {
4444
return false;
4545
}
4646

47+
final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
48+
if(!player.isOp()) {
49+
int maxLimit = -1;
50+
for(String permission : player.getEffectivePermissions().keySet()) {
51+
if(permission.startsWith("plot.limit.")) {
52+
try {
53+
final String limitStr = permission.substring("plot.limit.".length());
54+
if(limitStr.isBlank()) continue;
55+
final int limit = Integer.parseInt(limitStr);
56+
57+
if(limit > maxLimit) maxLimit = limit;
58+
} catch(NumberFormatException ignored) {
59+
}
60+
}
61+
}
62+
63+
if(maxLimit > 0 && ownedPlots >= maxLimit) {
64+
player.sendMessage(this.translate(player, TranslationKey.AUTO_FAILURE_TOO_MANY, ownedPlots));
65+
return false;
66+
}
67+
}
68+
4769
final Plot plot = plotManager.getNextFreePlot();
4870

4971
if(plot != null) {

src/main/java/ms/kevi/plotplugin/command/defaults/ClaimCommand.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ public boolean execute(Player player, String[] args) {
4545
return false;
4646
}
4747

48+
final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
49+
if(!player.isOp()) {
50+
int maxLimit = -1;
51+
for(String permission : player.getEffectivePermissions().keySet()) {
52+
if(permission.startsWith("plot.limit.")) {
53+
try {
54+
final String limitStr = permission.substring("plot.limit.".length());
55+
if(limitStr.isBlank()) continue;
56+
final int limit = Integer.parseInt(limitStr);
57+
58+
if(limit > maxLimit) maxLimit = limit;
59+
} catch(NumberFormatException ignored) {
60+
}
61+
}
62+
}
63+
64+
if(maxLimit > 0 && ownedPlots >= maxLimit) {
65+
player.sendMessage(this.translate(player, TranslationKey.CLAIM_FAILURE_TOO_MANY, ownedPlots));
66+
return false;
67+
}
68+
}
69+
4870
if(!plot.hasOwner()) {
4971
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, false, true);
5072
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);

0 commit comments

Comments
 (0)