Skip to content

Commit

Permalink
Update 1.1.0: New commands and fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KCodeYT authored Jul 29, 2022
1 parent e3470b3 commit c6b6ff0
Show file tree
Hide file tree
Showing 22 changed files with 642 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/[email protected]
with:
name: PowerNukkitX
path: PowerNukkitX/target/powernukkitx-1.6.0.0-PNX-SNAPSHOT-shaded.jar
path: PowerNukkitX/target/powernukkitx-1.6.0.0-PNX-shaded.jar

- name: Get name and version from pom.xml
run: |
Expand Down
71 changes: 42 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,50 @@ How can I create a plot world?
Commands and Permissions
------------------------------

| Command | Sub command | Permission | Aliases |
|-----------|-----------------|------------------------------------|-------------------------------|
| /plot | --- | --- | --- |
| ~ | addhelper | --- | add, trust |
| ~ | auto | --- | a |
| ~ | claim | --- | c |
| ~ | clear | --- | --- |
| ~ | delethome | --- | delhome, removehome, rmhome |
| ~ | deny | --- | --- |
| ~ | dispose | --- | reset |
| ~ | generate | plot.command.admin.generate | --- |
| ~ | home | --- | h, visit, v |
| ~ | homes | --- | --- |
| ~ | info | --- | i |
| ~ | kick | --- | --- |
| ~ | merge | plot.command.admin.merge | --- |
| ~ | regenallroads | plot.command.admin.regenallroads | --- |
| ~ | regenroad | plot.command.admin.regenroad | --- |
| ~ | reload | plot.command.admin.reload | --- |
| ~ | removehelper | --- | remove, untrust |
| ~ | sethome | --- | --- |
| ~ | setowner | --- | --- |
| ~ | setroads | plot.command.admin.setroads | --- |
| ~ | setting | --- | config |
| ~ | teleport | plot.command.admin.teleport | tp |
| ~ | undeny | --- | --- |
| ~ | unlink | plot.command.admin.unlink | --- |
| ~ | warp | --- | w |
| Command | Sub command | Permission | Aliases |
|-----------|-----------------|----------------------------------|-------------------------------|
| /plot | --- | --- | --- |
| ~ | addhelper | --- | add, trust |
| ~ | auto | --- | a |
| ~ | claim | --- | c |
| ~ | clear | --- | --- |
| ~ | delethome | --- | delhome, removehome, rmhome |
| ~ | deny | --- | --- |
| ~ | dispose | --- | reset |
| ~ | generate | plot.command.admin.generate | --- |
| ~ | home | --- | h, visit, v |
| ~ | homes | --- | --- |
| ~ | info | --- | i |
| ~ | kick | --- | --- |
| ~ | merge | plot.command.merge | --- |
| ~ | regenallroads | plot.command.admin.regenallroads | --- |
| ~ | regenroad | plot.command.admin.regenroad | --- |
| ~ | reload | plot.command.admin.reload | --- |
| ~ | removehelper | --- | remove, untrust |
| ~ | sethome | --- | --- |
| ~ | setowner | --- | --- |
| ~ | setroads | plot.command.admin.setroads | --- |
| ~ | setting | --- | config |
| ~ | teleport | plot.command.admin.teleport | tp |
| ~ | undeny | --- | --- |
| ~ | unlink | plot.command.unlink | --- |
| ~ | warp | --- | w |

Commands that need to be enabled in config.yml
------------------------------

| Command | Sub command | Permission | Aliases |
|---------|-------------|---------------------|---------|
| /plot | border | plot.command.border | b |
| ~ | wall | plot.command.wall | --- |

Other Permissions
------------------------------

| Permission | Discription |
|---------------------------------|--------------------------------------------------------------------------|
| plot.command.admin.addhelper | Bypasses the owner check when adding a helper to a plot. |
| plot.command.admin.border | Bypasses the owner check when changing the plot border block. |
| plot.command.admin.clear | Bypasses the owner check when clearing a plot. |
| plot.command.admin.deletehome | Bypasses the owner check when deleting the spawn point of a plot |
| plot.command.admin.deny | Bypasses the owner check when denying a player from a plot. |
Expand All @@ -79,11 +88,15 @@ Other Permissions
| plot.command.admin.config | Bypasses the owner check when setting the configuration of a plot. |
| plot.command.admin.undeny | Bypasses the owner check when undenying a player from a plot. |
| plot.command.admin.unlink | Bypasses the owner check when unlinking a plot. |
| plot.command.admin.wall | Bypasses the owner check when changing the plot wall block. |
| plot.admin.bypass.deny | Bypasses the denial of a player from a plot. |
| plot.admin.bypass.kick | Bypasses the kick of a player from a plot. |
| plot.admin.interact | Allows you to interact with blocks on the road. |
| plot.admin.damage | Allows you to damage players on roads or if pvp is disabled on the plot. |
| plot.admin.bucket.fill | Allows you to fill up buckets from the road. |
| plot.admin.bucket.emtpy | Allows you to empty buckets from the road. |
| plot.admin.break | Allows you to break blocks on the road. |
| plot.admin.place | Allows you to place blocks on the road. |
| plot.admin.place | Allows you to place blocks on the road. |
| plot.merge.unlimited | Allows you to merge unlimited plots. |
| plot.merge.limit.\<any number> | Limits the player to only merge up to the given amount of plots. |
| plot.limit.\<any number> | Limits the player to only claim up to the given amount of plots. |
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ms.kevi</groupId>
<artifactId>plotplugin</artifactId>
<version>1.0.7</version>
<version>1.1.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/ms/kevi/plotplugin/PlotPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import ms.kevi.plotplugin.util.PlotLevelRegistration;
import ms.kevi.plotplugin.util.PlotLevelSettings;
import ms.kevi.plotplugin.util.Utils;
import ms.kevi.plotplugin.util.BlockEntry;
import ms.kevi.plotplugin.util.async.TaskExecutor;

import java.io.BufferedReader;
Expand Down Expand Up @@ -81,6 +82,15 @@ public class PlotPlugin extends PluginBase {
@Getter
private int plotsPerPage = 5;

@Getter
private boolean addOtherCommands = true;

@Getter
private final List<BlockEntry> borderEntries = new ArrayList<>();

@Getter
private final List<BlockEntry> wallEntries = new ArrayList<>();

@Override
public void onLoad() {
INSTANCE = this;
Expand Down Expand Up @@ -126,6 +136,38 @@ public void onEnable() {

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

if(!config.exists("add_other_commands")) {
config.set("add_other_commands", this.addOtherCommands);
config.save();
}

this.addOtherCommands = config.getBoolean("add_other_commands");

if(!config.exists("borders")) {
final List<Map<String, Object>> defaultWalls = new ArrayList<>();
defaultWalls.add(Utils.createMap(List.of("name", "image_type", "image_data"), List.of("reset_to_default", "PATH", "textures/ui/undoArrow")));
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")));
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")));
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")));

config.set("borders", defaultWalls);
config.save();
}

if(!config.exists("walls")) {
final List<Map<String, Object>> defaultWalls = new ArrayList<>();
defaultWalls.add(Utils.createMap(List.of("name", "image_type", "image_data"), List.of("reset_to_default", "PATH", "textures/ui/undoArrow")));
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")));
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")));
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")));

config.set("walls", defaultWalls);
config.save();
}

this.borderEntries.addAll(config.getMapList("borders").stream().map(BlockEntry::of).toList());
this.wallEntries.addAll(config.getMapList("walls").stream().map(BlockEntry::of).toList());

try {
final String defaultLang = config.getString("default_lang");

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/ms/kevi/plotplugin/command/PlotCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import cn.nukkit.command.CommandSender;
import ms.kevi.plotplugin.PlotPlugin;
import ms.kevi.plotplugin.command.defaults.*;
import ms.kevi.plotplugin.command.other.BorderCommand;
import ms.kevi.plotplugin.command.other.WallCommand;
import ms.kevi.plotplugin.lang.TranslationKey;

import java.util.Arrays;
Expand Down Expand Up @@ -66,6 +68,11 @@ public PlotCommand(PlotPlugin plugin) {
this.subCommands.add(new UndenyCommand(this.plugin, this));
this.subCommands.add(new UnlinkCommand(this.plugin, this));
this.subCommands.add(new WarpCommand(this.plugin, this));

if(this.plugin.isAddOtherCommands()) {
this.subCommands.add(new BorderCommand(this.plugin, this));
this.subCommands.add(new WallCommand(this.plugin, this));
}
}

@Override
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/ms/kevi/plotplugin/command/defaults/AutoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ public boolean execute(Player player, String[] args) {
return false;
}

final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
if(!player.isOp()) {
int maxLimit = -1;
for(String permission : player.getEffectivePermissions().keySet()) {
if(permission.startsWith("plot.limit.")) {
try {
final String limitStr = permission.substring("plot.limit.".length());
if(limitStr.isBlank()) continue;
final int limit = Integer.parseInt(limitStr);

if(limit > maxLimit) maxLimit = limit;
} catch(NumberFormatException ignored) {
}
}
}

if(maxLimit > 0 && ownedPlots >= maxLimit) {
player.sendMessage(this.translate(player, TranslationKey.AUTO_FAILURE_TOO_MANY, ownedPlots));
return false;
}
}

final Plot plot = plotManager.getNextFreePlot();

if(plot != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ public boolean execute(Player player, String[] args) {
return false;
}

final int ownedPlots = plotManager.getPlotsByOwner(player.getUniqueId()).size();
if(!player.isOp()) {
int maxLimit = -1;
for(String permission : player.getEffectivePermissions().keySet()) {
if(permission.startsWith("plot.limit.")) {
try {
final String limitStr = permission.substring("plot.limit.".length());
if(limitStr.isBlank()) continue;
final int limit = Integer.parseInt(limitStr);

if(limit > maxLimit) maxLimit = limit;
} catch(NumberFormatException ignored) {
}
}
}

if(maxLimit > 0 && ownedPlots >= maxLimit) {
player.sendMessage(this.translate(player, TranslationKey.CLAIM_FAILURE_TOO_MANY, ownedPlots));
return false;
}
}

if(!plot.hasOwner()) {
final PlotPreClaimEvent plotPreClaimEvent = new PlotPreClaimEvent(player, plot, false, true);
this.plugin.getServer().getPluginManager().callEvent(plotPreClaimEvent);
Expand Down
Loading

0 comments on commit c6b6ff0

Please sign in to comment.