Fixed messages for npc's and made the left/right click actions more consistent

This commit is contained in:
Teriuihi 2023-09-24 23:07:42 +02:00
parent 7960cece04
commit 569e6a3334
5 changed files with 16 additions and 14 deletions

View File

@ -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", "<red>book name</red>")));
bookMeta.lore(config.getStringList(npcPrefix, "book.item-lore", List.of("<green>book</green>", "<red>lore</red>")).stream()

View File

@ -89,11 +89,17 @@ public class Messages extends AbstractConfig {
private static final String prefix = "npc.";
public static String ALREADY_HAVE_ROD = "<red>You already have a fishing rod</red>";
public static String UPGRADE_NPC_LEFT_CLICK_MESSAGE = "<green>Hey <player>. If you want to catch better fish I can upgrade your fishing rod for you! I don't work free though, if you need <gold>Fish Points</gold> you can get some by selling your catches!</green>";
public static String PRIZE_NPC_LEFT_CLICK_MESSAGE = "<green>Hey <player>. If you want to cash out and get some rewards I can trade you some nice prizes for some <gold>Fish Points</gold>!</green>";
public static String SELL_NPC_LEFT_CLICK_MESSAGE = "<green>Hey <player>. If you need <gold>Fish Points</gold> you can get some by selling your catches to me, right click me and put the fishes in my inventory.</green>";
public static String TUTORIAL_NPC_LEFT_CLICK = "<green>Hey <player>. 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!</green>";
@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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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) {