From 569e6a333448d34a91dc72913c7ec28eb8d17096 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 24 Sep 2023 23:07:42 +0200 Subject: [PATCH] Fixed messages for npc's and made the left/right click actions more consistent --- .../java/com/alttd/fishingevent/config/Config.java | 2 +- .../com/alttd/fishingevent/config/Messages.java | 6 ++++++ .../com/alttd/fishingevent/npc/types/PrizeNPC.java | 5 +---- .../com/alttd/fishingevent/npc/types/SellNPC.java | 3 +-- .../alttd/fishingevent/npc/types/TutorialNPC.java | 14 +++++++------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/alttd/fishingevent/config/Config.java b/src/main/java/com/alttd/fishingevent/config/Config.java index a546eda..e8e32d7 100644 --- a/src/main/java/com/alttd/fishingevent/config/Config.java +++ b/src/main/java/com/alttd/fishingevent/config/Config.java @@ -198,7 +198,7 @@ public class Config extends AbstractConfig { } private static ItemStack getBook(String npcPrefix) { - ItemStack itemStack = new ItemStack(Material.BOOK); + ItemStack itemStack = new ItemStack(Material.WRITTEN_BOOK); BookMeta bookMeta = (BookMeta) itemStack.getItemMeta(); bookMeta.displayName(MiniMessage.miniMessage().deserialize(config.getString(npcPrefix, "book.item-name", "book name"))); bookMeta.lore(config.getStringList(npcPrefix, "book.item-lore", List.of("book", "lore")).stream() diff --git a/src/main/java/com/alttd/fishingevent/config/Messages.java b/src/main/java/com/alttd/fishingevent/config/Messages.java index 63115a4..8a7c69c 100644 --- a/src/main/java/com/alttd/fishingevent/config/Messages.java +++ b/src/main/java/com/alttd/fishingevent/config/Messages.java @@ -89,11 +89,17 @@ public class Messages extends AbstractConfig { private static final String prefix = "npc."; public static String ALREADY_HAVE_ROD = "You already have a fishing rod"; public static String UPGRADE_NPC_LEFT_CLICK_MESSAGE = "Hey . If you want to catch better fish I can upgrade your fishing rod for you! I don't work free though, if you need Fish Points you can get some by selling your catches!"; + public static String PRIZE_NPC_LEFT_CLICK_MESSAGE = "Hey . If you want to cash out and get some rewards I can trade you some nice prizes for some Fish Points!"; + public static String SELL_NPC_LEFT_CLICK_MESSAGE = "Hey . If you need Fish Points you can get some by selling your catches to me, right click me and put the fishes in my inventory."; + public static String TUTORIAL_NPC_LEFT_CLICK = "Hey . I've given you a fishing rod so you can get started! If you want to know more about how this all works right click me to read the tutorial!"; @SuppressWarnings("unused") private static void load() { ALREADY_HAVE_ROD = config.getString(prefix, "already-have-rod", ALREADY_HAVE_ROD); UPGRADE_NPC_LEFT_CLICK_MESSAGE = config.getString(prefix, "upgrade-npc-left-click-message", UPGRADE_NPC_LEFT_CLICK_MESSAGE); + PRIZE_NPC_LEFT_CLICK_MESSAGE = config.getString(prefix, "prize-npc-left-click-message", PRIZE_NPC_LEFT_CLICK_MESSAGE); + SELL_NPC_LEFT_CLICK_MESSAGE = config.getString(prefix, "sell-npc-left-click-message", SELL_NPC_LEFT_CLICK_MESSAGE); + TUTORIAL_NPC_LEFT_CLICK = config.getString(prefix, "tutorial-npc-left-click-message", TUTORIAL_NPC_LEFT_CLICK); } } diff --git a/src/main/java/com/alttd/fishingevent/npc/types/PrizeNPC.java b/src/main/java/com/alttd/fishingevent/npc/types/PrizeNPC.java index c9bd0f2..53b491f 100644 --- a/src/main/java/com/alttd/fishingevent/npc/types/PrizeNPC.java +++ b/src/main/java/com/alttd/fishingevent/npc/types/PrizeNPC.java @@ -3,7 +3,6 @@ package com.alttd.fishingevent.npc.types; import com.alttd.fishingevent.FishingEvent; import com.alttd.fishingevent.config.Messages; import com.alttd.fishingevent.gui.windows.PrizesWindow; -import com.alttd.fishingevent.gui.windows.UpgradeWindow; import com.alttd.fishingevent.npc.LibNPC; import com.alttd.fishingevent.npc.NPC; import com.alttd.fishingevent.objects.Prize; @@ -12,8 +11,6 @@ import com.alttd.fishingevent.util.NPCCreateData; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.Location; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import java.util.List; @@ -45,7 +42,7 @@ public class PrizeNPC extends LibNPC implements NPC { @Override public void leftClick(Player player) { - player.sendMiniMessage(Messages.NPC.UPGRADE_NPC_LEFT_CLICK_MESSAGE, Placeholder.component("player", player.name())); + player.sendMiniMessage(Messages.NPC.PRIZE_NPC_LEFT_CLICK_MESSAGE, Placeholder.component("player", player.name())); } @Override diff --git a/src/main/java/com/alttd/fishingevent/npc/types/SellNPC.java b/src/main/java/com/alttd/fishingevent/npc/types/SellNPC.java index e3aa275..e5d5c39 100644 --- a/src/main/java/com/alttd/fishingevent/npc/types/SellNPC.java +++ b/src/main/java/com/alttd/fishingevent/npc/types/SellNPC.java @@ -10,7 +10,6 @@ import com.alttd.fishingevent.util.NPCCreateData; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import org.bukkit.Location; import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; public class SellNPC extends LibNPC implements NPC { @@ -38,7 +37,7 @@ public class SellNPC extends LibNPC implements NPC { @Override public void leftClick(Player player) { - player.sendMiniMessage(Messages.NPC.UPGRADE_NPC_LEFT_CLICK_MESSAGE, Placeholder.component("player", player.name())); + player.sendMiniMessage(Messages.NPC.SELL_NPC_LEFT_CLICK_MESSAGE, Placeholder.component("player", player.name())); } @Override diff --git a/src/main/java/com/alttd/fishingevent/npc/types/TutorialNPC.java b/src/main/java/com/alttd/fishingevent/npc/types/TutorialNPC.java index fc4a366..d85736a 100644 --- a/src/main/java/com/alttd/fishingevent/npc/types/TutorialNPC.java +++ b/src/main/java/com/alttd/fishingevent/npc/types/TutorialNPC.java @@ -1,7 +1,6 @@ package com.alttd.fishingevent.npc.types; import com.alttd.fishingevent.FishingEvent; -import com.alttd.fishingevent.config.Config; import com.alttd.fishingevent.config.Messages; import com.alttd.fishingevent.npc.LibNPC; import com.alttd.fishingevent.npc.NPC; @@ -39,21 +38,22 @@ public class TutorialNPC extends LibNPC implements NPC { public void spawnNPC(FishingEvent fishingEvent, Location location) { defaultSpawnNPC(fishingEvent, location, npcCreateData, logger, this); isSpawned = true; - getGlobalNPC().addOpenBookClickAction(dev.sergiferry.playernpc.api.NPC.Interact.ClickType.LEFT_CLICK, book); - } - - @Override - public void leftClick(Player player) { - //Leave empty since we're overwriting the left click action when spawning the npc + getGlobalNPC().addOpenBookClickAction(dev.sergiferry.playernpc.api.NPC.Interact.ClickType.RIGHT_CLICK, book); } @Override public void rightClick(Player player) { + //Leave empty since we're overwriting the right click action when spawning the npc + } + + @Override + public void leftClick(Player player) { if (player.getInventory().first(Material.FISHING_ROD) != -1) { player.sendMiniMessage(Messages.NPC.ALREADY_HAVE_ROD, null); return; } player.getInventory().addItem(getDefaultFishingRod(player)); + player.sendMiniMessage(Messages.NPC.TUTORIAL_NPC_LEFT_CLICK, Placeholder.component("player", player.displayName())); } private ItemStack getDefaultFishingRod(Player player) {