Skip to content

Commit 07d6a82

Browse files
authored
Update 1.2.0 (#15)
1 parent 2617312 commit 07d6a82

39 files changed

Lines changed: 1054 additions & 833 deletions

pom.xml

Lines changed: 7 additions & 2 deletions
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.2</version>
9+
<version>1.2.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>17</maven.compiler.source>
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>cn.powernukkitx</groupId>
2828
<artifactId>powernukkitx</artifactId>
29-
<version>1.6.0.0-PNX</version>
29+
<version>1.19.20-r1</version>
3030
<scope>compile</scope>
3131
</dependency>
3232
<dependency>
@@ -39,6 +39,11 @@
3939
<artifactId>gson</artifactId>
4040
<version>2.9.0</version>
4141
</dependency>
42+
<dependency>
43+
<groupId>com.github.luben</groupId>
44+
<artifactId>zstd-jni</artifactId>
45+
<version>1.5.2-3</version>
46+
</dependency>
4247
</dependencies>
4348

4449
<build>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public boolean execute(Player player, String[] args) {
6666
return false;
6767
}
6868

69-
if(plot.addHelper(targetId)) {
70-
plotManager.savePlots();
71-
player.sendMessage(this.translate(player, TranslationKey.ADDED_HELPER, this.plugin.getCorrectName(targetId)));
72-
return true;
73-
} else {
69+
if(!plot.addHelper(targetId)) {
7470
player.sendMessage(this.translate(player, TranslationKey.ALREADY_HELPER, this.plugin.getCorrectName(targetId)));
7571
return false;
7672
}
73+
74+
plotManager.savePlots();
75+
player.sendMessage(this.translate(player, TranslationKey.ADDED_HELPER, this.plugin.getCorrectName(targetId)));
76+
return true;
7777
}
7878

7979
}

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,31 @@ public boolean execute(Player player, String[] args) {
6868

6969
final Plot plot = plotManager.getNextFreePlot();
7070

71-
if(plot != null) {
72-
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, true, true);
73-
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);
74-
final PlotManager finalPlotManager = plotManager;
75-
plotPreClaimEvent.getWaiter().addTask(() -> {
76-
if(plotPreClaimEvent.isCancelled())
77-
return;
78-
79-
plot.setOwner(player.getUniqueId());
80-
if(plotPreClaimEvent.isBorderChanging())
81-
finalPlotManager.changeBorder(plot, finalPlotManager.getLevelSettings().getClaimPlotState());
82-
finalPlotManager.savePlots();
83-
84-
final PlotClaimEvent plotClaimEvent = new PlotClaimEvent(player, plot, true);
85-
this.plugin.getServer().getPluginManager().callEvent(plotClaimEvent);
86-
87-
finalPlotManager.teleportPlayerToPlot(player, plot, false);
88-
player.sendMessage(this.translate(player, TranslationKey.AUTO_SUCCESS));
89-
});
90-
return true;
91-
} else {
71+
if(plot == null) {
9272
player.sendMessage(this.translate(player, TranslationKey.AUTO_FAILURE));
9373
return false;
9474
}
75+
76+
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, true, true, true);
77+
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);
78+
79+
if(plotPreClaimEvent.isCancelled()) {
80+
if(plotPreClaimEvent.isShowCancelMessage())
81+
player.sendMessage(this.translate(player, TranslationKey.AUTO_FAILURE));
82+
return false;
83+
}
84+
85+
plot.setOwner(player.getUniqueId());
86+
if(plotPreClaimEvent.isBorderChanging())
87+
plotManager.changeBorder(plot, plotManager.getLevelSettings().getClaimPlotState());
88+
plotManager.savePlots();
89+
90+
final PlotClaimEvent plotClaimEvent = new PlotClaimEvent(player, plot, true);
91+
this.plugin.getServer().getPluginManager().callEvent(plotClaimEvent);
92+
93+
plotManager.teleportPlayerToPlot(player, plot, false);
94+
player.sendMessage(this.translate(player, TranslationKey.AUTO_SUCCESS));
95+
return true;
9596
}
9697

9798
}

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,30 @@ public boolean execute(Player player, String[] args) {
6767
}
6868
}
6969

70-
if(!plot.hasOwner()) {
71-
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, false, true);
72-
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);
73-
plotPreClaimEvent.getWaiter().addTask(() -> {
74-
if(plotPreClaimEvent.isCancelled()) return;
75-
76-
plot.setOwner(player.getUniqueId());
77-
if(plotPreClaimEvent.isBorderChanging())
78-
plotManager.changeBorder(plot, plotManager.getLevelSettings().getClaimPlotState());
79-
plotManager.savePlots();
70+
if(plot.hasOwner()) {
71+
player.sendMessage(this.translate(player, TranslationKey.CLAIM_FAILURE));
72+
return false;
73+
}
8074

81-
final PlotClaimEvent plotClaimEvent = new PlotClaimEvent(player, plot, false);
82-
this.plugin.getServer().getPluginManager().callEvent(plotClaimEvent);
75+
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, false, true, true);
76+
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);
8377

84-
player.sendMessage(this.translate(player, TranslationKey.CLAIM_SUCCESS));
85-
});
86-
return true;
87-
} else {
88-
player.sendMessage(this.translate(player, TranslationKey.CLAIM_FAILURE));
78+
if(plotPreClaimEvent.isCancelled()) {
79+
if(plotPreClaimEvent.isShowCancelMessage())
80+
player.sendMessage(this.translate(player, TranslationKey.CLAIM_FAILURE));
8981
return false;
9082
}
83+
84+
plot.setOwner(player.getUniqueId());
85+
if(plotPreClaimEvent.isBorderChanging())
86+
plotManager.changeBorder(plot, plotManager.getLevelSettings().getClaimPlotState());
87+
plotManager.savePlots();
88+
89+
final PlotClaimEvent plotClaimEvent = new PlotClaimEvent(player, plot, false);
90+
this.plugin.getServer().getPluginManager().callEvent(plotClaimEvent);
91+
92+
player.sendMessage(this.translate(player, TranslationKey.CLAIM_SUCCESS));
93+
return true;
9194
}
9295

9396
}

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

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

46-
if((player.hasPermission("plot.command.admin.clear") || plot.isOwner(player.getUniqueId())) && plotManager.clearPlot(plot)) {
47-
plotManager.savePlots();
48-
player.sendMessage(this.translate(player, TranslationKey.CLEAR_SUCCESS));
49-
return true;
50-
} else {
46+
if(!plot.isOwner(player.getUniqueId()) && !player.hasPermission("plot.command.admin.clear")) {
47+
player.sendMessage(this.translate(player, TranslationKey.NO_PLOT_OWNER));
48+
return false;
49+
}
50+
51+
if(!plotManager.clearPlot(plot)) {
5152
player.sendMessage(this.translate(player, TranslationKey.CLEAR_FAILURE));
5253
return false;
5354
}
55+
56+
plotManager.savePlots();
57+
player.sendMessage(this.translate(player, TranslationKey.CLEAR_SUCCESS));
58+
return true;
5459
}
5560

5661
}

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,29 @@ public boolean execute(Player player, String[] args) {
6969
return false;
7070
}
7171

72-
if(plot.denyPlayer(targetId)) {
73-
plotManager.savePlots();
72+
if(!plot.denyPlayer(targetId)) {
73+
player.sendMessage(this.translate(player, TranslationKey.DENY_FAILURE, this.plugin.getCorrectName(targetId)));
74+
return false;
75+
}
76+
77+
plotManager.savePlots();
7478

75-
if(target != null || isEveryone) {
76-
if(!isEveryone) {
77-
final Plot plot1 = plotManager.getMergedPlot(target.getFloorX(), target.getFloorZ());
78-
if(plot1 != null && (plot.getId().equals(plot1.getId())) && !target.hasPermission("plot.admin.bypass.deny"))
79-
plotManager.teleportPlayerToPlot(target, plot1, false);
80-
} else {
81-
for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers().values()) {
82-
final Plot plot1 = plotManager.getMergedPlot(onlinePlayer.getFloorX(), onlinePlayer.getFloorZ());
83-
if(!plot.isOwner(onlinePlayer.getUniqueId()) && !plot.isHelper(onlinePlayer.getUniqueId()) && plot1 != null && (plot.getId().equals(plot1.getId())) && !onlinePlayer.hasPermission("plot.admin.bypass.deny"))
84-
plotManager.teleportPlayerToPlot(onlinePlayer, plot1, false);
85-
}
79+
if(target != null || isEveryone) {
80+
if(!isEveryone) {
81+
final Plot plot1 = plotManager.getMergedPlot(target.getFloorX(), target.getFloorZ());
82+
if(plot1 != null && (plot.getId().equals(plot1.getId())) && !target.hasPermission("plot.admin.bypass.deny"))
83+
plotManager.teleportPlayerToPlot(target, plot1, false);
84+
} else {
85+
for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers().values()) {
86+
final Plot plot1 = plotManager.getMergedPlot(onlinePlayer.getFloorX(), onlinePlayer.getFloorZ());
87+
if(!plot.isOwner(onlinePlayer.getUniqueId()) && !plot.isHelper(onlinePlayer.getUniqueId()) && plot1 != null && (plot.getId().equals(plot1.getId())) && !onlinePlayer.hasPermission("plot.admin.bypass.deny"))
88+
plotManager.teleportPlayerToPlot(onlinePlayer, plot1, false);
8689
}
8790
}
88-
89-
player.sendMessage(this.translate(player, TranslationKey.DENY_SUCCESS, this.plugin.getCorrectName(targetId)));
90-
return true;
91-
} else {
92-
player.sendMessage(this.translate(player, TranslationKey.DENY_FAILURE, this.plugin.getCorrectName(targetId)));
93-
return false;
9491
}
92+
93+
player.sendMessage(this.translate(player, TranslationKey.DENY_SUCCESS, this.plugin.getCorrectName(targetId)));
94+
return true;
9595
}
9696

9797
}

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package ms.kevi.plotplugin.command.defaults;
1818

1919
import cn.nukkit.Player;
20+
import cn.nukkit.command.data.CommandEnum;
2021
import cn.nukkit.command.data.CommandParamType;
2122
import cn.nukkit.command.data.CommandParameter;
2223
import ms.kevi.plotplugin.PlotPlugin;
@@ -36,7 +37,7 @@ public GenerateCommand(PlotPlugin plugin, PlotCommand parent) {
3637
super(plugin, parent, "generate");
3738
this.setPermission("plot.command.admin.generate");
3839
this.addParameter(CommandParameter.newType("level", CommandParamType.STRING));
39-
this.addParameter(CommandParameter.newEnum("default", new String[]{"true", "false"}));
40+
this.addParameter(CommandParameter.newEnum("default", new CommandEnum("should be default level?", "true", "false")));
4041
}
4142

4243
@Override
@@ -49,19 +50,16 @@ public boolean execute(Player player, String[] args) {
4950
return false;
5051
}
5152

52-
if(!this.plugin.getServer().isLevelGenerated(levelName)) {
53-
final PlotLevelRegistration levelRegistration = new PlotLevelRegistration(levelName, defaultLevel);
54-
this.plugin.getLevelRegistrationMap().put(player, levelRegistration);
55-
player.sendMessage(this.translate(player, TranslationKey.GENERATE_START, levelName));
56-
player.sendMessage(this.translate(player, TranslationKey.GENERATE_DIMENSION, levelRegistration.getLevelSettings().getDimension()));
57-
return true;
58-
} else {
59-
if(!this.plugin.getServer().isLevelLoaded(levelName))
60-
this.plugin.getServer().loadLevel(levelName);
61-
player.teleport(this.plugin.getServer().getLevelByName(levelName).getSpawnLocation());
53+
if(this.plugin.getServer().isLevelGenerated(levelName)) {
6254
player.sendMessage(this.translate(player, TranslationKey.GENERATE_FAILURE));
6355
return false;
6456
}
57+
58+
final PlotLevelRegistration levelRegistration = new PlotLevelRegistration(levelName, defaultLevel);
59+
this.plugin.getLevelRegistrationMap().put(player, levelRegistration);
60+
player.sendMessage(this.translate(player, TranslationKey.GENERATE_START, levelName));
61+
player.sendMessage(this.translate(player, TranslationKey.GENERATE_DIMENSION, levelRegistration.getLevelSettings().getDimension()));
62+
return true;
6563
}
6664

6765
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,34 @@ public boolean execute(Player player, String[] args) {
6060
return false;
6161
}
6262

63-
final List<Plot> plots;
64-
if((plots = plotManager.getPlotsByOwner(targetId)).size() != 0) {
65-
if(plotId < plots.size()) {
66-
final Plot plot = plots.get(plotId);
67-
final boolean canPerform = (!plot.isDenied(player.getUniqueId()) && !plot.isDenied(Utils.UUID_EVERYONE)) || player.hasPermission("plot.admin.bypass.deny");
68-
if(targetName.equalsIgnoreCase(player.getName())) {
69-
player.sendMessage(this.translate(player, TranslationKey.HOME_SUCCESS_OWN));
70-
plotManager.teleportPlayerToPlot(player, plots.get(plotId));
71-
} else if(canPerform) {
72-
player.sendMessage(this.translate(player, TranslationKey.HOME_SUCCESS, this.plugin.getCorrectName(targetId)));
73-
plotManager.teleportPlayerToPlot(player, plots.get(plotId));
74-
} else
75-
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_DENIED));
76-
return true;
77-
} else {
78-
if(targetName.equalsIgnoreCase(player.getName()))
79-
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_OWN_ID, plotId + 1));
80-
else
81-
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_ID, this.plugin.getCorrectName(targetId), plotId + 1));
82-
return false;
83-
}
84-
} else {
63+
final List<Plot> plots = plotManager.getPlotsByOwner(targetId);
64+
if(plots.isEmpty()) {
8565
if(targetName.equalsIgnoreCase(player.getName()))
8666
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_OWN));
8767
else
8868
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE, this.plugin.getCorrectName(targetId)));
8969
return false;
9070
}
71+
72+
if(plotId >= plots.size()) {
73+
if(targetName.equalsIgnoreCase(player.getName()))
74+
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_OWN_ID, plotId + 1));
75+
else
76+
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_ID, this.plugin.getCorrectName(targetId), plotId + 1));
77+
return false;
78+
}
79+
80+
final Plot plot = plots.get(plotId);
81+
final boolean canPerform = (!plot.isDenied(player.getUniqueId()) && !plot.isDenied(Utils.UUID_EVERYONE)) || player.hasPermission("plot.admin.bypass.deny");
82+
if(targetName.equalsIgnoreCase(player.getName())) {
83+
player.sendMessage(this.translate(player, TranslationKey.HOME_SUCCESS_OWN));
84+
plotManager.teleportPlayerToPlot(player, plots.get(plotId));
85+
} else if(canPerform) {
86+
player.sendMessage(this.translate(player, TranslationKey.HOME_SUCCESS, this.plugin.getCorrectName(targetId)));
87+
plotManager.teleportPlayerToPlot(player, plots.get(plotId));
88+
} else
89+
player.sendMessage(this.translate(player, TranslationKey.HOME_FAILURE_DENIED));
90+
return true;
9191
}
9292

9393
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,32 @@ public boolean execute(Player player, String[] args) {
5252
for(PlotManager plotManager : this.plugin.getPlotManagerMap().values())
5353
plots.put(plotManager, plotManager.getPlotsByOwner(player.getUniqueId()));
5454

55-
if(plots.size() != 0) {
56-
final List<Plot> allPlots = new ArrayList<>();
57-
for(List<Plot> list : plots.values()) allPlots.addAll(list);
58-
59-
final PaginationList<Plot> pages = new PaginationList<>(allPlots, this.plugin.getPlotsPerPage());
60-
61-
if(page < 0 || page >= pages.size()) {
62-
player.sendMessage(this.translate(player, TranslationKey.HOMES_FAILURE_PAGE_DID_NOT_EXIST, page + 1));
63-
return false;
64-
}
55+
if(plots.isEmpty()) {
56+
player.sendMessage(this.translate(player, TranslationKey.HOMES_FAILURE));
57+
return false;
58+
}
6559

66-
player.sendMessage(this.translate(player, TranslationKey.HOMES_TITLE, page + 1, pages.size()));
60+
final List<Plot> allPlots = new ArrayList<>();
61+
for(List<Plot> list : plots.values()) allPlots.addAll(list);
6762

68-
for(Plot plot : pages.get(page))
69-
player.sendMessage(this.translate(player, TranslationKey.HOMES_ENTRY,
70-
plots.get(plot.getManager()).indexOf(plot) + 1,
71-
plot.getId(),
72-
plot.getManager().getLevel().getName()
73-
));
63+
final PaginationList<Plot> pages = new PaginationList<>(allPlots, this.plugin.getPlotsPerPage());
7464

75-
player.sendMessage(this.translate(player, TranslationKey.HOMES_END));
76-
return true;
77-
} else {
78-
player.sendMessage(this.translate(player, TranslationKey.HOMES_FAILURE));
65+
if(page < 0 || page >= pages.size()) {
66+
player.sendMessage(this.translate(player, TranslationKey.HOMES_FAILURE_PAGE_DID_NOT_EXIST, page + 1));
7967
return false;
8068
}
69+
70+
player.sendMessage(this.translate(player, TranslationKey.HOMES_TITLE, page + 1, pages.size()));
71+
72+
for(Plot plot : pages.get(page))
73+
player.sendMessage(this.translate(player, TranslationKey.HOMES_ENTRY,
74+
plots.get(plot.getManager()).indexOf(plot) + 1,
75+
plot.getId(),
76+
plot.getManager().getLevel().getName()
77+
));
78+
79+
player.sendMessage(this.translate(player, TranslationKey.HOMES_END));
80+
return true;
8181
}
8282

8383
}

0 commit comments

Comments
 (0)