mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 09:33:43 +01:00 
			
		
		
		
	Fixes #740
This commit is contained in:
		| @@ -28,7 +28,7 @@ import java.util.UUID; | |||||||
| @CommandDeclaration(command = "rate", | @CommandDeclaration(command = "rate", | ||||||
|         permission = "plots.rate", |         permission = "plots.rate", | ||||||
|         description = "Rate the plot", |         description = "Rate the plot", | ||||||
|         usage = "/plot rate [#|next]", |         usage = "/plot rate [#|next|purge]", | ||||||
|         aliases = "rt", |         aliases = "rt", | ||||||
|         category = CommandCategory.INFO, |         category = CommandCategory.INFO, | ||||||
|         requiredType = RequiredType.NONE) |         requiredType = RequiredType.NONE) | ||||||
| @@ -37,7 +37,8 @@ public class Rate extends SubCommand { | |||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(final PlotPlayer player, String[] args) { |     public boolean onCommand(final PlotPlayer player, String[] args) { | ||||||
|         if (args.length == 1) { |         if (args.length == 1) { | ||||||
|             if (args[0].equalsIgnoreCase("next")) { |             switch (args[0].toLowerCase()) { | ||||||
|  |                 case "next": { | ||||||
|                     ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots()); |                     ArrayList<Plot> plots = new ArrayList<>(PS.get().getBasePlots()); | ||||||
|                     Collections.sort(plots, new Comparator<Plot>() { |                     Collections.sort(plots, new Comparator<Plot>() { | ||||||
|                         @Override |                         @Override | ||||||
| @@ -72,6 +73,19 @@ public class Rate extends SubCommand { | |||||||
|                     MainUtil.sendMessage(player, C.FOUND_NO_PLOTS); |                     MainUtil.sendMessage(player, C.FOUND_NO_PLOTS); | ||||||
|                     return false; |                     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(); |         final Plot plot = player.getCurrentPlot(); | ||||||
|         if (plot == null) { |         if (plot == null) { | ||||||
|   | |||||||
| @@ -71,6 +71,7 @@ public enum C { | |||||||
|     PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"), |     PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"), | ||||||
|     PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"), |     PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"), | ||||||
|     PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "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_ADMIN_COMMAND_TRUST("plots.admin.command.trust", "static.permissions"), | ||||||
|     PERMISSION_TRUST_EVERYONE("plots.trust.everyone", "static.permissions"), |     PERMISSION_TRUST_EVERYONE("plots.trust.everyone", "static.permissions"), | ||||||
|     PERMISSION_AREA_CREATE("plots.area.create", "static.permissions"), |     PERMISSION_AREA_CREATE("plots.area.create", "static.permissions"), | ||||||
| @@ -311,6 +312,7 @@ public enum C { | |||||||
|     /* |     /* | ||||||
|      * Ratings |      * Ratings | ||||||
|      */ |      */ | ||||||
|  |     RATINGS_PURGED("$2Purged ratings for this plot", "Ratings"), | ||||||
|     RATING_NOT_VALID("$2You need to specify a number between 1 and 10", "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_ALREADY_EXISTS("$2You have already rated plot $2%s", "Ratings"), | ||||||
|     RATING_APPLIED("$4You successfully rated plot $2%s", "Ratings"), |     RATING_APPLIED("$4You successfully rated plot $2%s", "Ratings"), | ||||||
|   | |||||||
| @@ -14,6 +14,10 @@ import java.util.HashMap; | |||||||
|  */ |  */ | ||||||
| public class Permissions { | 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). |      * Check if a player has a permission (C class helps keep track of permissions). | ||||||
|      * @param player |      * @param player | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jesse Boyd
					Jesse Boyd