From 5abcde42af6c6939be84576a10caa5fe3e9d29a4 Mon Sep 17 00:00:00 2001 From: devlrxxh Date: Sat, 6 Apr 2024 22:17:39 +0200 Subject: [PATCH] Removed useless code --- .../practice/profile/ProfileListener.java | 11 ---- .../button/AllowSpectatorsOptionButton.java | 54 ------------------ .../button/DuelRequestsOptionButton.java | 54 ------------------ .../button/ShowScoreboardOptionButton.java | 54 ------------------ .../profile/option/OptionsOpenedEvent.java | 18 ------ .../profile/option/ProfileOptionButton.java | 56 ------------------- 6 files changed, 247 deletions(-) delete mode 100644 src/main/java/me/lrxh/practice/profile/meta/option/button/AllowSpectatorsOptionButton.java delete mode 100644 src/main/java/me/lrxh/practice/profile/meta/option/button/DuelRequestsOptionButton.java delete mode 100644 src/main/java/me/lrxh/practice/profile/meta/option/button/ShowScoreboardOptionButton.java delete mode 100644 src/main/java/me/lrxh/practice/profile/option/OptionsOpenedEvent.java delete mode 100644 src/main/java/me/lrxh/practice/profile/option/ProfileOptionButton.java diff --git a/src/main/java/me/lrxh/practice/profile/ProfileListener.java b/src/main/java/me/lrxh/practice/profile/ProfileListener.java index a433ee8..106456a 100644 --- a/src/main/java/me/lrxh/practice/profile/ProfileListener.java +++ b/src/main/java/me/lrxh/practice/profile/ProfileListener.java @@ -6,10 +6,6 @@ import me.lrxh.practice.match.Match; import me.lrxh.practice.match.MatchState; import me.lrxh.practice.profile.hotbar.HotbarItem; -import me.lrxh.practice.profile.meta.option.button.AllowSpectatorsOptionButton; -import me.lrxh.practice.profile.meta.option.button.DuelRequestsOptionButton; -import me.lrxh.practice.profile.meta.option.button.ShowScoreboardOptionButton; -import me.lrxh.practice.profile.option.OptionsOpenedEvent; import me.lrxh.practice.profile.visibility.VisibilityLogic; import me.lrxh.practice.util.CC; import me.lrxh.practice.util.PlaceholderUtil; @@ -126,13 +122,6 @@ public void soilChangePlayer(PlayerInteractEvent event) { event.setCancelled(true); } - @EventHandler - public void onOptionsOpenedEvent(OptionsOpenedEvent event) { - event.getButtons().add(new ShowScoreboardOptionButton()); - event.getButtons().add(new AllowSpectatorsOptionButton()); - event.getButtons().add(new DuelRequestsOptionButton()); - } - @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteract(PlayerInteractEvent event) { if (event.getItem() != null && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) { diff --git a/src/main/java/me/lrxh/practice/profile/meta/option/button/AllowSpectatorsOptionButton.java b/src/main/java/me/lrxh/practice/profile/meta/option/button/AllowSpectatorsOptionButton.java deleted file mode 100644 index a5d1178..0000000 --- a/src/main/java/me/lrxh/practice/profile/meta/option/button/AllowSpectatorsOptionButton.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.lrxh.practice.profile.meta.option.button; - -import me.lrxh.practice.profile.Profile; -import me.lrxh.practice.profile.option.ProfileOptionButton; -import me.lrxh.practice.util.ItemBuilder; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -public class AllowSpectatorsOptionButton extends ProfileOptionButton { - - @Override - public ItemStack getEnabledItem(Player player) { - return new ItemBuilder(Material.REDSTONE_TORCH_ON).build(); - } - - @Override - public ItemStack getDisabledItem(Player player) { - return new ItemBuilder(Material.REDSTONE_TORCH_ON).build(); - } - - @Override - public String getOptionName() { - return "&dSpectators"; - } - - @Override - public String getDescription() { - return "If enabled, players will be able to spectate your match."; - } - - @Override - public String getEnabledOption() { - return "Allow players to spectate"; - } - - @Override - public String getDisabledOption() { - return "Do not allow players to spectate"; - } - - @Override - public boolean isEnabled(Player player) { - return Profile.getByUuid(player.getUniqueId()).getOptions().allowSpectators(); - } - - @Override - public void clicked(Player player, ClickType clickType) { - Profile profile = Profile.getByUuid(player.getUniqueId()); - profile.getOptions().allowSpectators(!profile.getOptions().allowSpectators()); - } - -} diff --git a/src/main/java/me/lrxh/practice/profile/meta/option/button/DuelRequestsOptionButton.java b/src/main/java/me/lrxh/practice/profile/meta/option/button/DuelRequestsOptionButton.java deleted file mode 100644 index bd9b55c..0000000 --- a/src/main/java/me/lrxh/practice/profile/meta/option/button/DuelRequestsOptionButton.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.lrxh.practice.profile.meta.option.button; - -import me.lrxh.practice.profile.Profile; -import me.lrxh.practice.profile.option.ProfileOptionButton; -import me.lrxh.practice.util.ItemBuilder; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -public class DuelRequestsOptionButton extends ProfileOptionButton { - - @Override - public ItemStack getEnabledItem(Player player) { - return new ItemBuilder(Material.BLAZE_ROD).build(); - } - - @Override - public ItemStack getDisabledItem(Player player) { - return new ItemBuilder(Material.BLAZE_ROD).build(); - } - - @Override - public String getOptionName() { - return "&bDuel Requests"; - } - - @Override - public String getDescription() { - return "If enabled, you will receive duel requests."; - } - - @Override - public String getEnabledOption() { - return "Receive duel requests"; - } - - @Override - public String getDisabledOption() { - return "Do not receive duel requests"; - } - - @Override - public boolean isEnabled(Player player) { - return Profile.getByUuid(player.getUniqueId()).getOptions().receiveDuelRequests(); - } - - @Override - public void clicked(Player player, ClickType clickType) { - Profile profile = Profile.getByUuid(player.getUniqueId()); - profile.getOptions().receiveDuelRequests(!profile.getOptions().receiveDuelRequests()); - } - -} diff --git a/src/main/java/me/lrxh/practice/profile/meta/option/button/ShowScoreboardOptionButton.java b/src/main/java/me/lrxh/practice/profile/meta/option/button/ShowScoreboardOptionButton.java deleted file mode 100644 index 8933c29..0000000 --- a/src/main/java/me/lrxh/practice/profile/meta/option/button/ShowScoreboardOptionButton.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.lrxh.practice.profile.meta.option.button; - -import me.lrxh.practice.profile.Profile; -import me.lrxh.practice.profile.option.ProfileOptionButton; -import me.lrxh.practice.util.ItemBuilder; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -public class ShowScoreboardOptionButton extends ProfileOptionButton { - - @Override - public String getOptionName() { - return "&aShow Scoreboard"; - } - - @Override - public ItemStack getEnabledItem(Player player) { - return new ItemBuilder(Material.ITEM_FRAME).build(); - } - - @Override - public ItemStack getDisabledItem(Player player) { - return new ItemBuilder(Material.ITEM_FRAME).build(); - } - - @Override - public String getDescription() { - return "If enabled, a scoreboard will be displayed to you."; - } - - @Override - public String getEnabledOption() { - return "Show you a scoreboard"; - } - - @Override - public String getDisabledOption() { - return "Do not show you a scoreboard"; - } - - @Override - public boolean isEnabled(Player player) { - return Profile.getProfiles().get(player.getUniqueId()).getOptions().showScoreboard(); - } - - @Override - public void clicked(Player player, ClickType clickType) { - Profile profile = Profile.getProfiles().get(player.getUniqueId()); - profile.getOptions().showScoreboard(!profile.getOptions().showScoreboard()); - } - -} diff --git a/src/main/java/me/lrxh/practice/profile/option/OptionsOpenedEvent.java b/src/main/java/me/lrxh/practice/profile/option/OptionsOpenedEvent.java deleted file mode 100644 index fe7016f..0000000 --- a/src/main/java/me/lrxh/practice/profile/option/OptionsOpenedEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.lrxh.practice.profile.option; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import me.lrxh.practice.util.BaseEvent; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - -@RequiredArgsConstructor -@Getter -public class OptionsOpenedEvent extends BaseEvent { - - private final Player player; - private final List buttons = new ArrayList<>(); - -} diff --git a/src/main/java/me/lrxh/practice/profile/option/ProfileOptionButton.java b/src/main/java/me/lrxh/practice/profile/option/ProfileOptionButton.java deleted file mode 100644 index 4fdfa7e..0000000 --- a/src/main/java/me/lrxh/practice/profile/option/ProfileOptionButton.java +++ /dev/null @@ -1,56 +0,0 @@ -package me.lrxh.practice.profile.option; - -import lombok.AllArgsConstructor; -import me.lrxh.practice.util.CC; -import me.lrxh.practice.util.ItemBuilder; -import me.lrxh.practice.util.TextSplitter; -import me.lrxh.practice.util.menu.Button; -import org.apache.commons.lang.StringEscapeUtils; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - -@AllArgsConstructor -public abstract class ProfileOptionButton extends Button { - - @Override - public ItemStack getButtonItem(Player player) { - ItemBuilder itemBuilder = new ItemBuilder(isEnabled(player) ? getEnabledItem(player) : getDisabledItem(player)); - - List lore = new ArrayList<>(); - lore.add(""); - lore.addAll(TextSplitter.split(40, getDescription(), CC.GRAY, " ")); - lore.add(""); - lore.add((isEnabled(player) ? CC.BLUE + StringEscapeUtils.unescapeJava(" » ") : " ") + "&e" + getEnabledOption()); - lore.add((!isEnabled(player) ? CC.BLUE + StringEscapeUtils.unescapeJava(" » ") : " ") + "&e" + getDisabledOption()); - lore.add(""); - lore.add("&eClick to toggle this option."); - - return itemBuilder.name(getOptionName()) - .lore(lore) - .build(); - } - - public abstract ItemStack getEnabledItem(Player player); - - public abstract ItemStack getDisabledItem(Player player); - - public abstract String getOptionName(); - - public abstract String getDescription(); - - public abstract String getEnabledOption(); - - public abstract String getDisabledOption(); - - public abstract boolean isEnabled(Player player); - - @Override - public boolean shouldUpdate(Player player, ClickType clickType) { - return true; - } - -}