diff --git a/src/main/java/com/badbones69/crazycrates/CrazyCrates.java b/src/main/java/com/badbones69/crazycrates/CrazyCrates.java index da8321be3..5bba8fd63 100644 --- a/src/main/java/com/badbones69/crazycrates/CrazyCrates.java +++ b/src/main/java/com/badbones69/crazycrates/CrazyCrates.java @@ -7,8 +7,6 @@ import com.badbones69.crazycrates.api.objects.other.Server; import com.badbones69.crazycrates.api.utils.MiscUtils; import com.badbones69.crazycrates.commands.CommandManager; -import com.badbones69.crazycrates.config.ConfigManager; -import com.badbones69.crazycrates.config.impl.ConfigKeys; import com.badbones69.crazycrates.listeners.BrokeLocationsListener; import com.badbones69.crazycrates.listeners.CrateControlListener; import com.badbones69.crazycrates.listeners.MiscListener; @@ -188,9 +186,4 @@ public void onDisable() { public @NotNull final Timer getTimer() { return this.timer; } - - @Override - public final boolean isLegacy() { - return !ConfigManager.getConfig().getProperty(ConfigKeys.minimessage_toggle); - } } \ No newline at end of file diff --git a/src/main/java/com/badbones69/crazycrates/api/builders/InventoryBuilder.java b/src/main/java/com/badbones69/crazycrates/api/builders/InventoryBuilder.java index 770eb2844..0b1ec2e66 100644 --- a/src/main/java/com/badbones69/crazycrates/api/builders/InventoryBuilder.java +++ b/src/main/java/com/badbones69/crazycrates/api/builders/InventoryBuilder.java @@ -58,13 +58,9 @@ public InventoryBuilder(@NotNull final Player player, @NotNull final String titl this.title = title; this.size = size; - String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; + final String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; - if (this.plugin.isLegacy()) { - this.inventory = this.server.createInventory(this, this.size, ItemUtil.color(inventoryTitle)); - } else { - this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); - } + this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); } public InventoryBuilder(@NotNull final Player player, @NotNull final String title, final int size, @NotNull final Crate crate) { @@ -74,13 +70,9 @@ public InventoryBuilder(@NotNull final Player player, @NotNull final String titl this.crate = crate; - String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; + final String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; - if (this.plugin.isLegacy()) { - this.inventory = this.server.createInventory(this, this.size, ItemUtil.color(inventoryTitle)); - } else { - this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); - } + this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); } public InventoryBuilder(@NotNull final Player player, @NotNull final String title, final int size, final int page, @NotNull final Crate crate) { @@ -91,13 +83,9 @@ public InventoryBuilder(@NotNull final Player player, @NotNull final String titl this.crate = crate; - String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; + final String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; - if (this.plugin.isLegacy()) { - this.inventory = this.server.createInventory(this, this.size, ItemUtil.color(inventoryTitle)); - } else { - this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); - } + this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); } public InventoryBuilder(@NotNull final Player player, @NotNull final String title, final int size, @NotNull final Crate crate, @NotNull final List tiers) { @@ -108,13 +96,9 @@ public InventoryBuilder(@NotNull final Player player, @NotNull final String titl this.crate = crate; this.tiers = tiers; - String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; + final String inventoryTitle = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(getPlayer(), this.title) : this.title; - if (this.plugin.isLegacy()) { - this.inventory = this.server.createInventory(this, this.size, ItemUtil.color(inventoryTitle)); - } else { - this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); - } + this.inventory = this.server.createInventory(this, this.size, AdvUtil.parse(inventoryTitle)); } public InventoryBuilder() {} @@ -127,7 +111,7 @@ public boolean overrideMenu() { if (!commands.isEmpty()) { commands.forEach(value -> { - String command = value.replaceAll("%player%", quoteReplacement(this.player.getName())).replaceAll("%crate%", quoteReplacement(this.crate.getFileName())); + final String command = value.replaceAll("%player%", quoteReplacement(this.player.getName())).replaceAll("%crate%", quoteReplacement(this.crate.getFileName())); MiscUtils.sendCommand(command); }); @@ -197,10 +181,6 @@ public final boolean contains(@NotNull final String message) { } public void sendTitleChange() { - if (this.plugin.isLegacy()) { - return; - } - ServerPlayer entityPlayer = (ServerPlayer) ((CraftHumanEntity) getView().getPlayer()).getHandle(); int containerId = entityPlayer.containerMenu.containerId; MenuType windowType = CraftContainer.getNotchInventoryType(getView().getTopInventory()); diff --git a/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java b/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java index ee7d6475c..59c511276 100644 --- a/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java +++ b/src/main/java/com/badbones69/crazycrates/api/enums/Messages.java @@ -182,14 +182,8 @@ public void sendActionBar(final CommandSender sender, final String placeholder, if (msg.isEmpty() || msg.isBlank()) return; - if (this.plugin.isLegacy()) { - if (sender instanceof Player player) { - player.sendActionBar(ItemUtil.color(msg)); - } - } else { - if (sender instanceof Player player) { - player.sendActionBar(AdvUtil.parse(msg)); - } + if (sender instanceof Player player) { + player.sendActionBar(AdvUtil.parse(msg)); } } @@ -198,14 +192,8 @@ public void sendActionBar(final CommandSender sender, final Map if (msg.isEmpty() || msg.isBlank()) return; - if (this.plugin.isLegacy()) { - if (sender instanceof Player player) { - player.sendActionBar(ItemUtil.color(msg)); - } - } else { - if (sender instanceof Player player) { - player.sendActionBar(AdvUtil.parse(msg)); - } + if (sender instanceof Player player) { + player.sendActionBar(AdvUtil.parse(msg)); } } @@ -214,14 +202,8 @@ public void sendActionBar(final CommandSender sender) { if (msg.isEmpty() || msg.isBlank()) return; - if (this.plugin.isLegacy()) { - if (sender instanceof Player player) { - player.sendActionBar(ItemUtil.color(msg)); - } - } else { - if (sender instanceof Player player) { - player.sendActionBar(AdvUtil.parse(msg)); - } + if (sender instanceof Player player) { + player.sendActionBar(AdvUtil.parse(msg)); } } @@ -230,11 +212,7 @@ public void sendRichMessage(final CommandSender sender, final String placeholder if (msg.isEmpty() || msg.isBlank()) return; - if (this.plugin.isLegacy()) { - sender.sendMessage(ItemUtil.color(msg)); - } else { - sender.sendRichMessage(msg); - } + sender.sendRichMessage(msg); } public void sendRichMessage(final CommandSender sender, final Map placeholders) { @@ -242,11 +220,7 @@ public void sendRichMessage(final CommandSender sender, final Map placeholders) { diff --git a/src/main/java/com/badbones69/crazycrates/api/objects/Crate.java b/src/main/java/com/badbones69/crazycrates/api/objects/Crate.java index a890eb96f..895e81e28 100644 --- a/src/main/java/com/badbones69/crazycrates/api/objects/Crate.java +++ b/src/main/java/com/badbones69/crazycrates/api/objects/Crate.java @@ -15,8 +15,6 @@ import net.kyori.adventure.sound.Sound; import org.bukkit.Color; import org.bukkit.Particle; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.Nullable; import org.bukkit.configuration.ConfigurationSection; @@ -35,11 +33,9 @@ import com.badbones69.crazycrates.api.utils.MiscUtils; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; -@SuppressWarnings("deprecation") public class Crate { private ItemBuilder previewTierBorderItem; @@ -70,8 +66,6 @@ public class Crate { private int previewChestLines; private int newPlayerKeys; - private List itemStacks; - private List tiers; private CrateHologram hologram; @@ -646,67 +640,26 @@ private void setItem(@Nullable final ItemStack itemStack, @NotNull final String final String tiers = getPath(prizeName, "Tiers"); - final boolean useOldEditor = ConfigManager.getConfig().getProperty(ConfigKeys.item_editor_toggle); - if (!section.contains(prizeName)) { section.set(getPath(prizeName, "MaxRange"), 100); } - if (useOldEditor && !this.plugin.isLegacy()) { - final List editorItems = new ArrayList<>(); - - if (section.contains(prizeName + ".Editor-Items")) { - final List editors = section.getList(prizeName + ".Editor-Items"); - - if (editors != null) { - editors.forEach(item -> editorItems.add((ItemStack) item)); - } - } - - editorItems.add(itemStack); - - List enchantments = new ArrayList<>(); - - for (Map.Entry enchantment : itemStack.getEnchantments().entrySet()) { - enchantments.add(enchantment.getKey().getKey().getKey() + ":" + enchantment.getValue()); - } - - if (!enchantments.isEmpty()) section.set(getPath(prizeName, "DisplayEnchantments"), enchantments); + String toBase64 = ItemUtil.toBase64(itemStack); - if (itemStack.hasItemMeta()) { - final ItemMeta itemMeta = itemStack.getItemMeta(); + section.set(getPath(prizeName, "DisplayData"), toBase64); - if (itemMeta.hasDisplayName()) { - section.set(getPath(prizeName, "DisplayName"), itemMeta.getDisplayName()); - } + final String items = getPath(prizeName, "Items"); - if (itemMeta.hasLore()) { - section.set(getPath(prizeName, "DisplayLore"), itemMeta.getLore()); - } - } + if (section.contains(items)) { + final List list = section.getStringList(items); - section.set(getPath(prizeName, "DisplayItem"), itemStack.getType().getKey().getKey()); - section.set(getPath(prizeName, "DisplayAmount"), itemStack.getAmount()); + list.add("Data:" + toBase64); - section.set(getPath(prizeName, "Editor-Items"), editorItems); + section.set(items, list); } else { - String toBase64 = ItemUtil.toBase64(itemStack); - - section.set(getPath(prizeName, "DisplayData"), toBase64); - - final String items = getPath(prizeName, "Items"); - - if (section.contains(items)) { - final List list = section.getStringList(items); - - list.add("Data:" + toBase64); - - section.set(items, list); - } else { - section.set(items, new ArrayList<>() {{ - add("Data:" + toBase64); - }}); - } + section.set(items, new ArrayList<>() {{ + add("Data:" + toBase64); + }}); } section.set(getPath(prizeName, "Chance"), chance); diff --git a/src/main/java/com/badbones69/crazycrates/api/objects/Prize.java b/src/main/java/com/badbones69/crazycrates/api/objects/Prize.java index d0dce8f0a..bd3274ac9 100644 --- a/src/main/java/com/badbones69/crazycrates/api/objects/Prize.java +++ b/src/main/java/com/badbones69/crazycrates/api/objects/Prize.java @@ -112,18 +112,10 @@ public Prize(@NotNull final String prizeName, @NotNull final String sectionName, * @return the name of the prize. */ public @NotNull final String getPrizeName() { - if (this.plugin.isLegacy()) { - return this.prizeName.isEmpty() ? "" : this.prizeName; - } - return this.prizeName.isEmpty() ? "" : this.prizeName; } public @NotNull final String getStrippedName() { - if (this.plugin.isLegacy()) { - return ChatColor.stripColor(getPrizeName()); - } - return PlainTextComponentSerializer.plainText().serialize(AdvUtil.parse(getPrizeName())); } @@ -284,21 +276,6 @@ public void broadcast(final Crate crate) { final String prizeName = getPrizeName(); final String strippedName = getStrippedName(); - if (this.plugin.isLegacy()) { - this.plugin.getServer().getOnlinePlayers().forEach(player -> { - if (!this.broadcastPermission.isEmpty() && player.hasPermission(this.broadcastPermission)) return; - - this.broadcastMessages.forEach(message -> player.sendMessage(ItemUtil.color(message, new HashMap<>() {{ - put("%player%", player.getName()); - put("%crate%", fancyName); - put("%reward%", prizeName); - put("%reward_stripped%", strippedName); - }}, player))); - }); - - return; - } - this.plugin.getServer().getOnlinePlayers().forEach(player -> { if (!this.broadcastPermission.isEmpty() && player.hasPermission(this.broadcastPermission)) return; diff --git a/src/main/java/com/badbones69/crazycrates/api/utils/MsgUtils.java b/src/main/java/com/badbones69/crazycrates/api/utils/MsgUtils.java index be69f0f3e..f1b492c3d 100644 --- a/src/main/java/com/badbones69/crazycrates/api/utils/MsgUtils.java +++ b/src/main/java/com/badbones69/crazycrates/api/utils/MsgUtils.java @@ -24,17 +24,9 @@ public static void sendMessage(CommandSender commandSender, @NotNull final Strin if (sendPrefix) { final String msg = message.replaceAll("%prefix%", quoteReplacement(prefix)).replaceAll("%Prefix%", quoteReplacement(prefix)); - if (plugin.isLegacy()) { - player.sendMessage(ItemUtil.color(msg)); - } else { - player.sendRichMessage(msg); - } + player.sendRichMessage(msg); } else { - if (plugin.isLegacy()) { - player.sendMessage(ItemUtil.color(message)); - } else { - player.sendRichMessage(message); - } + player.sendRichMessage(message); } return; @@ -43,17 +35,9 @@ public static void sendMessage(CommandSender commandSender, @NotNull final Strin if (sendPrefix) { final String msg = message.replaceAll("%prefix%", quoteReplacement(prefix)).replaceAll("%Prefix%", quoteReplacement(prefix)); - if (plugin.isLegacy()) { - commandSender.sendMessage(ItemUtil.color(msg)); - } else { - commandSender.sendRichMessage(msg); - } + commandSender.sendRichMessage(msg); } else { - if (plugin.isLegacy()) { - commandSender.sendMessage(ItemUtil.color(message)); - } else { - commandSender.sendRichMessage(message); - } + commandSender.sendRichMessage(message); } } diff --git a/src/main/java/com/badbones69/crazycrates/config/impl/ConfigKeys.java b/src/main/java/com/badbones69/crazycrates/config/impl/ConfigKeys.java index 3928120cb..899c10f8d 100644 --- a/src/main/java/com/badbones69/crazycrates/config/impl/ConfigKeys.java +++ b/src/main/java/com/badbones69/crazycrates/config/impl/ConfigKeys.java @@ -5,7 +5,6 @@ import ch.jalu.configme.configurationdata.CommentsConfiguration; import ch.jalu.configme.properties.Property; import com.badbones69.crazycrates.api.enums.misc.State; - import java.util.Collections; import java.util.List; import static ch.jalu.configme.properties.PropertyInitializer.newBeanProperty; @@ -62,23 +61,6 @@ public void registerComments(CommentsConfiguration conf) { @Comment("This option will let you test a different way of picking random numbers. If you have any issues, You can set it back to false.") public static final Property use_different_random = newProperty("root.use-different-random", false); - @Comment({ - "This option defines the type of color codes used in CrazyCrates", - "", - "true -> uses minimessage", - "false -> uses legacy color codes", - "", - "Note: inventory titles won't update during Cosmic Crate while this is false.", - "Warning: legacy color codes is highly likely to be removed in the future, so you should find time to migrate as this option won't be here forever.", - "", - "Now I get what you are going to say next, but I can't. Excluding the common reason of people simply want to, or it's easier.", - "I would like you to explain why you use legacy color codes still, is it because of lacking features", - "which make you have to rely on external plugins? I had one such instance with someone using /broadcast", - "from EssentialsX which didn't support MiniMessage, each prize in the crates now let you broadcast to the server.", - "and that section supports MiniMessage, that is one such example of an issue someone had." - }) - public static final Property minimessage_toggle = newProperty("root.use-minimessage", true); - @Comment({ "This option defines what in-game editor format is used in CrazyCrates", "", diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java index 17e5da2f8..d4d818086 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java @@ -11,7 +11,6 @@ import com.badbones69.crazycrates.api.objects.Crate; import com.ryderbelserion.vital.paper.api.enums.Support; import com.ryderbelserion.vital.paper.util.AdvUtil; -import com.ryderbelserion.vital.paper.util.ItemUtil; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -90,11 +89,7 @@ public void onCrateOpen(CrateOpenEvent event) { if (!broadcastMessage.isBlank()) { final String builder = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(player, broadcastMessage) : broadcastMessage; - if (this.plugin.isLegacy()) { - this.plugin.getServer().broadcastMessage(ItemUtil.color(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); - } else { - this.plugin.getServer().broadcast(AdvUtil.parse(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); - } + this.plugin.getServer().broadcast(AdvUtil.parse(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); } } diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/types/CosmicCrateListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/types/CosmicCrateListener.java index af37f9714..28a9c2f3a 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/types/CosmicCrateListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/types/CosmicCrateListener.java @@ -324,11 +324,7 @@ public void onMysteryBoxClick(InventoryClickEvent event) { if (!broadcastMessage.isBlank()) { String builder = Support.placeholder_api.isEnabled() ? PlaceholderAPI.setPlaceholders(player, broadcastMessage) : broadcastMessage; - if (this.plugin.isLegacy()) { - this.plugin.getServer().broadcastMessage(ItemUtil.color(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); - } else { - this.plugin.getServer().broadcast(AdvUtil.parse(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); - } + this.plugin.getServer().broadcast(AdvUtil.parse(builder.replaceAll("%crate%", fancyName).replaceAll("%prefix%", MsgUtils.getPrefix()).replaceAll("%player%", player.getName()))); } } diff --git a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java index afe34d5ed..68a2bcef7 100644 --- a/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java +++ b/src/main/java/com/badbones69/crazycrates/tasks/crates/types/QuickCrate.java @@ -9,7 +9,6 @@ import com.badbones69.crazycrates.api.objects.other.CrateLocation; import com.badbones69.crazycrates.support.holograms.HologramManager; import com.ryderbelserion.vital.paper.util.AdvUtil; -import com.ryderbelserion.vital.paper.util.ItemUtil; import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable; import com.badbones69.crazycrates.tasks.BukkitUserManager; import com.badbones69.crazycrates.tasks.crates.CrateManager; @@ -178,11 +177,7 @@ public void open(@NotNull final KeyType type, final boolean checkHand) { reward.setVelocity(new Vector(0, .2, 0)); - if (this.plugin.isLegacy()) { - reward.setCustomName(ItemUtil.color(prize.getPrizeName())); - } else { - reward.customName(AdvUtil.parse(prize.getPrizeName())); - } + reward.customName(AdvUtil.parse(prize.getPrizeName())); reward.setCustomNameVisible(true); reward.setCanMobPickup(false);