mirror of https://github.com/PikaMug/Quests.git
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.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Scanner;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -21,6 +22,7 @@ import org.bukkit.potion.PotionEffect;
|
||||||
public class Event {
|
public class Event {
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
|
|
||||||
String message = null;
|
String message = null;
|
||||||
boolean clearInv = false;
|
boolean clearInv = false;
|
||||||
LinkedList<Location> explosions = new LinkedList<Location>();
|
LinkedList<Location> explosions = new LinkedList<Location>();
|
||||||
|
@ -45,7 +47,7 @@ public class Event {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o){
|
public boolean equals(Object o){
|
||||||
|
|
||||||
if(o instanceof Event){
|
if(o instanceof Event){
|
||||||
|
|
||||||
Event other = (Event) o;
|
Event other = (Event) o;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package me.blackvein.quests;
|
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.event.NPCRightClickEvent;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.conversations.Conversable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
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 != 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){
|
if(quester.currentQuest == null){
|
||||||
|
|
||||||
LinkedList<Option> options = new LinkedList<Option>();
|
quester.questToTake = q;
|
||||||
Option yes = new Option("Yes", new Runnable(){
|
plugin.conversationFactory.buildConversation((Conversable)player).begin();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package me.blackvein.quests;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
import ca.xshade.questionmanager.Option;
|
|
||||||
import ca.xshade.questionmanager.Question;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.LinkedList;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.conversations.Conversable;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -62,72 +60,8 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
LinkedList<Option> options = new LinkedList<Option>();
|
quester.questToTake = q;
|
||||||
Option yes = new Option("Yes", new Runnable(){
|
plugin.conversationFactory.buildConversation((Conversable)player).begin();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,5 @@
|
||||||
package me.blackvein.quests;
|
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.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.herocraftonline.heroes.Heroes;
|
import com.herocraftonline.heroes.Heroes;
|
||||||
|
@ -30,7 +27,6 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
@ -60,7 +56,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||||
boolean debug = false;
|
boolean debug = false;
|
||||||
boolean load = false;
|
boolean load = false;
|
||||||
int killDelay = 0;
|
int killDelay = 0;
|
||||||
Questioner questioner;
|
|
||||||
public final static Logger log = Logger.getLogger("Minecraft");
|
public final static Logger log = Logger.getLogger("Minecraft");
|
||||||
Map<Location, String> brewers = new HashMap<Location, String>();
|
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");
|
mcmmo = (mcMMO) getServer().getPluginManager().getPlugin("mcMMO");
|
||||||
}
|
}
|
||||||
|
|
||||||
questioner = (Questioner) getServer().getPluginManager().getPlugin("Questioner");
|
|
||||||
if (!setupEconomy()) {
|
if (!setupEconomy()) {
|
||||||
printWarning("[Quests] Economy not found.");
|
printWarning("[Quests] Economy not found.");
|
||||||
}
|
}
|
||||||
|
@ -210,14 +204,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, String s) {
|
protected Prompt acceptValidatedInput(ConversationContext context, String s) {
|
||||||
|
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
if (s.equalsIgnoreCase("Yes") == false) {
|
if (s.equalsIgnoreCase("Yes") == false) {
|
||||||
|
|
||||||
((Player)context.getForWhom()).sendMessage(ChatColor.YELLOW + "Cancelled.");
|
player.sendMessage(ChatColor.YELLOW + "Cancelled.");
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.setSessionData("type", s);
|
context.setSessionData("who", player.getName());
|
||||||
return new HowManyPrompt();
|
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
|
@Override
|
||||||
public String getPrefix(ConversationContext context) {
|
public String getPrefix(ConversationContext context) {
|
||||||
Player who = (Player)context.getSessionData("who");
|
String who = (String)context.getSessionData("who");
|
||||||
|
return ChatColor.GREEN + who + ": " + ChatColor.GRAY + (String) context.getSessionData("message");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -637,72 +631,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (takeable == true) {
|
if (takeable == true) {
|
||||||
LinkedList<Option> options = new LinkedList<Option>();
|
|
||||||
Option yes = new Option("Yes", new Runnable() {
|
if (cs instanceof Conversable) {
|
||||||
|
quester.questToTake = quest;
|
||||||
@Override
|
conversationFactory.buildConversation((Conversable)cs).begin();
|
||||||
public void run() {
|
return true;
|
||||||
|
}else{
|
||||||
if (quest.testRequirements((Player) sender) == true) {
|
return false;
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1089,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
|
||||||
quester.currentQuest = questToGive;
|
quester.currentQuest = questToGive;
|
||||||
quester.currentStage = questToGive.stages.getFirst();
|
quester.currentStage = questToGive.stages.getFirst();
|
||||||
quester.addEmpties();
|
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 + ".");
|
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.GREEN + player.getName() + ChatColor.GOLD + " has forced you to take the Quest " + ChatColor.DARK_PURPLE + questToGive.name + ChatColor.GOLD + ".");
|
||||||
target.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
target.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||||
|
|
|
@ -16,17 +16,17 @@ public class Stage {
|
||||||
|
|
||||||
public String finished;
|
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<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 fishToCatch;
|
||||||
Integer playersToKill;
|
Integer playersToKill;
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Player questing system
|
||||||
website: http://dev.bukkit.org/server-mods/quests/
|
website: http://dev.bukkit.org/server-mods/quests/
|
||||||
dev-url: http://dev.bukkit.org/server-mods/quests/
|
dev-url: http://dev.bukkit.org/server-mods/quests/
|
||||||
authors: [Blackvein]
|
authors: [Blackvein]
|
||||||
soft-depend: [Citizens, Questioner, Vault]
|
soft-depend: [Citizens, Vault]
|
||||||
permissions:
|
permissions:
|
||||||
quests.quest:
|
quests.quest:
|
||||||
description: View current Quest objectives
|
description: View current Quest objectives
|
||||||
|
|
Loading…
Reference in New Issue