mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Use hasPermissionRange to check for trust and add limits
This commit is contained in:
parent
fafdae9ba9
commit
0fcca4c141
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.permissions.Permission;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
@ -114,8 +115,11 @@ public class Add extends Command {
|
||||
size += plot.getTrusted().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
if (!(player.hasPermission("plots.add." + size) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_ADD)))
|
||||
player.sendMessage(TranslatableCaption.of("members.plot_max_members"), Template.of("amount", String.valueOf(size - 1)));
|
||||
int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS);
|
||||
if (size > maxAddSize) {
|
||||
player.sendMessage(TranslatableCaption.of("members.plot_max_members_added"), Template.of("amount", String.valueOf(size - 1)));
|
||||
return;
|
||||
}
|
||||
// Success
|
||||
confirm.run(this, () -> {
|
||||
for (UUID uuid : uuids) {
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.permissions.Permission;
|
||||
import com.plotsquared.core.configuration.caption.Templates;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
@ -128,8 +129,11 @@ public class Trust extends Command {
|
||||
size += currentPlot.getMembers().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
if (!(player.hasPermission("plots.trust." + size) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST)))
|
||||
player.sendMessage(TranslatableCaption.of("members.plot_max_members"), Template.of("amount", String.valueOf(size - 1)));
|
||||
int maxTrustSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_TRUST, Settings.Limit.MAX_PLOTS);
|
||||
if (size > maxTrustSize) {
|
||||
player.sendMessage(TranslatableCaption.of("members.plot_max_members_trusted"), Template.of("amount", String.valueOf(size - 1)));
|
||||
return;
|
||||
}
|
||||
// Success
|
||||
confirm.run(this, () -> {
|
||||
for (UUID uuid : uuids) {
|
||||
|
@ -78,6 +78,8 @@ public enum Permission {
|
||||
PERMISSION_ADMIN_COMMAND_PURGE_RATINGS("plots.admin.command.purge.ratings"),
|
||||
PERMISSION_ADMIN_COMMAND_ADD("plots.admin.command.trust"),
|
||||
PERMISSION_ADMIN_COMMAND_TRUST("plots.admin.command.trust"),
|
||||
PERMISSION_TRUST("plots.trust"),
|
||||
PERMISSION_ADD("plots.add"),
|
||||
PERMISSION_TRUST_EVERYONE("plots.trust.everyone"),
|
||||
PERMISSION_AREA_CREATE("plots.area.create"),
|
||||
PERMISSION_AREA_INFO("plots.area.info"),
|
||||
|
@ -452,7 +452,8 @@
|
||||
"member.already_owner": "<prefix><gray><player></gray><gold> is already the plot owner.</gold>",
|
||||
"member.already_added": "<prefix><gray>That user is already added to that category: <player></gray>",
|
||||
"member.member_added": "<prefix><dark_aqua>That user can now build while the plot owner is online.</dark_aqua>",
|
||||
"members.plot_max_members": "<prefix><red>You are not allowed to add more than </red><gold><amount></gold><red> players to this plot.</red>",
|
||||
"members.plot_max_members_added": "<prefix><red>You are not allowed to add more than </red><gold><amount></gold><red> players to this plot.</red>",
|
||||
"members.plot_max_members_trusted": "<prefix><red>You are not allowed to trust more than </red><gold><amount></gold><red> players to this plot.</red>",
|
||||
"members.plot_max_members_denied": "<prefix><red>You are not allowed to deny more than </red><gold><amount></gold><red> players from this plot.</red>",
|
||||
"members.not_added_trusted": "<prefix><red>You must be added or trusted to the plot to run that command.</red>",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user