mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Cleaner quest accept prompt input
This commit is contained in:
parent
49392e5d1c
commit
c5a753e19e
@ -172,8 +172,7 @@ public interface IQuester extends Comparable<IQuester> {
|
|||||||
|
|
||||||
void smeltItem(final IQuest quest, final ItemStack itemStack);
|
void smeltItem(final IQuest quest, final ItemStack itemStack);
|
||||||
|
|
||||||
void enchantBook(final IQuest quest, final ItemStack itemStack,
|
void enchantBook(final IQuest quest, final ItemStack itemStack, final Map<Enchantment, Integer> enchantsToAdd);
|
||||||
final Map<Enchantment, Integer> enchantsToAdd);
|
|
||||||
|
|
||||||
void enchantItem(final IQuest quest, final ItemStack itemStack);
|
void enchantItem(final IQuest quest, final ItemStack itemStack);
|
||||||
|
|
||||||
|
@ -492,12 +492,9 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
* Get Quester from player UUID
|
* Get Quester from player UUID
|
||||||
*
|
*
|
||||||
* @param id Player UUID
|
* @param id Player UUID
|
||||||
* @return Quester, or null if UUID is null
|
* @return new or existing Quester
|
||||||
*/
|
*/
|
||||||
public Quester getQuester(final UUID id) {
|
public Quester getQuester(final @NotNull UUID id) {
|
||||||
if (id == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final ConcurrentSkipListSet<IQuester> set = (ConcurrentSkipListSet<IQuester>) questers;
|
final ConcurrentSkipListSet<IQuester> set = (ConcurrentSkipListSet<IQuester>) questers;
|
||||||
for (final IQuester q : set) {
|
for (final IQuester q : set) {
|
||||||
if (q != null && q.getUUID().equals(id)) {
|
if (q != null && q.getUUID().equals(id)) {
|
||||||
@ -738,28 +735,15 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
final Player player = (Player) context.getForWhom();
|
final Player player = (Player) context.getForWhom();
|
||||||
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y")
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y")
|
||||||
|| input.equalsIgnoreCase(Lang.get(player, "yesWord"))) {
|
|| input.equalsIgnoreCase(Lang.get(player, "yesWord"))) {
|
||||||
IQuester quester = getQuester(player.getUniqueId());
|
final IQuester quester = getQuester(player.getUniqueId());
|
||||||
if (quester == null) {
|
|
||||||
// Must be new player
|
|
||||||
quester = new Quester(Quests.this, player.getUniqueId());
|
|
||||||
if (quester.saveData()) {
|
|
||||||
getLogger().info("Created new data for player " + player.getName());
|
|
||||||
} else {
|
|
||||||
Lang.send(player, ChatColor.RED + Lang.get(player, "questSaveError"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String questIdToTake = quester.getQuestIdToTake();
|
final String questIdToTake = quester.getQuestIdToTake();
|
||||||
try {
|
if (getQuestByIdTemp(questIdToTake) == null) {
|
||||||
if (getQuestByIdTemp(questIdToTake) == null) {
|
getLogger().warning(player.getName() + " attempted to take quest ID \"" + questIdToTake
|
||||||
getLogger().info(player.getName() + " attempted to take quest ID \"" + questIdToTake
|
+ "\" but something went wrong");
|
||||||
+ "\" but something went wrong");
|
player.sendMessage(ChatColor.RED
|
||||||
player.sendMessage(ChatColor.RED
|
+ "Something went wrong! Please report issue to an administrator.");
|
||||||
+ "Something went wrong! Please report issue to an administrator.");
|
} else {
|
||||||
} else {
|
quester.takeQuest(getQuestByIdTemp(questIdToTake), false);
|
||||||
getQuester(player.getUniqueId()).takeQuest(getQuestByIdTemp(questIdToTake), false);
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("n")
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("n")
|
||||||
|
@ -27,6 +27,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -132,7 +133,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public @Nonnull String getPromptText(final ConversationContext context) {
|
public @NotNull String getPromptText(final ConversationContext context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
||||||
final String npc = (String) context.getSessionData("npc");
|
final String npc = (String) context.getSessionData("npc");
|
||||||
|
Loading…
Reference in New Issue
Block a user