Added WorldGuard support

This commit is contained in:
Blackvein 2013-11-08 15:16:39 -08:00
parent 1ca1da2cf1
commit b0c813eec2
13 changed files with 489 additions and 55 deletions

Binary file not shown.

BIN
lib/PhatLoots.jar Normal file

Binary file not shown.

BIN
lib/WorldEdit.jar Normal file

Binary file not shown.

BIN
lib/WorldGuard.jar Normal file

Binary file not shown.

23
pom.xml
View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.6.9-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>
@ -87,6 +87,27 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/rpgitems.jar</systemPath>
</dependency>
<dependency>
<groupId>com.codisimus.phatloots</groupId>
<artifactId>PhatLoots</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/PhatLoots.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/WorldEdit.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>WorldGuard</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/WorldGuard.jar</systemPath>
</dependency>
</dependencies>
<build>

View File

@ -4,4 +4,10 @@ Heroes support
heroes-secondary-class:
Rewards
heroes-exp-classes:
heroes-exp-amounts:
heroes-exp-amounts:
PhatLoots support
Rewards
phat-loots:
WorldGuard support
Quest Attributes
region:

View File

@ -1,8 +1,14 @@
package me.blackvein.quests;
import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.codisimus.plugins.phatloots.loot.CommandLoot;
import com.codisimus.plugins.phatloots.loot.LootBundle;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.characters.Hero;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.util.ItemUtil;
@ -22,6 +28,7 @@ public class Quest {
public String description;
public String finished;
public long redoDelay = -1;
public String region = null;
public int parties = 0;
LinkedList<Stage> stages = new LinkedList<Stage>();
NPC npcStart;
@ -55,6 +62,7 @@ public class Quest {
List<Integer> mcmmoAmounts = new LinkedList<Integer>();
List<String> heroesClasses = new LinkedList<String>();
List<Double> heroesAmounts = new LinkedList<Double>();
List<String> phatLootRewards = new LinkedList<String>();
//
public void nextStage(Quester q) {
@ -287,6 +295,42 @@ public class Quest {
none = null;
}
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
int phatLootExp = 0;
int phatLootMoney = 0;
LinkedList<String> phatLootMessages = new LinkedList<String>();
for(String s : phatLootRewards) {
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
if(lb.getExp() > 0){
phatLootExp += lb.getExp();
player.giveExp(lb.getExp());
}
if(lb.getMoney() > 0){
phatLootMoney += lb.getMoney();
Quests.economy.depositPlayer(player.getName(), lb.getMoney());
}
if(lb.getItemList().isEmpty() == false){
phatLootItems.addAll(lb.getItemList());
for(ItemStack is : lb.getItemList())
Quests.addItem(player, is);
}
if(lb.getCommandList().isEmpty() == false){
for(CommandLoot cl : lb.getCommandList())
cl.execute(player);
}
if(lb.getMessageList().isEmpty() == false)
phatLootMessages.addAll(lb.getMessageList());
}
if (exp > 0) {
player.giveExp(exp);
@ -310,6 +354,20 @@ public class Quest {
}
for (ItemStack i : itemRewards) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else if (i.getDurability() != 0) {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount());
}
none = null;
}
for (ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else if (i.getDurability() != 0) {
@ -329,8 +387,10 @@ public class Quest {
none = null;
}
if (exp > 0) {
player.sendMessage("- " + ChatColor.DARK_GREEN + exp + ChatColor.DARK_PURPLE + " Experience");
if (exp > 0 || phatLootExp > 0) {
int tot = exp + phatLootExp;
player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " Experience");
none = null;
}
@ -338,17 +398,27 @@ public class Quest {
for (String s : mcmmoSkills) {
player.sendMessage("- " + ChatColor.DARK_GREEN + mcmmoAmounts.get(mcmmoSkills.indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " Experience");
}
none = null;
}
if (heroesClasses.isEmpty() == false) {
for (String s : heroesClasses) {
player.sendMessage("- " + ChatColor.AQUA + heroesAmounts.get(heroesClasses.indexOf(s)) + " " + ChatColor.BLUE + s + " Experience");
}
none = null;
}
if(phatLootMessages.isEmpty() == false) {
for (String s : phatLootMessages){
player.sendMessage("- " + s);
}
none = null;
}
if (none != null) {
player.sendMessage(none);
}
q.currentQuest = null;
q.currentStage = null;
@ -469,6 +539,10 @@ public class Quest {
if (other.heroesAmounts.equals(heroesAmounts) == false) {
return false;
}
if(other.phatLootRewards.equals(phatLootRewards) == false) {
return false;
}
if (other.moneyReq != moneyReq) {
return false;
@ -557,5 +631,24 @@ public class Quest {
return true;
}
public boolean isInRegion(Player player){
if(region == null){
return true;
}else{
ApplicableRegionSet ars = Quests.worldGuard.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation());
Iterator<ProtectedRegion> i = ars.iterator();
while(i.hasNext()){
ProtectedRegion pr = i.next();
if(pr.getId().equalsIgnoreCase(region))
return true;
}
return false;
}
}
}

View File

@ -1,5 +1,7 @@
package me.blackvein.quests;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.blackvein.quests.util.ColorUtil;
import java.io.File;
import java.io.IOException;
@ -20,6 +22,7 @@ import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
@ -148,7 +151,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public CreateMenuPrompt() {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13");
}
@ -211,55 +214,87 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
}
if(Quests.worldGuard != null){
if (context.getSessionData(CK.Q_REGION) == null){
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set Region (None set)\n";
} else {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Region (None set)\n";
}
} else {
if (quests.citizens != null) {
String s = (String) context.getSessionData(CK.Q_REGION);
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set Region (" + GREEN + s + YELLOW + ")\n";
} else {
String s = (String) context.getSessionData(CK.Q_REGION);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Region (" + GREEN + s + YELLOW + ")\n";
}
}
}else {
if (quests.citizens != null) {
text += GRAY + "7 - Set Region (WorldGuard not installed)\n";
} else {
text += GRAY + "6 - Set Region (WorldGuard not installed)\n";
}
}
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
} else {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
}
} else {
if (quests.citizens != null) {
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
} else {
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
}
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "9" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
} else {
text += BLUE + "" + BOLD + "8" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
} else {
text += BLUE + "" + BOLD + "7" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "10" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
} else {
text += BLUE + "" + BOLD + "9" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
} else {
text += BLUE + "" + BOLD + "8" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "11" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
} else {
text += BLUE + "" + BOLD + "10" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
} else {
text += BLUE + "" + BOLD + "9" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "12" + RESET + GOLD + " - " + Lang.get("save") + "\n";
} else {
text += BLUE + "" + BOLD + "11" + RESET + GOLD + " - " + Lang.get("save") + "\n";
} else {
text += BLUE + "" + BOLD + "10" + RESET + GOLD + " - " + Lang.get("save") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "12" + RESET + RED + " - " + Lang.get("exit") + "\n";
text += BLUE + "" + BOLD + "13" + RESET + RED + " - " + Lang.get("exit") + "\n";
} else {
text += BLUE + "" + BOLD + "11" + RESET + RED + " - " + Lang.get("exit") + "\n";
text += BLUE + "" + BOLD + "12" + RESET + RED + " - " + Lang.get("exit") + "\n";
}
return text;
@ -299,58 +334,70 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (quests.citizens != null) {
selectedBlockStarts.put((Player) context.getForWhom(), null);
return new BlockStartPrompt();
} else if (Quests.worldGuard != null) {
return new RegionPrompt();
} else {
return new InitialEventPrompt();
return new CreateMenuPrompt();
}
} else if (input.equalsIgnoreCase("7")) {
if (quests.citizens != null) {
return new InitialEventPrompt();
if (quests.citizens != null && Quests.worldGuard != null) {
return new RegionPrompt();
}else if (quests.citizens != null) {
return new CreateMenuPrompt();
} else {
return new RequirementsPrompt(quests, QuestFactory.this);
return new InitialEventPrompt();
}
} else if (input.equalsIgnoreCase("8")) {
if (quests.citizens != null) {
return new RequirementsPrompt(quests, QuestFactory.this);
return new InitialEventPrompt();
} else {
return new StagesPrompt(QuestFactory.this);
return new RequirementsPrompt(quests, QuestFactory.this);
}
} else if (input.equalsIgnoreCase("9")) {
if (quests.citizens != null) {
return new StagesPrompt(QuestFactory.this);
return new RequirementsPrompt(quests, QuestFactory.this);
} else {
return new RewardsPrompt(quests, QuestFactory.this);
return new StagesPrompt(QuestFactory.this);
}
} else if (input.equalsIgnoreCase("10")) {
if (quests.citizens != null) {
return new RewardsPrompt(quests, QuestFactory.this);
return new StagesPrompt(QuestFactory.this);
} else {
return new SavePrompt();
return new RewardsPrompt(quests, QuestFactory.this);
}
} else if (input.equalsIgnoreCase("11")) {
if (quests.citizens != null) {
return new SavePrompt();
return new RewardsPrompt(quests, QuestFactory.this);
} else {
return new ExitPrompt();
return new SavePrompt();
}
} else if (input.equalsIgnoreCase("12")) {
if (quests.citizens != null) {
return new ExitPrompt();
return new SavePrompt();
} else {
return new CreateMenuPrompt();
return new ExitPrompt();
}
} else if (input.equalsIgnoreCase("13")) {
if (quests.citizens != null) {
return new ExitPrompt();
}else{
return new CreateMenuPrompt();
}
}
return null;
@ -714,6 +761,83 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
}
private class RegionPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = DARKGREEN + "- Quest Region -\n";
boolean any = false;
for(World world : quests.getServer().getWorlds()){
RegionManager rm = Quests.worldGuard.getRegionManager(world);
for(String region : rm.getRegions().keySet()){
any = true;
text += GREEN + region + ", ";
}
}
if(any) {
text = text.substring(0, text.length() - 2);
text += "\n\n";
}else {
text += GRAY + "(None)\n\n";
}
return text + YELLOW + "Enter WorldGuard region, or enter \"clear\" to clear the region, or \"cancel\" to return.";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String found = null;
boolean done = false;
for(World world : quests.getServer().getWorlds()){
RegionManager rm = Quests.worldGuard.getRegionManager(world);
for(String region : rm.getRegions().keySet()){
if(region.equalsIgnoreCase(input)){
found = region;
done = true;
break;
}
}
if(done)
break;
}
if (found == null) {
player.sendMessage(RED + input + YELLOW + " is not a valid WorldGuard region!");
return new RegionPrompt();
} else {
context.setSessionData(CK.Q_REGION, found);
return new CreateMenuPrompt();
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.Q_REGION, null);
player.sendMessage(YELLOW + "Quest region cleared.");
return new CreateMenuPrompt();
} else {
return new CreateMenuPrompt();
}
}
}
private class RedoDelayPrompt extends NumericPrompt {
@ -867,6 +991,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
Integer npcStart = null;
String blockStart = null;
String initialEvent = null;
String region = null;
Integer moneyReq = null;
Integer questPointsReq = null;
@ -893,6 +1018,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Integer> mcMMOSkillAmounts = null;
LinkedList<String> heroesClassRews = null;
LinkedList<Double> heroesExpRews = null;
LinkedList<String> phatLootRews = null;
if (cc.getSessionData(CK.Q_REDO_DELAY) != null) {
@ -952,6 +1078,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData(CK.Q_INITIAL_EVENT) != null) {
initialEvent = (String) cc.getSessionData(CK.Q_INITIAL_EVENT);
}
if (cc.getSessionData(CK.Q_REGION) != null) {
region = (String) cc.getSessionData(CK.Q_REGION);
}
if (cc.getSessionData(CK.REW_MONEY) != null) {
moneyRew = (Integer) cc.getSessionData(CK.REW_MONEY);
@ -1000,6 +1130,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
heroesClassRews = (LinkedList<String>) cc.getSessionData(CK.REW_HEROES_CLASSES);
heroesExpRews = (LinkedList<Double>) cc.getSessionData(CK.REW_HEROES_AMOUNTS);
}
if (cc.getSessionData(CK.REW_PHAT_LOOTS) != null) {
phatLootRews = (LinkedList<String>) cc.getSessionData(CK.REW_PHAT_LOOTS);
}
cs.set("name", name);
cs.set("npc-giver-id", npcStart);
@ -1007,7 +1141,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("redo-delay", redo);
cs.set("ask-message", desc);
cs.set("finish-message", finish);
cs.set(CK.S_FINISH_EVENT, initialEvent);
cs.set("initial-event", initialEvent);
cs.set("region", region);
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false) || heroesPrimaryReq != null || heroesSecondaryReq != null) {
@ -1367,11 +1502,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
System.out.println("HERE 1");
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false || mcMMOSkillRews != null || RPGItemRews != null || heroesClassRews != null && heroesClassRews.isEmpty() == false) {
System.out.println("HERE 2");
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false || mcMMOSkillRews != null || RPGItemRews != null || heroesClassRews != null && heroesClassRews.isEmpty() == false || phatLootRews != null && phatLootRews.isEmpty() == false) {
ConfigurationSection rews = cs.createSection("rewards");
@ -1387,13 +1518,12 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
rews.set("rpgitem-amounts", RPGItemAmounts);
rews.set("heroes-exp-classes", heroesClassRews);
rews.set("heroes-exp-amounts", heroesExpRews);
rews.set("phat-loots", phatLootRews);
} else {
cs.set("rewards", null);
}
System.out.println("HERE 3");
}
public static void loadQuest(ConversationContext cc, Quest q) {
@ -1412,6 +1542,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (q.initialEvent != null) {
cc.setSessionData(CK.Q_INITIAL_EVENT, q.initialEvent.getName());
}
if(q.region != null) {
cc.setSessionData(CK.Q_REGION, q.region);
}
//Requirements
if (q.moneyReq != 0) {
@ -1503,6 +1637,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses);
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
}
if(q.phatLootRewards.isEmpty() == false) {
cc.setSessionData(CK.REW_PHAT_LOOTS, q.phatLootRewards);
}
//
//Stages

View File

@ -1,5 +1,7 @@
package me.blackvein.quests;
import com.codisimus.plugins.phatloots.PhatLoots;
import com.codisimus.plugins.phatloots.PhatLootsAPI;
import me.blackvein.quests.util.ColorUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
@ -8,6 +10,9 @@ import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
@ -20,6 +25,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@ -47,6 +53,7 @@ import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
@ -80,10 +87,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public final static Logger log = Logger.getLogger("Minecraft");
public static Economy economy = null;
public static Permission permission = null;
public static WorldGuardPlugin worldGuard = null;
public static mcMMO mcmmo = null;
public static EpicBoss epicBoss = null;
public static Plugin rpgItems = null;
public static Heroes heroes = null;
public static PhatLoots phatLoots = null;
public static boolean snoop = true;
public static boolean npcEffects = true;
public static boolean broadcastPartyCreation = true;
@ -156,6 +165,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} catch (Exception e) {
printWarning("[Quests] Legacy version of Citizens found. Citizens in Quests not enabled.");
}
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard");
}
if (getServer().getPluginManager().getPlugin("Denizen") != null) {
denizen = (Denizen) getServer().getPluginManager().getPlugin("Denizen");
@ -180,6 +193,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (getServer().getPluginManager().getPlugin("RPG Items") != null) {
rpgItems = think.rpgitems.Plugin.plugin;
}
if (getServer().getPluginManager().getPlugin("PhatLoots") != null) {
phatLoots = (PhatLoots) getServer().getPluginManager().getPlugin("PhatLoots");
}
if (!setupEconomy()) {
printWarning("[Quests] Economy not found.");
@ -211,6 +228,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
lang.save();
if (new File(this.getDataFolder(), "quests.yml").exists() == false) {
printInfo("[Quests] Quest data not found, writing default to file.");
FileConfiguration data = new YamlConfiguration();
try {
@ -430,7 +448,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (player.hasPermission("quests.top")) {
player.sendMessage(YELLOW + "/quests top <number> - View top Questers");
}
player.sendMessage(GOLD + "/quests party - Quest Party commands");
//player.sendMessage(GOLD + "/quests party - Quest Party commands");
player.sendMessage(YELLOW + "/quests info - Display plugin information");
player.sendMessage(" ");
player.sendMessage(YELLOW + "/quest - Display current Quest objectives");
@ -824,6 +842,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else {
boolean takeable = true;
if (quester.completedQuests.contains(quest.name)) {
if (quester.getDifference(quest) > 0) {
@ -832,6 +851,27 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
}
if(quest.region != null){
boolean inRegion = false;
Player p = quester.getPlayer();
RegionManager rm = worldGuard.getRegionManager(p.getWorld());
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
while(it.hasNext()){
ProtectedRegion pr = it.next();
if(pr.getId().equalsIgnoreCase(quest.region)){
inRegion = true;
break;
}
}
if(inRegion == false){
cs.sendMessage(YELLOW + "You may not take " + AQUA + quest.name + YELLOW + " at this location.");
takeable = false;
}
}
if (takeable == true) {
@ -1350,7 +1390,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else {
Quest questToGive = null;
Quest questToGive;
String name = null;
@ -1791,6 +1831,31 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if(config.contains("quests." + s + ".region")){
String region = config.getString("quests." + s + ".region");
boolean exists = false;
for(World world : getServer().getWorlds()){
RegionManager rm = worldGuard.getRegionManager(world);
if(rm != null){
ProtectedRegion pr = rm.getRegionExact(region);
if(pr != null){
quest.region = region;
exists = true;
break;
}
}
}
if(!exists){
printSevere("[Quests] region: for Quest " + quest.name + " is not a valid WorldGuard region!");
continue;
}
}
if (config.contains("quests." + s + ".redo-delay")) {
if (config.getInt("quests." + s + ".redo-delay", -999) != -999) {
@ -3466,6 +3531,33 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
continue;
}
}
if (config.contains("quests." + s + ".rewards.phat-loots")) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.phat-loots"), String.class)) {
boolean failed = false;
for (String loot : config.getStringList("quests." + s + ".rewards.phat-loots")) {
if (PhatLootsAPI.getPhatLoot(loot) == null) {
printSevere("[Quests] " + loot + " in phat-loots: Reward in Quest " + quest.name + " is not a valid PhatLoot name!");
failed = true;
break;
}
}
if (failed) {
continue;
}
quest.phatLootRewards.clear();
quest.phatLootRewards.addAll(config.getStringList("quests." + s + ".rewards.phat-loots"));
} else {
printSevere("[Quests] phat-loots: Reward in Quest " + quest.name + " is not a list of PhatLoots!");
continue;
}
}
//
quests.add(quest);

View File

@ -44,7 +44,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
@SuppressWarnings("unchecked")
@Override
@Override
public String getPromptText(ConversationContext context) {
context.setSessionData(pref, Boolean.TRUE);
@ -1902,8 +1902,8 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + Lang.get("stageEditorNPCPrompt");
questFactory.selectingNPCs.add((Player) context.getForWhom());
return YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + GOLD + Lang.get("npcHint");
}
@Override
@ -1939,6 +1939,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
questFactory.selectingNPCs.remove((Player) context.getForWhom());
return new DeliveryListPrompt();
}

View File

@ -1,5 +1,7 @@
package me.blackvein.quests.prompts;
import com.codisimus.plugins.phatloots.PhatLoot;
import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import java.util.Arrays;
import java.util.Collections;
@ -29,7 +31,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil {
public RewardsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
quests = plugin;
factory = qf;
@ -158,7 +160,28 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil {
}
text += GREEN + "" + BOLD + "10" + RESET + YELLOW + " - Done";
if (Quests.phatLoots != null) {
if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) {
text += BLUE + "" + BOLD + "10" + RESET + YELLOW + " - Set PhatLoot rewards (None set)\n";
} else {
text += BLUE + "" + BOLD + "10" + RESET + YELLOW + " - Set PhatLoot rewards\n";
List<String> phatLoots = (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS);
for (String phatLoot : phatLoots) {
text += GRAY + " - " + AQUA + phatLoot + "\n";
}
}
} else {
text += GRAY + "10 - Set PhatLoot rewards (PhatLoots not installed)\n";
}
text += GREEN + "" + BOLD + "11" + RESET + YELLOW + " - Done";
return text;
@ -198,6 +221,12 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil {
return new RewardsPrompt(quests, factory);
}
} else if (input.equalsIgnoreCase("10")) {
if (Quests.phatLoots != null) {
return new PhatLootsPrompt();
} else {
return new RewardsPrompt(quests, factory);
}
} else if (input.equalsIgnoreCase("11")) {
return factory.returnToMenu();
}
return null;
@ -1026,4 +1055,56 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil {
}
}
private class PhatLootsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = DARKAQUA + "- " + AQUA + "PhatLoots" + DARKAQUA + " -\n";
for (PhatLoot pl : PhatLootsAPI.getAllPhatLoots()) {
text += GRAY + "- " + BLUE + pl.name + "\n";
}
text += YELLOW + "Enter PhatLoots separating each one by a space, or enter \"clear\" to clear the list, or \"cancel\" to return.";
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
String[] arr = input.split(" ");
LinkedList<String> loots = new LinkedList<String>();
for (String s : arr) {
if (PhatLootsAPI.getPhatLoot(s) == null) {
cc.getForWhom().sendRawMessage(DARKRED + s + RED + " is not a valid PhatLoot name!");
return new PhatLootsPrompt();
}
}
loots.addAll(Arrays.asList(arr));
cc.setSessionData(CK.REW_PHAT_LOOTS, loots);
return new RewardsPrompt(quests, factory);
} else if (input.equalsIgnoreCase("clear")) {
cc.setSessionData(CK.REW_PHAT_LOOTS, null);
cc.getForWhom().sendRawMessage(YELLOW + "PhatLoots reward cleared.");
return new RewardsPrompt(quests, factory);
} else {
return new RewardsPrompt(quests, factory);
}
}
}
}

View File

@ -15,6 +15,7 @@ public class CK {
public static final String Q_START_BLOCK= "blockStart";
public static final String Q_FAIL_MESSAGE = "failMessage";
public static final String Q_INITIAL_EVENT = "initialEvent";
public static final String Q_REGION = "region";
//Requirements
public static final String REQ_MONEY = "moneyReq";
@ -42,6 +43,7 @@ public class CK {
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
public static final String REW_HEROES_CLASSES = "heroesClassRews";
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
public static final String REW_PHAT_LOOTS = "phatLootRews";
//Stages
public static final String S_BREAK_IDS = "breakIds";
@ -80,12 +82,12 @@ public class CK {
public static final String S_SHEAR_COLORS = "shearColors";
public static final String S_SHEAR_AMOUNTS = "shearAmounts";
public static final String S_START_EVENT = "startEvent";
public static final String S_FINISH_EVENT = "finishEvent";
public static final String S_CHAT_EVENTS = "chatEvents";
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
public static final String S_DEATH_EVENT = "deathEvent";
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
public static final String S_FINISH_EVENT = "finishEvent";
public static final String S_CHAT_EVENTS = "chatEvents";
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
public static final String S_DEATH_EVENT = "deathEvent";
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
public static final String S_DELAY = "delay";
public static final String S_DELAY_MESSAGE = "delayMessage";
public static final String S_DENIZEN = "denizen";

View File

@ -1,6 +1,6 @@
name: Quests
main: me.blackvein.quests.Quests
version: 1.6.9
version: 1.7.0
description: Player questing system
website: http://dev.bukkit.org/server-mods/quests/
dev-url: https://github.com/Blackvein/Quests/