Skip to content

Commit 2617312

Browse files
authored
Update 1.1.2 (#14)
Changes of this update: - `/plot clear` and `/plot dispose` do not unlink all connected merges plots anymore. - `/plot` subcommands can now be shown client-side. Fixes of this update: - `/plot setroads` y-coordinate calucalation
1 parent 61010ec commit 2617312

32 files changed

+308
-137
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ jobs:
5252
env:
5353
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
5454

55+
- name: Delete old snapshot
56+
uses: dev-drprasad/delete-tag-and-release@v0.2.0
57+
with:
58+
delete_release: true
59+
tag_name: ${{env.VER}}-SNAPSHOT
60+
env:
61+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
62+
5563
- name: Create Release
5664
id: create_release
5765
uses: actions/create-release@v1

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Other Permissions
9797
| plot.admin.bucket.emtpy | Allows you to empty buckets from the road. |
9898
| plot.admin.break | Allows you to break blocks on the road. |
9999
| plot.admin.place | Allows you to place blocks on the road. |
100-
| plot.merge.unlimited | Allows you to merge unlimited plots. |
100+
| plot.merge.limit.unlimited | Allows you to merge unlimited plots. |
101101
| plot.merge.limit.\<any number> | Limits the player to only merge up to the given amount of plots. |
102+
| plot.limit.unlimited | Allows you to claim unlimited plots. |
102103
| 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.1.1</version>
9+
<version>1.1.2</version>
1010

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

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
import ms.kevi.plotplugin.manager.PlayerManager;
3333
import ms.kevi.plotplugin.manager.PlayerNameFunction;
3434
import ms.kevi.plotplugin.manager.PlotManager;
35+
import ms.kevi.plotplugin.util.BlockEntry;
3536
import ms.kevi.plotplugin.util.PlotLevelRegistration;
3637
import ms.kevi.plotplugin.util.PlotLevelSettings;
3738
import ms.kevi.plotplugin.util.Utils;
38-
import ms.kevi.plotplugin.util.BlockEntry;
3939
import ms.kevi.plotplugin.util.async.TaskExecutor;
4040

4141
import java.io.BufferedReader;
@@ -82,6 +82,9 @@ public class PlotPlugin extends PluginBase {
8282
@Getter
8383
private int plotsPerPage = 5;
8484

85+
@Getter
86+
private boolean showCommandParams = true;
87+
8588
@Getter
8689
private boolean addOtherCommands = true;
8790

@@ -136,6 +139,13 @@ public void onEnable() {
136139

137140
this.plotsPerPage = config.getInt("plots_per_page");
138141

142+
if(!config.exists("show_command_params")) {
143+
config.set("show_command_params", this.showCommandParams);
144+
config.save();
145+
}
146+
147+
this.showCommandParams = config.getBoolean("show_command_params");
148+
139149
if(!config.exists("add_other_commands")) {
140150
config.set("add_other_commands", this.addOtherCommands);
141151
config.save();

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
import cn.nukkit.Player;
2020
import cn.nukkit.command.Command;
2121
import cn.nukkit.command.CommandSender;
22+
import cn.nukkit.command.data.*;
2223
import ms.kevi.plotplugin.PlotPlugin;
2324
import ms.kevi.plotplugin.command.defaults.*;
2425
import ms.kevi.plotplugin.command.other.BorderCommand;
2526
import ms.kevi.plotplugin.command.other.WallCommand;
2627
import ms.kevi.plotplugin.lang.TranslationKey;
2728

28-
import java.util.Arrays;
29-
import java.util.LinkedHashSet;
30-
import java.util.Set;
29+
import java.util.*;
3130

3231
/**
3332
* @author Kevims KCodeYT
@@ -73,6 +72,24 @@ public PlotCommand(PlotPlugin plugin) {
7372
this.subCommands.add(new BorderCommand(this.plugin, this));
7473
this.subCommands.add(new WallCommand(this.plugin, this));
7574
}
75+
76+
if(this.plugin.isShowCommandParams()) {
77+
this.commandParameters.clear();
78+
79+
for(SubCommand subCommand : this.subCommands) {
80+
final Set<CommandParameter> parameterSet = subCommand.getParameters();
81+
82+
for(String alias : subCommand.getAliases()) {
83+
final CommandParameter[] parameters = new CommandParameter[parameterSet.size() + 1];
84+
parameters[0] = CommandParameter.newEnum("subcommand", false, new CommandEnum("PlotSubcommand" + alias, alias));
85+
86+
int i = 1;
87+
for(CommandParameter parameter : parameterSet) parameters[i++] = parameter;
88+
89+
this.commandParameters.put(alias, parameters);
90+
}
91+
}
92+
}
7693
}
7794

7895
@Override
@@ -107,4 +124,22 @@ protected String translate(Player player, TranslationKey key, Object... params)
107124
return this.plugin.getLanguage().translate(player, key, params);
108125
}
109126

127+
@Override
128+
public CommandDataVersions generateCustomCommandData(Player player) {
129+
final CommandDataVersions versions = super.generateCustomCommandData(player);
130+
final CommandData commandData = versions.versions.get(0);
131+
132+
final Map<String, CommandOverload> overloads = new HashMap<>(commandData.overloads);
133+
for(Map.Entry<String, CommandOverload> entry : overloads.entrySet()) {
134+
for(SubCommand subCommand : this.subCommands) {
135+
if(subCommand.getAliases().contains(entry.getKey())) {
136+
if(!subCommand.hasPermission(player)) commandData.overloads.remove(entry.getKey());
137+
break;
138+
}
139+
}
140+
}
141+
142+
return versions;
143+
}
144+
110145
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import cn.nukkit.Player;
2020
import cn.nukkit.command.data.CommandParameter;
21-
import ms.kevi.plotplugin.PlotPlugin;
22-
import ms.kevi.plotplugin.lang.TranslationKey;
2321
import lombok.AccessLevel;
2422
import lombok.Getter;
2523
import lombok.Setter;
24+
import ms.kevi.plotplugin.PlotPlugin;
25+
import ms.kevi.plotplugin.lang.TranslationKey;
2626

2727
import java.util.*;
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean execute(Player player, String[] args) {
4545
}
4646

4747
final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
48-
if(!player.isOp()) {
48+
if(!player.hasPermission("plot.limit.unlimited")) {
4949
int maxLimit = -1;
5050
for(String permission : player.getEffectivePermissions().keySet()) {
5151
if(permission.startsWith("plot.limit.")) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public boolean execute(Player player, String[] args) {
4646
}
4747

4848
final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
49-
if(!player.isOp()) {
49+
if(!player.hasPermission("plot.limit.unlimited")) {
5050
int maxLimit = -1;
5151
for(String permission : player.getEffectivePermissions().keySet()) {
5252
if(permission.startsWith("plot.limit.")) {

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ public boolean execute(Player player, String[] args) {
4343
return false;
4444
}
4545

46-
if(player.hasPermission("plot.command.admin.dispose") || plot.isOwner(player.getUniqueId())) {
47-
plotManager.disposePlot(plot);
48-
plotManager.savePlots();
49-
player.sendMessage(this.translate(player, TranslationKey.DISPOSE_SUCCESS));
50-
return true;
51-
} else {
46+
if(!plot.isOwner(player.getUniqueId()) && !player.hasPermission("plot.command.admin.dispose")) {
5247
player.sendMessage(this.translate(player, TranslationKey.DISPOSE_FAILURE));
5348
return false;
5449
}
50+
51+
if(!plotManager.disposePlot(plot)) {
52+
player.sendMessage(this.translate(player, TranslationKey.DISPOSE_FAILURE_COULD_NOT_DISPOSE));
53+
return false;
54+
}
55+
56+
plotManager.savePlots();
57+
player.sendMessage(this.translate(player, TranslationKey.DISPOSE_SUCCESS));
58+
return true;
5559
}
5660

5761
}

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

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -52,64 +52,55 @@ public boolean execute(Player player, String[] args) {
5252
final int dir = (NukkitMath.floorDouble((player.getYaw() * 4 / 360) + 0.5) - 2) & 3;
5353
final Set<Plot> plotsToMerge = plotManager.calculatePlotsToMerge(plot, dir);
5454

55-
boolean isOwner = player.hasPermission("plot.command.admin.merge");
56-
if(!isOwner) {
57-
isOwner = true;
55+
if(!player.hasPermission("plot.command.admin.merge")) {
5856
for(Plot plotToMerge : plotsToMerge) {
5957
if(!plotToMerge.isOwner(player.getUniqueId())) {
60-
isOwner = false;
61-
break;
58+
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_OWNER));
59+
return false;
6260
}
6361
}
6462
}
6563

66-
if(isOwner) {
67-
if(!player.hasPermission("plot.merge.unlimited") && !player.isOp()) {
68-
if(!player.isOp()) {
69-
int maxLimit = -1;
70-
for(String permission : player.getEffectivePermissions().keySet()) {
71-
if(permission.startsWith("plot.merge.limit.")) {
72-
try {
73-
final String limitStr = permission.substring("plot.merge.limit.".length());
74-
if(limitStr.isBlank()) continue;
75-
final int limit = Integer.parseInt(limitStr);
76-
77-
if(limit > maxLimit) maxLimit = limit;
78-
} catch(NumberFormatException ignored) {
79-
}
80-
}
81-
}
82-
83-
if(maxLimit > 0 && plotsToMerge.size() > maxLimit) {
84-
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_TOO_MANY, plotsToMerge.size()));
85-
return false;
64+
if(!player.hasPermission("plot.merge.limit.unlimited")) {
65+
int maxLimit = -1;
66+
for(String permission : player.getEffectivePermissions().keySet()) {
67+
if(permission.startsWith("plot.merge.limit.")) {
68+
try {
69+
final String limitStr = permission.substring("plot.merge.limit.".length());
70+
if(limitStr.isBlank()) continue;
71+
final int limit = Integer.parseInt(limitStr);
72+
73+
if(limit > maxLimit) maxLimit = limit;
74+
} catch(NumberFormatException ignored) {
8675
}
8776
}
8877
}
8978

90-
if(plot.isMerged(dir)) {
91-
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_ALREADY_MERGED));
79+
if(maxLimit > 0 && plotsToMerge.size() > maxLimit) {
80+
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_TOO_MANY, plotsToMerge.size()));
9281
return false;
9382
}
83+
}
9484

95-
final PlotPreMergeEvent plotPreMergeEvent = new PlotPreMergeEvent(player, plot, dir, plotsToMerge);
96-
this.plugin.getServer().getPluginManager().callEvent(plotPreMergeEvent);
97-
if(plotPreMergeEvent.isCancelled()) return false;
98-
99-
if(!plotManager.startMerge(plot, plotsToMerge)) {
100-
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_NO_PLOTS_FOUND));
101-
return false;
102-
}
85+
if(plot.isMerged(dir)) {
86+
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_ALREADY_MERGED));
87+
return false;
88+
}
10389

104-
final PlotMergeEvent plotMergeEvent = new PlotMergeEvent(player, plot, plotsToMerge);
105-
this.plugin.getServer().getPluginManager().callEvent(plotMergeEvent);
90+
final PlotPreMergeEvent plotPreMergeEvent = new PlotPreMergeEvent(player, plot, dir, plotsToMerge);
91+
this.plugin.getServer().getPluginManager().callEvent(plotPreMergeEvent);
92+
if(plotPreMergeEvent.isCancelled()) return false;
10693

107-
player.sendMessage(this.translate(player, TranslationKey.MERGE_SUCCESS));
108-
return true;
109-
} else {
110-
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_OWNER));
94+
if(!plotManager.startMerge(plot, plotsToMerge)) {
95+
player.sendMessage(this.translate(player, TranslationKey.MERGE_FAILURE_NO_PLOTS_FOUND));
11196
return false;
11297
}
98+
99+
final PlotMergeEvent plotMergeEvent = new PlotMergeEvent(player, plot, plotsToMerge);
100+
this.plugin.getServer().getPluginManager().callEvent(plotMergeEvent);
101+
102+
player.sendMessage(this.translate(player, TranslationKey.MERGE_SUCCESS));
103+
return true;
113104
}
114105

115106
}

0 commit comments

Comments
 (0)