Skip to content

Commit 1635152

Browse files
authored
Update 1.0.4: New commands and first README (#5)
* 1.0.2: Fix saving languages * Update 1.0.2: Implement plot kick command * Update 1.0.3: Implement plot sethome and deletehome command * Update 1.0.4: Add README and some bug fixes * Update org.projectlombok:lombok from 1.18.22 to 1.18.24
1 parent 55b36f4 commit 1635152

20 files changed

Lines changed: 384 additions & 22 deletions

.github/images/banner.png

31.5 KB
Loading

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
![banner](./.github/images/banner.png)
2+
3+
What is this?
4+
------------------------------
5+
6+
This project functions as a plugin for the powernukkitx environment.
7+
It adds a plot system to the server, which supports changing borders, merging plots, customizing of the roads and much
8+
more.
9+
10+
How can I download this plugin?
11+
------------------------------
12+
13+
You can find the downloads on the [releases section](https://github.com/KCodeYT/PlotPlugin/releases) of this
14+
github
15+
page.
16+
There you can find the LATEST jar file of this plugin.
17+
18+
How can I create a plot world?
19+
------------------------------
20+
21+
1. Open the chat in your client.
22+
2. Ensure you have the operator status on the server or
23+
have the permission "plot.command.admin.generate",
24+
otherwise you will not be able to use this command.
25+
3. Type /plot generate followed by the name of the plot world
26+
and true or false if the world should be registered as default plot world.
27+
4. You are now in the plot world generation.
28+
You have to answer the questions shown in the chat.
29+
5. After answering all questions, you are being teleported to the newly created plot world.
30+
31+
Commands and Permissions
32+
------------------------------
33+
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 |
62+
63+
Other Permissions
64+
------------------------------
65+
66+
| Permission | Discription |
67+
|---------------------------------|--------------------------------------------------------------------------|
68+
| plot.command.admin.addhelper | Bypasses the owner check when adding a helper to a plot. |
69+
| plot.command.admin.clear | Bypasses the owner check when clearing a plot. |
70+
| plot.command.admin.deletehome | Bypasses the owner check when deleting the spawn point of a plot |
71+
| plot.command.admin.deny | Bypasses the owner check when denying a player from a plot. |
72+
| plot.command.admin.dispose | Bypasses the owner check when disposing a plot. |
73+
| plot.command.admin.info | Bypasses the empty check when seeing the information of a plot. |
74+
| plot.command.admin.kick | Bypasses the owner check when kicking a player from a plot. |
75+
| plot.command.admin.merge | Bypasses the owner check when merging a plot. |
76+
| plot.command.admin.removehelper | Bypasses the owner check when removing a helper from a plot. |
77+
| plot.command.admin.sethome | Bypasses the owner check when setting the spawn point of a plot. |
78+
| plot.command.admin.setowner | Bypasses the owner check when setting the owner of a plot. |
79+
| plot.command.admin.config | Bypasses the owner check when setting the configuration of a plot. |
80+
| plot.command.admin.undeny | Bypasses the owner check when undenying a player from a plot. |
81+
| plot.command.admin.unlink | Bypasses the owner check when unlinking a plot. |
82+
| plot.admin.bypass.deny | Bypasses the denial of a player from a plot. |
83+
| plot.admin.bypass.kick | Bypasses the kick of a player from a plot. |
84+
| plot.admin.interact | Allows you to interact with blocks on the road. |
85+
| plot.admin.damage | Allows you to damage players on roads or if pvp is disabled on the plot. |
86+
| plot.admin.bucket.fill | Allows you to fill up buckets from the road. |
87+
| plot.admin.bucket.emtpy | Allows you to empty buckets from the road. |
88+
| plot.admin.break | Allows you to break blocks on the road. |
89+
| plot.admin.place | Allows you to place blocks on the road. |

pom.xml

Lines changed: 2 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.0.1</version>
9+
<version>1.0.4</version>
1010

1111
<properties>
1212
<maven.compiler.source>17</maven.compiler.source>
@@ -32,7 +32,7 @@
3232
<dependency>
3333
<groupId>org.projectlombok</groupId>
3434
<artifactId>lombok</artifactId>
35-
<version>1.18.22</version>
35+
<version>1.18.24</version>
3636
</dependency>
3737
<dependency>
3838
<groupId>com.google.code.gson</groupId>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,12 @@ public void registerPlayer(Player player) {
242242
}
243243

244244
public UUID getUniqueIdByName(String playerName) {
245+
return this.getUniqueIdByName(playerName, true);
246+
}
247+
248+
public UUID getUniqueIdByName(String playerName, boolean allowEveryone) {
245249
final String firstPlayerName = playerName.trim();
246-
if(firstPlayerName.equals(Utils.STRING_EVERYONE))
250+
if(allowEveryone && firstPlayerName.equals(Utils.STRING_EVERYONE))
247251
return Utils.UUID_EVERYONE;
248252

249253
for(Map.Entry<String, Object> entry : this.playersConfig.getAll().entrySet()) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,20 @@ public PlotCommand(PlotPlugin plugin) {
4545
this.subCommands.add(new AutoCommand(this.plugin, this));
4646
this.subCommands.add(new ClaimCommand(this.plugin, this));
4747
this.subCommands.add(new ClearCommand(this.plugin, this));
48+
this.subCommands.add(new DeleteHomeCommand(this.plugin, this));
4849
this.subCommands.add(new DenyCommand(this.plugin, this));
4950
this.subCommands.add(new DisposeCommand(this.plugin, this));
5051
this.subCommands.add(new GenerateCommand(this.plugin, this));
5152
this.subCommands.add(new HomeCommand(this.plugin, this));
5253
this.subCommands.add(new HomesCommand(this.plugin, this));
5354
this.subCommands.add(new InfoCommand(this.plugin, this));
55+
this.subCommands.add(new KickCommand(this.plugin, this));
5456
this.subCommands.add(new MergeCommand(this.plugin, this));
5557
this.subCommands.add(new RegenAllRoadsCommand(this.plugin, this));
5658
this.subCommands.add(new RegenRoadCommand(this.plugin, this));
5759
this.subCommands.add(new ReloadCommand(this.plugin, this));
5860
this.subCommands.add(new RemoveHelperCommand(this.plugin, this));
61+
this.subCommands.add(new SetHomeCommand(this.plugin, this));
5962
this.subCommands.add(new SetOwnerCommand(this.plugin, this));
6063
this.subCommands.add(new SetRoadsCommand(this.plugin, this));
6164
this.subCommands.add(new SettingCommand(this.plugin, this));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public boolean execute(Player player, String[] args) {
6262
final PlotClaimEvent plotClaimEvent = new PlotClaimEvent(player, plot, true);
6363
this.plugin.getServer().getPluginManager().callEvent(plotClaimEvent);
6464

65-
finalPlotManager.teleportPlayerToPlot(player, plot);
65+
finalPlotManager.teleportPlayerToPlot(player, plot, false);
6666
player.sendMessage(this.translate(player, TranslationKey.AUTO_SUCCESS));
6767
});
6868
return true;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2022 KCodeYT
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package ms.kevi.plotplugin.command.defaults;
18+
19+
import cn.nukkit.Player;
20+
import ms.kevi.plotplugin.PlotPlugin;
21+
import ms.kevi.plotplugin.command.PlotCommand;
22+
import ms.kevi.plotplugin.command.SubCommand;
23+
import ms.kevi.plotplugin.lang.TranslationKey;
24+
import ms.kevi.plotplugin.manager.PlotManager;
25+
import ms.kevi.plotplugin.util.Plot;
26+
27+
/**
28+
* @author Kevims KCodeYT
29+
* @version 1.0
30+
*/
31+
public class DeleteHomeCommand extends SubCommand {
32+
33+
public DeleteHomeCommand(PlotPlugin plugin, PlotCommand parent) {
34+
super(plugin, parent, "deletehome", "delhome", "removehome", "rmhome");
35+
}
36+
37+
@Override
38+
public boolean execute(Player player, String[] args) {
39+
final PlotManager plotManager = this.plugin.getPlotManager(player.getLevel());
40+
final Plot plot;
41+
if(plotManager == null || (plot = plotManager.getMergedPlot(player.getFloorX(), player.getFloorZ())) == null) {
42+
player.sendMessage(this.translate(player, TranslationKey.NO_PLOT));
43+
return false;
44+
}
45+
46+
if(!player.hasPermission("plot.command.admin.deletehome") && !plot.isOwner(player.getUniqueId())) {
47+
player.sendMessage(this.translate(player, TranslationKey.NO_PLOT_OWNER));
48+
return false;
49+
}
50+
51+
if(plot.getHomePosition() == null) {
52+
player.sendMessage(this.translate(player, TranslationKey.DELETEHOME_FAILURE_NO_HOME_SET));
53+
return false;
54+
}
55+
56+
for(Plot mergedPlot : plotManager.getConnectedPlots(plot)) mergedPlot.setHomePosition(null);
57+
plotManager.savePlots();
58+
player.sendMessage(this.translate(player, TranslationKey.DELETEHOME_SUCCESS));
59+
return true;
60+
}
61+
62+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ public boolean execute(Player player, String[] args) {
7575
if(target != null || isEveryone) {
7676
if(!isEveryone) {
7777
final Plot plot1 = plotManager.getMergedPlot(target.getFloorX(), target.getFloorZ());
78-
if(plot1 != null && (plot.getId().equals(plot1.getId())) && !target.hasPermission("plot.admin.nodeny"))
79-
plotManager.teleportPlayerToPlot(target, plot1);
78+
if(plot1 != null && (plot.getId().equals(plot1.getId())) && !target.hasPermission("plot.admin.bypass.deny"))
79+
plotManager.teleportPlayerToPlot(target, plot1, false);
8080
} else {
8181
for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers().values()) {
8282
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.nodeny"))
84-
plotManager.teleportPlayerToPlot(onlinePlayer, plot1);
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);
8585
}
8686
}
8787
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public boolean execute(Player player, String[] args) {
5353
if(plotId < 0) plotId = 0;
5454

5555
final String targetName = (args.length >= 2 ? this.plugin.findPlayerName(args[0]) : player.getName()).trim();
56-
final UUID targetId = this.plugin.getUniqueIdByName(targetName);
56+
final UUID targetId = this.plugin.getUniqueIdByName(targetName, false);
5757

5858
if(targetName.isEmpty() || targetId == null) {
5959
player.sendMessage(this.translate(player, TranslationKey.NO_PLAYER));
@@ -64,7 +64,7 @@ public boolean execute(Player player, String[] args) {
6464
if((plots = plotManager.getPlotsByOwner(targetId)).size() != 0) {
6565
if(plotId < plots.size()) {
6666
final Plot plot = plots.get(plotId);
67-
final boolean canPerform = (!plot.isDenied(player.getUniqueId()) && !plot.isDenied(Utils.UUID_EVERYONE)) || player.hasPermission("plot.admin.nodeny");
67+
final boolean canPerform = (!plot.isDenied(player.getUniqueId()) && !plot.isDenied(Utils.UUID_EVERYONE)) || player.hasPermission("plot.admin.bypass.deny");
6868
if(targetName.equalsIgnoreCase(player.getName())) {
6969
player.sendMessage(this.translate(player, TranslationKey.HOME_SUCCESS_OWN));
7070
plotManager.teleportPlayerToPlot(player, plots.get(plotId));
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright 2022 KCodeYT
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package ms.kevi.plotplugin.command.defaults;
18+
19+
import cn.nukkit.Player;
20+
import cn.nukkit.command.data.CommandParamType;
21+
import cn.nukkit.command.data.CommandParameter;
22+
import ms.kevi.plotplugin.PlotPlugin;
23+
import ms.kevi.plotplugin.command.PlotCommand;
24+
import ms.kevi.plotplugin.command.SubCommand;
25+
import ms.kevi.plotplugin.lang.TranslationKey;
26+
import ms.kevi.plotplugin.manager.PlotManager;
27+
import ms.kevi.plotplugin.util.Plot;
28+
29+
import java.util.UUID;
30+
31+
/**
32+
* @author Kevims KCodeYT
33+
* @version 1.0
34+
*/
35+
public class KickCommand extends SubCommand {
36+
37+
public KickCommand(PlotPlugin plugin, PlotCommand parent) {
38+
super(plugin, parent, "kick");
39+
this.addParameter(CommandParameter.newType("player", CommandParamType.TARGET));
40+
}
41+
42+
@Override
43+
public boolean execute(Player player, String[] args) {
44+
final PlotManager plotManager = this.plugin.getPlotManager(player.getLevel());
45+
final Plot plot;
46+
if(plotManager == null || (plot = plotManager.getMergedPlot(player.getFloorX(), player.getFloorZ())) == null) {
47+
player.sendMessage(this.translate(player, TranslationKey.NO_PLOT));
48+
return false;
49+
}
50+
51+
final String targetName = (args.length > 0 ? args[0] : "").trim();
52+
final UUID targetId = this.plugin.getUniqueIdByName(targetName, false);
53+
final Player target = targetId != null ? player.getServer().getPlayer(targetId).orElse(null) : null;
54+
55+
if(!player.hasPermission("plot.command.admin.kick") && !plot.isOwner(player.getUniqueId())) {
56+
player.sendMessage(this.translate(player, TranslationKey.NO_PLOT_OWNER));
57+
return false;
58+
}
59+
60+
if(targetName.equalsIgnoreCase(player.getName())) {
61+
player.sendMessage(this.translate(player, TranslationKey.PLAYER_SELF));
62+
return false;
63+
}
64+
65+
if(targetName.isEmpty() || targetId == null) {
66+
player.sendMessage(this.translate(player, TranslationKey.NO_PLAYER));
67+
return false;
68+
}
69+
70+
if(target == null) {
71+
player.sendMessage(this.translate(player, TranslationKey.PLAYER_NOT_ONLINE));
72+
return false;
73+
}
74+
75+
if(target.hasPermission("plot.admin.bypass.kick") || plot.isHelper(targetId) || plot.isOwner(targetId)) {
76+
player.sendMessage(this.translate(player, TranslationKey.KICK_CANNOT_PERFORM));
77+
return false;
78+
}
79+
80+
final PlotManager targetPlotManager = this.plugin.getPlotManager(target.getLevel());
81+
final Plot targetPlot;
82+
if(targetPlotManager == null || (targetPlot = targetPlotManager.getMergedPlot(target.getFloorX(), target.getFloorZ())) == null) {
83+
player.sendMessage(this.translate(player, TranslationKey.KICK_CANNOT_PERFORM));
84+
return false;
85+
}
86+
87+
if(!targetPlot.getBasePlot().equals(plot.getBasePlot())) {
88+
player.sendMessage(this.translate(player, TranslationKey.KICK_CANNOT_PERFORM));
89+
return false;
90+
}
91+
92+
plotManager.teleportPlayerToPlot(target, plot.getBasePlot(), false);
93+
player.sendMessage(this.translate(player, TranslationKey.KICK_PLAYER_KICKED, target.getName()));
94+
return true;
95+
}
96+
97+
}

0 commit comments

Comments
 (0)