This commit is contained in:
Blackvein 2012-10-29 12:04:31 -07:00
parent 6548d93787
commit 173d33520f
3 changed files with 58 additions and 46 deletions

View File

@ -24,48 +24,24 @@ public class NpcListener implements Listener {
if (plugin.questNPCs.contains(evt.getNPC())) {
final Player player = evt.getClicker();
final Player player = evt.getClicker();
if(Quests.checkQuester())
final Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("talkToNPC")) {
if(plugin.checkQuester(player.getName()) == false){
quester.interactWithNPC(evt.getNPC());
final Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("talkToNPC")) {
} else {
quester.interactWithNPC(evt.getNPC());
for (final Quest q : plugin.quests) {
} else {
if (q.npcStart != null && player.hasPermission("quests.quest")) {
for (final Quest q : plugin.quests) {
if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == false) {
if (q.npcStart != null && player.hasPermission("quests.quest")) {
if (quester.currentQuest == null) {
if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == false) {
quester.questToTake = q.name;
String s =
ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n"
+ "\n"
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
player.sendMessage(s);
plugin.conversationFactory.buildConversation((Conversable) player).begin();
} else if (quester.currentQuest.equals(q) == false) {
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
}
break;
} else if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == true) {
if (quester.currentQuest == null) {
if (quester.getDifference(q) > 0) {
player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + ".");
} else {
if (quester.currentQuest == null) {
quester.questToTake = q.name;
@ -76,24 +52,51 @@ public class NpcListener implements Listener {
player.sendMessage(s);
plugin.conversationFactory.buildConversation((Conversable) player).begin();
} else if (quester.currentQuest.equals(q) == false) {
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
}
} else if (quester.currentQuest.equals(q) == false) {
break;
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
} else if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == true) {
if (quester.currentQuest == null) {
if (quester.getDifference(q) > 0) {
player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + ".");
} else {
quester.questToTake = q.name;
String s =
ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n"
+ "\n"
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
player.sendMessage(s);
plugin.conversationFactory.buildConversation((Conversable) player).begin();
}
} else if (quester.currentQuest.equals(q) == false) {
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
}
break;
}
break;
}
}
}
}
}

View File

@ -24,6 +24,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.event.player.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class PlayerListener implements Listener {
@ -468,13 +469,14 @@ public class PlayerListener implements Listener {
}else{
ItemStack oldStack = evt.getCurrentItem();
HashMap<Integer, ItemStack> map = evt.getInventory().addItem(oldStack);
Inventory inv = plugin.getServer().createInventory(null, evt.getInventory().getType());
HashMap<Integer, ItemStack> map = inv.addItem(oldStack);
if(map.isEmpty() == false){
ItemStack newStack = oldStack.clone();
newStack.setAmount(old)
newStack.setAmount(oldStack.getAmount() - map.get(0).getAmount());
quester.collectItem(newStack);
}else{
quester.collectItem(oldStack);

View File

@ -38,7 +38,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public static Economy economy = null;
public static Permission permission = null;
public static mcMMO mcmmo = null;
HashSet<String> questerBlacklist = new HashSet<String>();
List<String> questerBlacklist = new LinkedList<String>();
ConversationFactory conversationFactory;
QuestFactory questFactory;
Heroes heroes;
@ -3685,9 +3685,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return true;
}
public static boolean checkQuester(String name){
public boolean checkQuester(String name){
for(String s : questerBlacklist){
if(Quests.checkQuester(name, s))
return true;
}
return false;
}