mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-16 12:31:19 +01:00
Finished switching to Conversation API. Questioner is no longer a dependency.
This commit is contained in:
parent
0885806182
commit
f0119d7c8d
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -21,6 +22,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
public class Event {
|
||||
|
||||
String name = "";
|
||||
|
||||
String message = null;
|
||||
boolean clearInv = false;
|
||||
LinkedList<Location> explosions = new LinkedList<Location>();
|
||||
@ -45,7 +47,7 @@ public class Event {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
|
||||
|
||||
if(o instanceof Event){
|
||||
|
||||
Event other = (Event) o;
|
||||
|
@ -1,12 +1,9 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import ca.xshade.questionmanager.Option;
|
||||
import ca.xshade.questionmanager.Question;
|
||||
import java.util.LinkedList;
|
||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -40,76 +37,12 @@ public class NpcListener implements Listener{
|
||||
|
||||
if(q.npcStart != null && player.hasPermission("quests.quest")){
|
||||
|
||||
if(q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q) == false){
|
||||
if(q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == false){
|
||||
|
||||
if(quester.currentQuest == null){
|
||||
|
||||
LinkedList<Option> options = new LinkedList<Option>();
|
||||
Option yes = new Option("Yes", new Runnable(){
|
||||
|
||||
public void run(){
|
||||
|
||||
if(q.testRequirements(player) == true){
|
||||
|
||||
quester.currentQuest = q;
|
||||
quester.currentStage = q.stages.getFirst();
|
||||
quester.addEmpties();
|
||||
quester.isTalking = false;
|
||||
if(q.moneyReq > 0){
|
||||
Quests.economy.withdrawPlayer(quester.name, q.moneyReq);
|
||||
}
|
||||
|
||||
for(int i : q.itemIds){
|
||||
if (q.removeItems.get(i) == true)
|
||||
Quests.removeItem(player.getInventory(), Material.getMaterial(i), q.itemAmounts.get(q.itemIds.indexOf(i)));
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for(String s : quester.getObjectives()){
|
||||
player.sendMessage(s);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
player.sendMessage(npc.getName() + ": " + q.failRequirements);
|
||||
quester.isTalking = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Option no = new Option("No", new Runnable(){
|
||||
|
||||
public void run(){
|
||||
|
||||
quester.isTalking = false;
|
||||
player.sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
options.add(yes);
|
||||
options.add(no);
|
||||
|
||||
if(quester.isTalking == false){
|
||||
|
||||
quester.isTalking = true;
|
||||
Question question = new Question(player.getName(), "Accept quest?", options);
|
||||
plugin.questioner.getQuestionManager().newQuestion(question);
|
||||
player.sendMessage(ChatColor.GOLD + "- " + q.name + " -");
|
||||
player.sendMessage(npc.getName() + ": " + q.description);
|
||||
try{
|
||||
plugin.questioner.appendQuestion(question);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
quester.questToTake = q;
|
||||
plugin.conversationFactory.buildConversation((Conversable)player).begin();
|
||||
|
||||
}else {
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import ca.xshade.questionmanager.Option;
|
||||
import ca.xshade.questionmanager.Question;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -62,72 +60,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
}else {
|
||||
|
||||
LinkedList<Option> options = new LinkedList<Option>();
|
||||
Option yes = new Option("Yes", new Runnable(){
|
||||
|
||||
public void run(){
|
||||
|
||||
if(q.testRequirements(player) == true){
|
||||
|
||||
quester.currentQuest = q;
|
||||
quester.currentStage = q.stages.getFirst();
|
||||
quester.addEmpties();
|
||||
quester.isTalking = false;
|
||||
if (q.moneyReq > 0) {
|
||||
Quests.economy.withdrawPlayer(quester.name, q.moneyReq);
|
||||
}
|
||||
|
||||
for(int i : q.itemIds){
|
||||
if (q.removeItems.get(q.itemIds.indexOf(i)) == true)
|
||||
Quests.removeItem(player.getInventory(), Material.getMaterial(i), q.itemAmounts.get(q.itemIds.indexOf(i)));
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for (String s : quester.getObjectives()) {
|
||||
player.sendMessage(s);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
player.sendMessage(q.failRequirements);
|
||||
quester.isTalking = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Option no = new Option("No", new Runnable(){
|
||||
|
||||
public void run(){
|
||||
|
||||
quester.isTalking = false;
|
||||
player.sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
options.add(yes);
|
||||
options.add(no);
|
||||
|
||||
if(quester.isTalking == false){
|
||||
|
||||
quester.isTalking = true;
|
||||
Question question = new Question(player.getName(), "Accept quest?", options);
|
||||
plugin.questioner.getQuestionManager().newQuestion(question);
|
||||
player.sendMessage(ChatColor.GOLD + "- " + q.name + " -");
|
||||
player.sendMessage(q.description);
|
||||
try{
|
||||
plugin.questioner.appendQuestion(question);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
quester.questToTake = q;
|
||||
plugin.conversationFactory.buildConversation((Conversable)player).begin();
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,5 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import ca.xshade.bukkit.questioner.Questioner;
|
||||
import ca.xshade.questionmanager.Option;
|
||||
import ca.xshade.questionmanager.Question;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.herocraftonline.heroes.Heroes;
|
||||
@ -30,7 +27,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -60,7 +56,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
boolean debug = false;
|
||||
boolean load = false;
|
||||
int killDelay = 0;
|
||||
Questioner questioner;
|
||||
public final static Logger log = Logger.getLogger("Minecraft");
|
||||
Map<Location, String> brewers = new HashMap<Location, String>();
|
||||
|
||||
@ -103,7 +98,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
mcmmo = (mcMMO) getServer().getPluginManager().getPlugin("mcMMO");
|
||||
}
|
||||
|
||||
questioner = (Questioner) getServer().getPluginManager().getPlugin("Questioner");
|
||||
if (!setupEconomy()) {
|
||||
printWarning("[Quests] Economy not found.");
|
||||
}
|
||||
@ -210,14 +204,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext context, String s) {
|
||||
|
||||
Player player = (Player) context.getForWhom();
|
||||
if (s.equalsIgnoreCase("Yes") == false) {
|
||||
|
||||
((Player)context.getForWhom()).sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||
player.sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
||||
}
|
||||
|
||||
context.setSessionData("type", s);
|
||||
return new HowManyPrompt();
|
||||
context.setSessionData("who", player.getName());
|
||||
context.setSessionData("message", s);
|
||||
|
||||
player.sendMessage(new SummoningConversationPrefix().getPrefix(context));
|
||||
|
||||
getQuester(player.getName()).takeQuest(getQuester(player.getName()).questToTake);
|
||||
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,19 +228,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
|
||||
@Override
|
||||
public String getPrefix(ConversationContext context) {
|
||||
Player who = (Player)context.getSessionData("who");
|
||||
|
||||
if (what != null && count == null && who == null) {
|
||||
return ChatColor.GREEN + "Summon " + what + ": " + ChatColor.WHITE;
|
||||
}
|
||||
if (what != null && count != null && who == null) {
|
||||
return ChatColor.GREEN + "Summon " + count + " " + what + ": " + ChatColor.WHITE;
|
||||
}
|
||||
if (what != null && count != null && who != null) {
|
||||
return ChatColor.GREEN + "Summon " + count + " " + what + " to " + who.getName() + ": " + ChatColor.WHITE;
|
||||
}
|
||||
return ChatColor.GREEN + "Summon: " + ChatColor.WHITE;
|
||||
String who = (String)context.getSessionData("who");
|
||||
return ChatColor.GREEN + who + ": " + ChatColor.GRAY + (String) context.getSessionData("message");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -637,72 +631,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
}
|
||||
|
||||
if (takeable == true) {
|
||||
LinkedList<Option> options = new LinkedList<Option>();
|
||||
Option yes = new Option("Yes", new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (quest.testRequirements((Player) sender) == true) {
|
||||
|
||||
quester.currentQuest = quest;
|
||||
quester.currentStage = quest.stages.getFirst();
|
||||
quester.addEmpties();
|
||||
quester.isTalking = false;
|
||||
if (quest.moneyReq > 0) {
|
||||
economy.withdrawPlayer(quester.name, quest.moneyReq);
|
||||
}
|
||||
|
||||
for (int i : quest.itemIds) {
|
||||
if (quest.removeItems.get(quest.itemIds.indexOf(i)) == true) {
|
||||
removeItem(((Player) sender).getInventory(), Material.getMaterial(i), quest.itemAmounts.get(quest.itemIds.indexOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Quest accepted: " + quest.name);
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for (String s : quester.getObjectives()) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage(quest.failRequirements);
|
||||
quester.isTalking = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Option no = new Option("No", new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
quester.isTalking = false;
|
||||
sender.sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
options.add(yes);
|
||||
options.add(no);
|
||||
|
||||
if (quester.isTalking == false) {
|
||||
|
||||
quester.isTalking = true;
|
||||
Question question = new Question(sender.getName(), "Accept quest?", options);
|
||||
questioner.getQuestionManager().newQuestion(question);
|
||||
sender.sendMessage(ChatColor.GOLD + "- " + quest.name + " -");
|
||||
sender.sendMessage(quest.description);
|
||||
try {
|
||||
questioner.appendQuestion(question);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (cs instanceof Conversable) {
|
||||
quester.questToTake = quest;
|
||||
conversationFactory.buildConversation((Conversable)cs).begin();
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1154,7 +1089,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||
quester.currentQuest = questToGive;
|
||||
quester.currentStage = questToGive.stages.getFirst();
|
||||
quester.addEmpties();
|
||||
quester.isTalking = false;
|
||||
player.sendMessage(ChatColor.GREEN + target.getName() + ChatColor.GOLD + " has forcibly started the Quest " + ChatColor.DARK_PURPLE + questToGive.name + ChatColor.GOLD + ".");
|
||||
target.sendMessage(ChatColor.GREEN + player.getName() + ChatColor.GOLD + " has forced you to take the Quest " + ChatColor.DARK_PURPLE + questToGive.name + ChatColor.GOLD + ".");
|
||||
target.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
|
@ -16,17 +16,17 @@ public class Stage {
|
||||
|
||||
public String finished;
|
||||
|
||||
Map<Material, Integer> blocksToDamage = new HashMap<Material, Integer>();
|
||||
Map<Material, Integer> blocksToDamage = new EnumMap<Material, Integer>(Material.class);
|
||||
|
||||
Map<Material, Integer> blocksToBreak = new HashMap<Material, Integer>();
|
||||
Map<Material, Integer> blocksToBreak = new EnumMap<Material, Integer>(Material.class);
|
||||
|
||||
Map<Material, Integer> blocksToPlace = new HashMap<Material, Integer>();
|
||||
Map<Material, Integer> blocksToPlace = new EnumMap<Material, Integer>(Material.class);
|
||||
|
||||
Map<Map<Material, Integer>, Boolean> itemsToCollect = new HashMap<Map<Material, Integer>, Boolean>();
|
||||
|
||||
Map<Material, Integer> blocksToUse = new HashMap<Material, Integer>();
|
||||
Map<Material, Integer> blocksToUse = new EnumMap<Material, Integer>(Material.class);
|
||||
|
||||
Map<Material, Integer> blocksToCut = new HashMap<Material, Integer>();
|
||||
Map<Material, Integer> blocksToCut = new EnumMap<Material, Integer>(Material.class);
|
||||
|
||||
Integer fishToCatch;
|
||||
Integer playersToKill;
|
||||
|
@ -5,7 +5,7 @@ description: Player questing system
|
||||
website: http://dev.bukkit.org/server-mods/quests/
|
||||
dev-url: http://dev.bukkit.org/server-mods/quests/
|
||||
authors: [Blackvein]
|
||||
soft-depend: [Citizens, Questioner, Vault]
|
||||
soft-depend: [Citizens, Vault]
|
||||
permissions:
|
||||
quests.quest:
|
||||
description: View current Quest objectives
|
||||
|
Loading…
Reference in New Issue
Block a user