diff --git a/README.md b/README.md index 9dbe38f..9f1225c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Commands and Permissions | ~ | reload | plot.command.admin.reload | --- | | ~ | removehelper | --- | remove, untrust | | ~ | sethome | --- | --- | -| ~ | setowner | --- | --- | +| ~ | setowner | plot.command.setowner | --- | | ~ | setroads | plot.command.admin.setroads | --- | | ~ | setting | --- | config | | ~ | teleport | plot.command.admin.teleport | tp | @@ -71,32 +71,32 @@ Commands that need to be enabled in config.yml 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. | -| plot.command.admin.dispose | Bypasses the owner check when disposing a plot. | -| plot.command.admin.info | Bypasses the empty check when seeing the information of a plot. | -| plot.command.admin.kick | Bypasses the owner check when kicking a player from a plot. | -| plot.command.admin.merge | Bypasses the owner check when merging a plot. | -| plot.command.admin.removehelper | Bypasses the owner check when removing a helper from a plot. | -| plot.command.admin.sethome | Bypasses the owner check when setting the spawn point of a plot. | -| plot.command.admin.setowner | Bypasses the owner check when setting the owner of a plot. | -| 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.merge.unlimited | Allows you to merge unlimited plots. | -| plot.merge.limit.\ | Limits the player to only merge up to the given amount of plots. | -| plot.limit.\ | Limits the player to only claim up to the given amount of plots. | \ No newline at end of file +| Permission | Description | +|---------------------------------|-----------------------------------------------------------------------------------------| +| 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. | +| plot.command.admin.dispose | Bypasses the owner check when disposing a plot. | +| plot.command.admin.info | Bypasses the empty check when seeing the information of a plot. | +| plot.command.admin.kick | Bypasses the owner check when kicking a player from a plot. | +| plot.command.admin.merge | Bypasses the owner check when merging a plot. | +| plot.command.admin.removehelper | Bypasses the owner check when removing a helper from a plot. | +| plot.command.admin.sethome | Bypasses the owner check when setting the spawn point of a plot. | +| plot.command.admin.setowner | Bypasses the owner check, self check and player limit when setting the owner of a plot. | +| 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.merge.unlimited | Allows you to merge unlimited plots. | +| plot.merge.limit.\ | Limits the player to only merge up to the given amount of plots. | +| plot.limit.\ | Limits the player to only claim up to the given amount of plots. | \ No newline at end of file diff --git a/pom.xml b/pom.xml index c643a20..44520f5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ms.kevi plotplugin - 1.1.0 + 1.1.1 17 diff --git a/src/main/java/ms/kevi/plotplugin/command/defaults/SetOwnerCommand.java b/src/main/java/ms/kevi/plotplugin/command/defaults/SetOwnerCommand.java index 8f2f594..27f65c5 100644 --- a/src/main/java/ms/kevi/plotplugin/command/defaults/SetOwnerCommand.java +++ b/src/main/java/ms/kevi/plotplugin/command/defaults/SetOwnerCommand.java @@ -36,6 +36,7 @@ public class SetOwnerCommand extends SubCommand { public SetOwnerCommand(PlotPlugin plugin, PlotCommand parent) { super(plugin, parent, "setowner"); + this.setPermission("plot.command.setowner"); this.addParameter(CommandParameter.newType("player", CommandParamType.TARGET)); } @@ -52,8 +53,8 @@ public boolean execute(Player player, String[] args) { final UUID targetId = this.plugin.getUniqueIdByName(targetName, false); final Player target = targetId != null ? player.getServer().getPlayer(targetId).orElse(null) : null; - if(targetName.equalsIgnoreCase(player.getName()) && !player.hasPermission("plot.command.admin.setowner")) { - player.sendMessage(this.translate(player, TranslationKey.PLAYER_SELF)); + if(!plot.isOwner(player.getUniqueId()) && !player.hasPermission("plot.command.admin.setowner")) { + player.sendMessage(this.translate(player, TranslationKey.NO_PLOT_OWNER)); return false; } @@ -62,15 +63,42 @@ public boolean execute(Player player, String[] args) { return false; } - if(!player.hasPermission("plot.command.admin.setowner") && !plot.isOwner(player.getUniqueId())) { - player.sendMessage(this.translate(player, TranslationKey.NO_PLOT_OWNER)); + if(target == null) { + player.sendMessage(this.translate(player, TranslationKey.PLAYER_NOT_ONLINE)); + return false; + } + + if(targetName.equalsIgnoreCase(player.getName()) && !player.hasPermission("plot.command.admin.setowner")) { + player.sendMessage(this.translate(player, TranslationKey.PLAYER_SELF)); return false; } + final int ownedPlots = plotManager.getPlotsByOwner(targetId).size(); + if(!target.isOp() && !player.hasPermission("plot.command.admin.setowner")) { + int maxLimit = -1; + for(String permission : target.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.SETOWNER_FAILURE_TOO_MANY)); + return false; + } + } + plot.setOwner(targetId); plotManager.savePlots(); - if(target != null) - target.sendMessage(this.translate(player, TranslationKey.SETOWNER_SUCCESS_TARGET, plot.getId())); + + target.sendMessage(this.translate(target, TranslationKey.SETOWNER_SUCCESS_TARGET, plot.getId())); player.sendMessage(this.translate(player, TranslationKey.SETOWNER_SUCCESS, this.plugin.getCorrectName(targetId))); return true; } diff --git a/src/main/java/ms/kevi/plotplugin/lang/TranslationKey.java b/src/main/java/ms/kevi/plotplugin/lang/TranslationKey.java index af017ee..34063f0 100644 --- a/src/main/java/ms/kevi/plotplugin/lang/TranslationKey.java +++ b/src/main/java/ms/kevi/plotplugin/lang/TranslationKey.java @@ -148,6 +148,7 @@ public enum TranslationKey { RELOAD_SUCCESS, REMOVED_HELPER, SETHOME_SUCCESS, + SETOWNER_FAILURE_TOO_MANY, SETOWNER_SUCCESS, SETOWNER_SUCCESS_TARGET, SETROADS_FINISHED, diff --git a/src/main/resources/lang/de_DE.txt b/src/main/resources/lang/de_DE.txt index 139b90b..1b5da8c 100644 --- a/src/main/resources/lang/de_DE.txt +++ b/src/main/resources/lang/de_DE.txt @@ -72,6 +72,7 @@ info-end=&7====== &6Grundstücks Info &7====== info-failure=&6&lCitybuild &8&l» &r&cDieses Grundstück gehört keiner Person. removed-helper=&6&lCitybuild &8&l» &r&6{0}&r&a ist nun kein Helfer mehr! no-helper=&6&lCitybuild &8&l» &r&6{0}&r&c ist kein Helfer! +setowner-failure-too-many=&6&lCitybuild &8&l» &r&cDieser Spieler besitzt bereits die maximale Anzahl an Grundstücken! setowner-success-target=&6&lCitybuild &8&l» &r&aDu wurdest zum Besitzer des Grundstückes &6{0}&r&a ernannt! setowner-success=&6&lCitybuild &8&l» &r&6{0}&r&a ist nun Besitzer von diesem Grundstück! undeny-success=&6&lCitybuild &8&l» &r&6{0}&r&a darf nun dein Grundstück wieder betreten! diff --git a/src/main/resources/lang/en_US.txt b/src/main/resources/lang/en_US.txt index c81813c..a5ad543 100644 --- a/src/main/resources/lang/en_US.txt +++ b/src/main/resources/lang/en_US.txt @@ -74,6 +74,7 @@ info-end=&7====== &6Plot Info &7====== info-failure=&6&lCitybuild &8&l» &r&cThis plot is not owned by a player. removed-helper=&6&lCitybuild &8&l» &r&6{0}&r&a is now no longer a helper! no-helper=&6&lCitybuild &8&l» &r&6{0}&r&c is not a helper! +setowner-failure-too-many=&6&lCitybuild &8&l» &r&cThis player already has the maximum amount of plots! setowner-success-target=&6&lCitybuild &8&l» &r&aYou have been appointed the owner of the plot &6{0}&r&a! setowner-success=&6&lCitybuild &8&l» &r&6{0}&r&a is now owner of this plot! undeny-success=&6&lCitybuild &8&l» &r&6{0}&r&a may now enter your plot again! diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cfd139c..107e4d0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Plots -version: "1.1.0" +version: "1.1.1" api: [ "1.0.13" ] author: Kevims main: ms.kevi.plotplugin.PlotPlugin \ No newline at end of file