From cb2da5abb210da0b23a4237af8050fe95f11a061 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 28 Jul 2022 10:53:47 +0200 Subject: [PATCH] Removed anvil text input --- .../mmocore/api/quest/PlayerQuests.java | 27 ++++++++++++++----- .../mmocore/api/util/input/AnvilGUI.java | 1 + .../gui/social/friend/EditableFriendList.java | 3 ++- .../gui/social/guild/EditableGuildAdmin.java | 3 ++- .../social/guild/EditableGuildCreation.java | 7 ++--- .../gui/social/guild/EditableGuildView.java | 3 ++- .../gui/social/party/EditablePartyView.java | 3 ++- .../mmocore/manager/ConfigManager.java | 8 +++--- src/main/resources/config.yml | 11 ++++---- 9 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java index 7929032c..7d2e2aed 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java @@ -12,6 +12,7 @@ import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.boss.BossBar; import org.bukkit.configuration.ConfigurationSection; +import org.jetbrains.annotations.Nullable; import java.util.Date; import java.util.HashMap; @@ -22,19 +23,28 @@ import java.util.logging.Level; public class PlayerQuests implements Closable { private final PlayerData playerData; + private final Map finished = new HashMap<>(); + + @Nullable private final BossBar bossbar; private final NamespacedKey bossbarNamespacedKey; - private final Map finished = new HashMap<>(); private QuestProgress current; public PlayerQuests(PlayerData playerData) { this.playerData = playerData; - bossbarNamespacedKey = new NamespacedKey(MMOCore.plugin, "mmocore_quest_progress_" + playerData.getUniqueId().toString()); - bossbar = Bukkit.createBossBar(bossbarNamespacedKey, "", BarColor.PURPLE, BarStyle.SEGMENTED_20); - if (playerData.isOnline()) - bossbar.addPlayer(playerData.getPlayer()); + if (MMOCore.plugin.configManager.questBossBar) { + bossbarNamespacedKey = new NamespacedKey(MMOCore.plugin, "mmocore_quest_progress_" + playerData.getUniqueId().toString()); + bossbar = Bukkit.createBossBar(bossbarNamespacedKey, "", BarColor.PURPLE, BarStyle.SEGMENTED_20); + if (playerData.isOnline()) + bossbar.addPlayer(playerData.getPlayer()); + + // Bossbar is disabled + } else { + bossbarNamespacedKey = null; + bossbar = null; + } } public PlayerQuests load(ConfigurationSection config) { @@ -50,7 +60,7 @@ public class PlayerQuests implements Closable { finished.put(key, config.getLong("finished." + key)); /* - * must update the boss bar once the instance is loaded, otherwise it + * Must update the boss bar once the instance is loaded, otherwise it * won't detect the current quest. THE BOSS BAR UPDATE is in the player * data class, this way it is still set invisible even if the player has * no quest data @@ -187,6 +197,11 @@ public class PlayerQuests implements Closable { } public void updateBossBar() { + + // Bossbar is disabled + if (bossbar == null) + return; + if (!hasCurrent() || !current.getProgress().getObjective().hasLore()) { bossbar.setVisible(false); return; diff --git a/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java b/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java index 2363716b..ae87b18b 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java @@ -14,6 +14,7 @@ import org.bukkit.util.Consumer; import io.lumine.mythic.lib.MythicLib; +@Deprecated public class AnvilGUI extends PlayerInput { private final int containerId; private final Inventory inventory; diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java b/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java index fbb4f953..aed946e9 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/friend/EditableFriendList.java @@ -3,6 +3,7 @@ package net.Indyuce.mmocore.gui.social.friend; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerActivity; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType; import net.Indyuce.mmocore.api.util.math.format.DelayFormat; import net.Indyuce.mmocore.gui.api.EditableInventory; @@ -191,7 +192,7 @@ public class EditableFriendList extends EditableInventory { return; } - MMOCore.plugin.configManager.newPlayerInput(player, InputType.FRIEND_REQUEST, (input) -> { + new ChatInput(player, InputType.FRIEND_REQUEST, (input) -> { Player target = Bukkit.getPlayer(input); if (target == null) { MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java index f3a7218e..4f6a145f 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildAdmin.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.gui.social.guild; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; @@ -151,7 +152,7 @@ public class EditableGuildAdmin extends EditableInventory { return; } - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.GUILD_INVITE, (input) -> { + new ChatInput(player, PlayerInput.InputType.GUILD_INVITE, (input) -> { Player target = Bukkit.getPlayer(input); if (target == null) { MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java index ae6e78e8..1e3d9c1b 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.gui.social.guild; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; @@ -39,14 +40,14 @@ public class EditableGuildCreation extends EditableInventory { return; if (item.getFunction().equals("create")) { - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.GUILD_CREATION_TAG, (input) -> { + new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_TAG, (input) -> { if(MMOCore.plugin.dataProvider.getGuildManager().getConfig().shouldUppercaseTags()) input = input.toUpperCase(); if(check(player, input, MMOCore.plugin.dataProvider.getGuildManager().getConfig().getTagRules())) { String tag = input; - - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.GUILD_CREATION_NAME, (name) -> { + + new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_NAME, (name) -> { if(check(player, name, MMOCore.plugin.dataProvider.getGuildManager().getConfig().getNameRules())) { MMOCore.plugin.dataProvider.getGuildManager().newRegisteredGuild(playerData.getUniqueId(), name, tag); MMOCore.plugin.dataProvider.getGuildManager().getGuild(tag.toLowerCase()).addMember(playerData.getUniqueId()); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java index 3ae1ccd5..cc87f854 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.gui.social.guild; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; @@ -200,7 +201,7 @@ public class EditableGuildView extends EditableInventory { * Sound.ENTITY_VILLAGER_NO, 1, 1); return; } */ - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.GUILD_INVITE, (input) -> { + new ChatInput(player, PlayerInput.InputType.GUILD_INVITE, (input) -> { Player target = Bukkit.getPlayer(input); if (target == null) { MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java index ec740dcd..ea4fc39a 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.gui.social.party; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.api.util.math.format.DelayFormat; import net.Indyuce.mmocore.gui.api.EditableInventory; @@ -148,7 +149,7 @@ public class EditablePartyView extends EditableInventory { return; } - MMOCore.plugin.configManager.newPlayerInput(player, PlayerInput.InputType.PARTY_INVITE, input -> { + new ChatInput(player, PlayerInput.InputType.PARTY_INVITE, input -> { Player target = Bukkit.getPlayer(input); if (target == null) { MMOCore.plugin.configManager.getSimpleMessage("not-online-player", "player", input).send(player); diff --git a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index f089e009..f23eb131 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -23,7 +23,7 @@ import java.util.logging.Level; public class ConfigManager { public final CommandVerbose commandVerbose = new CommandVerbose(); - public boolean overrideVanillaExp, canCreativeCast, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp; + public boolean overrideVanillaExp, canCreativeCast, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, questBossBar; public String partyChatPrefix, noSkillBoundPlaceholder; public ChatColor staminaFull, staminaHalf, staminaEmpty; public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown; @@ -31,7 +31,6 @@ public class ConfigManager { public int maxPartyLevelDifference; private final FileConfiguration messages; - private final boolean chatInput; /* * the instance must be created after the other managers since all it does @@ -95,7 +94,6 @@ public class ConfigManager { commandVerbose.reload(MMOCore.plugin.getConfig().getConfigurationSection("command-verbose")); messages = new ConfigFile("messages").getConfig(); - chatInput = true; // MMOCore.plugin.getConfig().getBoolean("use-chat-input") partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix"); combatLogTimer = MMOCore.plugin.getConfig().getInt("combat-log.timer") * 1000L; lootChestExpireTime = Math.max(MMOCore.plugin.getConfig().getInt("loot-chests.chest-expire-time"), 1) * 20; @@ -106,6 +104,7 @@ public class ConfigManager { fishingDropsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.fishing-drops"); maxPartyLevelDifference = MMOCore.plugin.getConfig().getInt("party.max-level-difference"); splitProfessionExp = MMOCore.plugin.getConfig().getBoolean("party.profession-exp-split"); + questBossBar = MMOCore.plugin.getConfig().getBoolean("mmocore-quests.disable-boss-bar"); staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN); staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN); @@ -125,8 +124,9 @@ public class ConfigManager { } } + @Deprecated public PlayerInput newPlayerInput(Player player, InputType type, Consumer output) { - return chatInput ? new ChatInput(player, type, output) : new AnvilGUI(player, type, output); + return new ChatInput(player, type, output) ; } public void loadDefaultFile(String name) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a33fa61f..01eaa05d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -162,6 +162,12 @@ party: # When enabled, being in a party also splits profession exp profession-exp-split: false +# Not relevant when not using MMOCore as quest plugin +mmocore-quests: + + # Disable boss bar indicating the current objective + disable-boss-bar: false + # Redirects vanilla experience obtained to MMOCore # class experience. You can define the % of the vanilla # experience that is being transfered as MMOCore exp. @@ -207,10 +213,6 @@ hotbar-swapping: # in creative mode to enter casting mode can-creative-cast: false -# Use this option if you're having issue with Anvil GUIs. -# This replaces anvil inputs by chat inputs. -use-chat-input: true - ability-targeting-options: # Prevent heals/buffs on players in a different guild @@ -222,7 +224,6 @@ ability-targeting-options: # Prevents mobs spawned from spawners from giving MMO XP points. prevent-spawner-xp: true - # Timer for combat log to expire (in seconds) combat-log: timer: 10