Update for latest Conversations 2

This commit is contained in:
PikaMug 2024-02-08 00:07:51 -05:00
parent c5c7bafa8f
commit 5838e88632
3 changed files with 6 additions and 12 deletions

View File

@ -179,9 +179,9 @@
<version>2.17.1</version> <version>2.17.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.Browsit</groupId> <groupId>com.github.Browsit.ConversationAPI</groupId>
<artifactId>ConversationAPI</artifactId> <artifactId>conversation-bukkit</artifactId>
<version>158a0ee8e3</version> <version>f5e587e641</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.pikamug.quests</groupId> <groupId>me.pikamug.quests</groupId>

View File

@ -51,12 +51,10 @@ import me.pikamug.quests.tasks.BukkitNpcEffectThread;
import me.pikamug.quests.tasks.BukkitPlayerMoveThread; import me.pikamug.quests.tasks.BukkitPlayerMoveThread;
import me.pikamug.quests.util.BukkitLang; import me.pikamug.quests.util.BukkitLang;
import me.pikamug.quests.util.BukkitUpdateChecker; import me.pikamug.quests.util.BukkitUpdateChecker;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.browsit.conversations.api.Conversations; import org.browsit.conversations.api.Conversations;
import org.browsit.conversations.bukkit.BukkitConversations;
import org.browsit.conversations.bukkit.BukkitConversationsForwarder; import org.browsit.conversations.bukkit.BukkitConversationsForwarder;
import org.browsit.conversations.impl.provider.AdventureConversationsProvider;
import org.browsit.libs.kyori.adventure.platform.AudienceProvider;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -127,7 +125,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
@Override @Override
public void onEnable() { public void onEnable() {
/*----> WARNING: ORDER OF STEPS MATTERS <----*/ /*----> WARNING: ORDER OF STEPS MATTERS <----*/
Conversations.init(AdventureConversationsProvider.create((AudienceProvider) BukkitAudiences.create(this))); BukkitConversations.init(this);
new BukkitConversationsForwarder().register(this); new BukkitConversationsForwarder().register(this);
// 1 - Trigger server to initialize Legacy Material Support // 1 - Trigger server to initialize Legacy Material Support

View File

@ -6,8 +6,6 @@ import me.pikamug.quests.util.BukkitLang;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.browsit.conversations.api.Conversations; import org.browsit.conversations.api.Conversations;
import org.browsit.conversations.api.action.Prompt;
import org.browsit.conversations.api.data.Conversation;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -112,24 +110,22 @@ public class QuestAcceptPrompt {
} else { } else {
quester.takeQuest(plugin.getQuestById(questIdToTake), false); quester.takeQuest(plugin.getQuestById(questIdToTake), false);
} }
return;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("n") } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("n")
|| input.equalsIgnoreCase(BukkitLang.get("noWord")) || input.equalsIgnoreCase(BukkitLang.get("noWord"))
|| input.equalsIgnoreCase(BukkitLang.get(player, "noWord"))) { || input.equalsIgnoreCase(BukkitLang.get(player, "noWord"))) {
BukkitLang.send(player, ChatColor.YELLOW + BukkitLang.get("cancelled")); BukkitLang.send(player, ChatColor.YELLOW + BukkitLang.get("cancelled"));
return;
} else { } else {
final String msg = BukkitLang.get(player, "questInvalidChoice") final String msg = BukkitLang.get(player, "questInvalidChoice")
.replace("<yes>", BukkitLang.get(player, "yesWord")) .replace("<yes>", BukkitLang.get(player, "yesWord"))
.replace("<no>", BukkitLang.get(player, "noWord")); .replace("<no>", BukkitLang.get(player, "noWord"));
BukkitLang.send(player, ChatColor.RED + msg); BukkitLang.send(player, ChatColor.RED + msg);
return;
} }
} }
public void start() { public void start() {
Conversations.create(uuid) Conversations.create(uuid)
.prompt(getPromptText(uuid), String.class, prompt -> prompt .prompt(getPromptText(uuid), String.class, prompt -> prompt
.converter(String::valueOf)
.fetch((input, sender) -> acceptInput(uuid, input))) .fetch((input, sender) -> acceptInput(uuid, input)))
.start(); .start();
} }