This commit is contained in:
Jesse Boyd 2016-11-30 16:07:16 +11:00
parent 2e23ae0811
commit 7c6c19ba63
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 50 additions and 30 deletions

View File

@ -28,7 +28,7 @@ import java.util.UUID;
@CommandDeclaration(command = "rate",
permission = "plots.rate",
description = "Rate the plot",
usage = "/plot rate [#|next]",
usage = "/plot rate [#|next|purge]",
aliases = "rt",
category = CommandCategory.INFO,
requiredType = RequiredType.NONE)
@ -37,7 +37,8 @@ public class Rate extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("next")) {
switch (args[0].toLowerCase()) {
case "next": {
ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots());
Collections.sort(plots, new Comparator<Plot>() {
@Override
@ -72,6 +73,19 @@ public class Rate extends SubCommand {
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
return false;
}
case "purge": {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
return !sendMessage(player, C.NOT_IN_PLOT);
}
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_RATE, true)) {
return false;
}
plot.clearRatings();
C.RATINGS_PURGED.send(player);
return true;
}
}
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {

View File

@ -71,6 +71,7 @@ public enum C {
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
PERMISSION_ADMIN_COMMAND_RATE("plots.admin.command.rate", "static.permissions"),
PERMISSION_ADMIN_COMMAND_TRUST("plots.admin.command.trust", "static.permissions"),
PERMISSION_TRUST_EVERYONE("plots.trust.everyone", "static.permissions"),
PERMISSION_AREA_CREATE("plots.area.create", "static.permissions"),
@ -311,6 +312,7 @@ public enum C {
/*
* Ratings
*/
RATINGS_PURGED("$2Purged ratings for this plot", "Ratings"),
RATING_NOT_VALID("$2You need to specify a number between 1 and 10", "Ratings"),
RATING_ALREADY_EXISTS("$2You have already rated plot $2%s", "Ratings"),
RATING_APPLIED("$4You successfully rated plot $2%s", "Ratings"),

View File

@ -14,6 +14,10 @@ import java.util.HashMap;
*/
public class Permissions {
public static boolean hasPermission(PlotPlayer player, C caption, boolean notify) {
return hasPermission(player, caption.s(), notify);
}
/**
* Check if a player has a permission (C class helps keep track of permissions).
* @param player