From 17f91c8eb92c8b0fa5a90fd530e1eaae25f72bda Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 21 May 2021 16:48:34 +0200 Subject: [PATCH] Make `/plot rate` GUI items customizable Bye bye legacy items :) --- .../com/plotsquared/core/command/Rate.java | 29 ++++++------------- .../core/configuration/Settings.java | 10 +++++++ .../plotsquared/core/plot/PlotItemStack.java | 21 -------------- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java index fc3224add..8d4cc03df 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -177,17 +177,6 @@ public class Rate extends SubCommand { TranslatableCaption.of("ratings.rating_applied"), Template.of("plot", plot.getId().toString()) ); - if (Permissions - .hasPermission(this.getPlayer(), Permission.PERMISSION_COMMENT)) { - Command command = - MainCommand.getInstance().getCommand(Comment.class); - if (command != null) { - getPlayer().sendMessage( - TranslatableCaption.of("tutorial.comment_this"), - Template.of("plot", "/plot rate") - ); - } - } } return false; } @@ -195,15 +184,15 @@ public class Rate extends SubCommand { return true; } }; - inventory.setItem(0, new PlotItemStack(35, (short) 12, 0, "0/8")); - inventory.setItem(1, new PlotItemStack(35, (short) 14, 1, "1/8")); - inventory.setItem(2, new PlotItemStack(35, (short) 1, 2, "2/8")); - inventory.setItem(3, new PlotItemStack(35, (short) 4, 3, "3/8")); - inventory.setItem(4, new PlotItemStack(35, (short) 5, 4, "4/8")); - inventory.setItem(5, new PlotItemStack(35, (short) 9, 5, "5/8")); - inventory.setItem(6, new PlotItemStack(35, (short) 11, 6, "6/8")); - inventory.setItem(7, new PlotItemStack(35, (short) 10, 7, "7/8")); - inventory.setItem(8, new PlotItemStack(35, (short) 2, 8, "8/8")); + inventory.setItem(0, new PlotItemStack(Settings.Ratings.BLOCK_0, 0, "0/8")); + inventory.setItem(1, new PlotItemStack(Settings.Ratings.BLOCK_1, 1, "1/8")); + inventory.setItem(2, new PlotItemStack(Settings.Ratings.BLOCK_2, 2, "2/8")); + inventory.setItem(3, new PlotItemStack(Settings.Ratings.BLOCK_3, 3, "3/8")); + inventory.setItem(4, new PlotItemStack(Settings.Ratings.BLOCK_4, 4, "4/8")); + inventory.setItem(5, new PlotItemStack(Settings.Ratings.BLOCK_5, 5, "5/8")); + inventory.setItem(6, new PlotItemStack(Settings.Ratings.BLOCK_6, 6, "6/8")); + inventory.setItem(7, new PlotItemStack(Settings.Ratings.BLOCK_7, 7, "7/8")); + inventory.setItem(8, new PlotItemStack(Settings.Ratings.BLOCK_8, 8, "8/8")); inventory.openInventory(); } }; diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index b7609a33b..fae9e178e 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -609,6 +609,16 @@ public class Settings extends Config { public static boolean USE_LIKES = false; @Comment("Rating categories") public static List CATEGORIES = new ArrayList<>(); + @Comment("The blocks to use for the rating GUI if categories are set above") + public static String BLOCK_0 = "brown_wool"; + public static String BLOCK_1 = "red_wool"; + public static String BLOCK_2 = "orange_wool"; + public static String BLOCK_3 = "yellow_wool"; + public static String BLOCK_4 = "lime_wool"; + public static String BLOCK_5 = "cyan_wool"; + public static String BLOCK_6 = "blue_wool"; + public static String BLOCK_7 = "purple_wool"; + public static String BLOCK_8 = "magenta_wool"; } diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotItemStack.java b/Core/src/main/java/com/plotsquared/core/plot/PlotItemStack.java index abe28bd58..8d6d4dff4 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotItemStack.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotItemStack.java @@ -28,7 +28,6 @@ package com.plotsquared.core.plot; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; -import com.sk89q.worldedit.world.registry.LegacyMapper; public class PlotItemStack { @@ -37,26 +36,6 @@ public class PlotItemStack { private final String[] lore; private final ItemType type; - /** - * @param id Legacy numerical item ID - * @param data Legacy numerical item data - * @param amount Amount of items in the stack - * @param name The display name of the item stack - * @param lore The item stack lore - * @deprecated Use {@link #PlotItemStack(String, int, String, String...)} - */ - @Deprecated - public PlotItemStack( - final int id, final short data, final int amount, - final String name, final String... lore - ) { - - this.amount = amount; - this.name = name; - this.lore = lore; - this.type = LegacyMapper.getInstance().getItemFromLegacy(id, data); - } - /** * @param id String ID * @param amount Amount of items in the stack