Added NPC Effects

This commit is contained in:
Blackvein 2013-04-12 18:25:19 -07:00
parent 42c348c9f6
commit 91e1fd840d
23 changed files with 535 additions and 440 deletions

22
.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

20
.gitignore vendored
View File

@ -1,3 +1,17 @@
/lib/Quests/build/
/lib/Quests/dist/
/lib/Quests/nbproject/private/
nbproject/
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
nbproject\project.properties
# Class Files #
*.class
# Package Files #
*.jar
*.war
*.ear

View File

@ -1,13 +1,13 @@
events:
ExampleEvent:
message: '<red>Event happened!'
potion-effect-types:
- Speed
- Jump
potion-effect-durations:
- 100
- 25
potion-effect-amplifiers:
- 3
- 2
events:
ExampleEvent:
message: '<red>Event happened!'
potion-effect-types:
- Speed
- Jump
potion-effect-durations:
- 100
- 25
potion-effect-amplifiers:
- 3
- 2

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

View File

@ -3,4 +3,4 @@ do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=/Users/136-aclarke/Library/Application Support/NetBeans/7.2.1/build.properties
user.properties.file=C:\\Users\\Alex\\AppData\\Roaming\\NetBeans\\7.2.1\\build.properties

View File

@ -27,9 +27,10 @@ dist.jar=${dist.dir}/Quests.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.craftbukkit-1.5.1-R0.1.jar=lib/craftbukkit-1.5.1-R0.1.jar
file.reference.denizen-0.8.8-PRERELEASE.jar=lib\\denizen-0.8.8-PRERELEASE.jar
file.reference.mcMMO.jar=lib\\mcMMO.jar
file.reference.ProtocolLib-2.4.1.jar=lib/ProtocolLib-2.4.1.jar
file.reference.mysql-connector-java-5.1.24-bin.jar=C:\\Users\\Alex\\Documents\\Coding\\libraries\\mysql-connector-java-5.1.24-bin.jar
file.reference.Vault.jar=lib/Vault.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
@ -41,7 +42,8 @@ javac.classpath=\
${libs.CitizensAPI.classpath}:\
${file.reference.mcMMO.jar}:\
${file.reference.denizen-0.8.8-PRERELEASE.jar}:\
${file.reference.ProtocolLib-2.4.1.jar}
${file.reference.mysql-connector-java-5.1.24-bin.jar}:\
${file.reference.craftbukkit-1.5.1-R0.1.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

192
pom.xml
View File

@ -1,97 +1,97 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.5.2-SNAPSHOT</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>
<description></description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>citizensapi-repo</id>
<url>http://ci.citizensnpcs.com/plugin/repository/everything</url>
</repository>
<repository>
<id>denizens-repo</id>
<url>http://ci.citizensnpcs.com/view/Characters/job/Denizen/592/maven-repository/repository/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.4.2-R0.2</version>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.aufdemrand</groupId>
<artifactId>denizen</artifactId>
<version>0.76-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.22-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.11</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>config.yml</include>
<include>plugin.yml</include>
<include>events.yml</include>
<include>quests.yml</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.5.2-SNAPSHOT</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>
<description></description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>citizensapi-repo</id>
<url>http://ci.citizensnpcs.com/plugin/repository/everything</url>
</repository>
<repository>
<id>denizens-repo</id>
<url>http://ci.citizensnpcs.com/view/Characters/job/Denizen/592/maven-repository/repository/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.4.2-R0.2</version>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.aufdemrand</groupId>
<artifactId>denizen</artifactId>
<version>0.76-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.22-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.11</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>config.yml</include>
<include>plugin.yml</include>
<include>events.yml</include>
<include>quests.yml</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
</project>

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -25,6 +25,8 @@ allow-quitting: true
debug-mode: false
kill-delay: 600
snoop: true
show-npc-effects: true
npc-effect: "note"
quester-blacklist:
- "SomeGuy12345"
- "somePrefix*"

View File

@ -1,13 +1,13 @@
events:
ExampleEvent:
message: '<red>Event happened!'
potion-effect-types:
- Speed
- Jump
potion-effect-durations:
- 100
- 25
potion-effect-amplifiers:
- 3
- 2
events:
ExampleEvent:
message: '<red>Event happened!'
potion-effect-types:
- Speed
- Jump
potion-effect-durations:
- 100
- 25
potion-effect-amplifiers:
- 3
- 2

View File

@ -126,15 +126,15 @@ public class Event {
}
public String getName(){
return name;
}
public void happen(Quester quester){
Player player = quester.getPlayer();
if(message != null)
player.sendMessage(Quests.parseString(message, quester.currentQuest));

View File

@ -0,0 +1,160 @@
package me.blackvein.quests;
import java.util.List;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class NpcEffectThread implements Runnable{
final Quests plugin;
public NpcEffectThread(Quests quests){
plugin = quests;
}
@Override
public void run(){
for(Player player : plugin.getServer().getOnlinePlayers()){
Quester quester = plugin.getQuester(player.getName());
List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0);
if(nearby.isEmpty() == false){
for(Entity e : nearby){
if(plugin.citizens.getNPCRegistry().isNPC(e)){
NPC npc = plugin.citizens.getNPCRegistry().getNPC(e);
if(plugin.hasQuest(npc, quester))
showEffect(player, npc);
}
}
}
}
}
private static void showEffect(Player player, NPC npc){
if(Quests.effect.equalsIgnoreCase("enchant")){
try{
ParticleEffect.ENCHANTMENT_TABLE.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 1, 0, 1, 10);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("crit")){
try{
ParticleEffect.CRIT.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, (float)0.35, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("spell")){
try{
ParticleEffect.INSTANT_SPELL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("magiccrit")){
try{
ParticleEffect.MAGIC_CRIT.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, (float)0.35, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("mobspell")){
try{
ParticleEffect.MOB_SPELL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("note")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
ParticleEffect.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("portal")){
try{
ParticleEffect.PORTAL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 5);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("dust")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
ParticleEffect.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("witch")){
try{
ParticleEffect.WITCH_MAGIC.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("snowball")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
ParticleEffect.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("splash")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
ParticleEffect.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("smoke")){
try{
ParticleEffect.TOWN_AURA.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 1, 0, 1, 20);
}catch(Exception e){
e.printStackTrace();
}
} else{
Quests.log.severe("[Quests] No particle effect specified!");
}
}
}

View File

@ -16,7 +16,7 @@ import org.bukkit.inventory.ItemStack;
public class NpcListener implements Listener {
Quests plugin;
final Quests plugin;
public NpcListener(Quests newPlugin) {
@ -31,15 +31,15 @@ public class NpcListener implements Listener {
final Quester quester = plugin.getQuester(player.getName());
boolean delivery = false;
if (quester.hasObjective("deliverItem") && player.getItemInHand() != null) {
if(quester.hasObjective("deliverItem") && player.getItemInHand() != null){
ItemStack hand = player.getItemInHand();
if (quester.itemsDelivered.containsKey(hand.getType())) {
if(quester.itemsDelivered.containsKey(hand.getType())){
NPC clicked = evt.getNPC();
for (NPC n : quester.currentStage.itemDeliveryTargets) {
if (n.getId() == clicked.getId()) {
for(NPC n : quester.currentStage.itemDeliveryTargets){
if(n.getId() == clicked.getId()){
quester.deliverItem(hand);
delivery = true;
break;
@ -92,13 +92,13 @@ public class NpcListener implements Listener {
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.completedQuests.contains(q.name) && q.redoDelay < 0) {
player.sendMessage(ChatColor.YELLOW + "You have already completed " + ChatColor.AQUA + q.name + ChatColor.YELLOW + ".");
} else {
}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";
ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n"
+ "\n"
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
player.sendMessage(s);
@ -130,47 +130,63 @@ public class NpcListener implements Listener {
@EventHandler
public void onNPCDeath(NPCDeathEvent evt) {
if (evt.getNPC().getBukkitEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
if (evt.getNPC().getBukkitEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getNPC().getBukkitEntity().getLastDamageCause();
Entity damager = damageEvent.getDamager();
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getNPC().getBukkitEntity().getLastDamageCause();
Entity damager = damageEvent.getDamager();
if (damager != null) {
if (damager != null) {
if (damager instanceof Projectile) {
if (damager instanceof Projectile) {
Projectile p = (Projectile) damager;
if (p.getShooter() instanceof Player) {
Projectile p = (Projectile) damager;
if (p.getShooter() instanceof Player) {
Player player = (Player) p.getShooter();
if (plugin.checkQuester(player.getName()) == false) {
Player player = (Player) p.getShooter();
boolean okay = true;
if (plugin.citizens != null) {
if (plugin.citizens.getNPCRegistry().isNPC(player)) {
okay = false;
}
}
if (okay) {
Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("killNPC")) {
quester.killNPC(evt.getNPC());
}
}
}
} else if (damager instanceof Player) {
boolean okay = true;
if (plugin.citizens != null) {
if (plugin.citizens.getNPCRegistry().isNPC(damager)) {
okay = false;
}
}
if (okay) {
Player player = (Player) damager;
Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("killNPC")) {
quester.killNPC(evt.getNPC());
}
}
}
} else if (damager instanceof Player) {
Player player = (Player) damager;
if (plugin.checkQuester(player.getName()) == false) {
Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("killNPC")) {
quester.killNPC(evt.getNPC());
}
}
}
}
}
}
}

View File

@ -0,0 +1,66 @@
package me.blackvein.quests;
import net.minecraft.server.v1_5_R2.Packet63WorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public enum ParticleEffect {
HUGE_EXPLOSION("hugeexplosion"),
LARGE_EXPLODE("largeexplode"),
FIREWORKS_SPARK("fireworksSpark"),
BUBBLE("bubble"),
SUSPEND("suspend"),
DEPTH_SUSPEND("depthSuspend"),
TOWN_AURA("townaura"),
CRIT("crit"),
MAGIC_CRIT("magicCrit"),
MOB_SPELL("mobSpell"),
MOB_SPELL_AMBIENT("mobSpellAmbient"),
SPELL("spell"),
INSTANT_SPELL("instantSpell"),
WITCH_MAGIC("witchMagic"),
NOTE("note"),
PORTAL("portal"),
ENCHANTMENT_TABLE("enchantmenttable"),
EXPLODE("explode"),
FLAME("flame"),
LAVA("lava"),
FOOTSTEP("footstep"),
SPLASH("splash"),
LARGE_SMOKE("largesmoke"),
CLOUD("cloud"),
RED_DUST("reddust"),
SNOWBALL_POOF("snowballpoof"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
SNOW_SHOVEL("snowshovel"),
SLIME("slime"),
HEART("heart"),
ANGRY_VILLAGER("angryVillager"),
HAPPY_VILLAGER("happerVillager"),
ICONCRACK("iconcrack_"),
TILECRACK("tilecrack_");
private String particleName;
ParticleEffect(String particleName) {
this.particleName = particleName;
}
public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception {
Packet63WorldParticles packet = new Packet63WorldParticles();
ReflectionUtilities.setValue(packet, "a", particleName);
ReflectionUtilities.setValue(packet, "b", (float) location.getX());
ReflectionUtilities.setValue(packet, "c", (float) location.getY());
ReflectionUtilities.setValue(packet, "d", (float) location.getZ());
ReflectionUtilities.setValue(packet, "e", offsetX);
ReflectionUtilities.setValue(packet, "f", offsetY);
ReflectionUtilities.setValue(packet, "g", offsetZ);
ReflectionUtilities.setValue(packet, "h", speed);
ReflectionUtilities.setValue(packet, "i", count);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -2,6 +2,7 @@ package me.blackvein.quests;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -25,7 +26,7 @@ import org.bukkit.event.player.PlayerFishEvent.State;
public class PlayerListener implements Listener {
Quests plugin;
final Quests plugin;
public PlayerListener(Quests newPlugin) {
@ -450,6 +451,7 @@ public class PlayerListener implements Listener {
if (p.getShooter() instanceof Player) {
Player player = (Player) p.getShooter();
if (plugin.checkQuester(player.getName()) == false) {
boolean okay = true;

View File

@ -393,14 +393,14 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter NPC ID, or 0 to clear the NPC start, or -1 to cancel";
return ChatColor.YELLOW + "Enter NPC ID, or -1 to clear the NPC start, or -2 to cancel";
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() > 0) {
if (input.intValue() > -1) {
if (quests.citizens.getNPCRegistry().getById(input.intValue()) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + "No NPC exists with that id!");
@ -410,10 +410,10 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData("npcStart", input.intValue());
return new CreateMenuPrompt();
} else if (input.intValue() == 0) {
} else if (input.intValue() == -1) {
context.setSessionData("npcStart", null);
return new CreateMenuPrompt();
} else if (input.intValue() == -1) {
} else if (input.intValue() == -2) {
return new CreateMenuPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + "No NPC exists with that id!");
@ -853,9 +853,6 @@ public class QuestFactory implements ConversationAbandonedListener {
LinkedList<String> shearColors;
LinkedList<Integer> shearAmounts;
LinkedList<Integer> npcKillIds;
LinkedList<Integer> npcKillAmounts;
String script;
String event;
@ -911,9 +908,6 @@ public class QuestFactory implements ConversationAbandonedListener {
shearColors = null;
shearAmounts = null;
npcKillIds = null;
npcKillAmounts = null;
script = null;
event = null;
@ -991,11 +985,6 @@ public class QuestFactory implements ConversationAbandonedListener {
shearColors = (LinkedList<String>) cc.getSessionData(pref + "shearColors");
shearAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "shearAmounts");
}
if (cc.getSessionData(pref + "npcIdsToKill") != null) {
npcKillIds = (LinkedList<Integer>) cc.getSessionData(pref + "npcIdsToKill");
npcKillAmounts = (LinkedList<Integer>) cc.getSessionData(pref + "npcAmountsToKill");
}
if (cc.getSessionData(pref + "event") != null) {
event = (String) cc.getSessionData(pref + "event");
@ -1042,8 +1031,6 @@ public class QuestFactory implements ConversationAbandonedListener {
stage.set("mob-tame-amounts", tameAmounts);
stage.set("sheep-to-shear", shearColors);
stage.set("sheep-amounts", shearAmounts);
stage.set("npc-ids-to-kill", npcKillIds);
stage.set("npc-kill-amounts", npcKillAmounts);
stage.set("script-to-run", script);
stage.set("event", event);
stage.set("delay", delay);

View File

@ -363,7 +363,7 @@ public class Quester {
if (((Boolean) e.getValue()) == false) {
unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getName());
unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getFullName());
} else {
@ -383,11 +383,11 @@ public class Quester {
if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
} else {
finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
}

View File

@ -41,6 +41,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public static Permission permission = null;
public static mcMMO mcmmo = null;
public static boolean snoop = true;
public static boolean npcEffects = true;
public static String effect = "note";
List<String> questerBlacklist = new LinkedList<String>();
ConversationFactory conversationFactory;
QuestFactory questFactory;
@ -48,6 +50,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
Vault vault = null;
public CitizensPlugin citizens;
PlayerListener pListener;
NpcEffectThread effListener;
NpcListener npcListener;
public Denizen denizen = null;
QuestTaskTrigger trigger;
@ -69,6 +72,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void onEnable() {
pListener = new PlayerListener(this);
effListener = new NpcEffectThread(this);
npcListener = new NpcListener(this);
this.conversationFactory = new ConversationFactory(this)
@ -154,6 +158,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
getServer().getPluginManager().registerEvents(pListener, this);
if(npcEffects)
getServer().getScheduler().scheduleSyncRepeatingTask(this, effListener, 20, 20);
printInfo("[Quests] Enabled.");
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@ -233,7 +239,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
@Override
public String getPrefix(ConversationContext context) {
return ChatColor.GREEN + "Quests: " + ChatColor.GRAY;
return "" + ChatColor.GRAY;
}
}
@ -247,14 +253,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
showQuestReqs = config.getBoolean("show-requirements");
allowQuitting = config.getBoolean("allow-quitting");
snoop = config.getBoolean("snoop", true);
npcEffects = config.getBoolean("show-npc-effects", true);
effect = config.getString("npc-effect", "note");
debug = config.getBoolean("debug-mode");
killDelay = config.getInt("kill-delay");
for (String s : config.getStringList("quester-blacklist")) {
for (String s : config.getStringList("quester-blacklist"))
questerBlacklist.add(s);
}
}
public void printHelp(Player player) {
@ -3906,4 +3911,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
public boolean hasQuest(NPC npc, Quester quester){
for(Quest quest : quests){
if(quest.npcStart != null && quester.completedQuests.contains(quest.name) == false){
if(quest.npcStart.getId() == npc.getId())
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,19 @@
package me.blackvein.quests;
import java.lang.reflect.Field;
public class ReflectionUtilities {
public static void setValue(Object instance, String fieldName, Object value) throws Exception {
Field field = instance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(instance, value);
}
public static Object getValue(Object instance, String fieldName) throws Exception {
Field field = instance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(instance);
}
}

View File

@ -0,0 +1,12 @@
enchant
crit
spell
magiccrit
mobspell
note
portal
dust
witch
snowball
splash
smoke

View File

@ -46,7 +46,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
public CreateStagePrompt(int stageNum, QuestFactory qf, CitizensPlugin cit) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20");
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.citizens = cit;
@ -278,63 +278,43 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
}
if(questFactory.quests.citizens != null){
if (context.getSessionData(pref + "npcIdsToKill") == null) {
text += PINK + "" + BOLD + "15 " + RESET + PURPLE + "- Kill NPCs " + GRAY + "(None set)\n";
} else {
text += PINK + "" + BOLD + "15 " + RESET + PURPLE + "- Kill NPCs\n";
LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + "npcIdsToKill");
LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + "npcAmountsToKill");
for (int i = 0; i < npcs.size(); i++) {
text += GRAY + " - " + BLUE + citizens.getNPCRegistry().getById(npcs.get(i)).getName() + GRAY + " x " + AQUA + amounts.get(i) + "\n";
}
}
}else{
text += GRAY + "" + BOLD + "15 " + RESET + GRAY + "- Kill NPCs " + GRAY + "(Citizens not installed)\n";
}
if (context.getSessionData(pref + "event") == null) {
text += PINK + "" + BOLD + "16 " + RESET + PURPLE + "- Event " + GRAY + "(None set)\n";
text += PINK + "" + BOLD + "15 " + RESET + PURPLE + "- Event " + GRAY + "(None set)\n";
} else {
text += PINK + "" + BOLD + "16 " + RESET + PURPLE + "- Event " + GRAY + "(" + AQUA + context.getSessionData(pref + "event") + GRAY + ")\n";
text += PINK + "" + BOLD + "15 " + RESET + PURPLE + "- Event " + GRAY + "(" + AQUA + context.getSessionData(pref + "event") + GRAY + ")\n";
}
if (context.getSessionData(pref + "delay") == null) {
text += PINK + "" + BOLD + "17 " + RESET + PURPLE + "- Delay " + GRAY + "(None set)\n";
text += PINK + "" + BOLD + "16 " + RESET + PURPLE + "- Delay " + GRAY + "(None set)\n";
} else {
long time = (Long) context.getSessionData(pref + "delay");
text += PINK + "" + BOLD + "17 " + RESET + PURPLE + "- Delay " + GRAY + "(" + AQUA + Quests.getTime(time) + GRAY + ")\n";
text += PINK + "" + BOLD + "16 " + RESET + PURPLE + "- Delay " + GRAY + "(" + AQUA + Quests.getTime(time) + GRAY + ")\n";
}
if(context.getSessionData(pref + "delay") == null){
text += GRAY + "" + BOLD + "18 " + RESET + GRAY + "- Delay Message " + GRAY + "(No delay set)\n";
text += GRAY + "" + BOLD + "17 " + RESET + GRAY + "- Delay Message " + GRAY + "(No delay set)\n";
}else if(context.getSessionData(pref + "delayMessage") == null){
text += PINK + "" + BOLD + "18 " + RESET + PURPLE + "- Delay Message " + GRAY + "(None set)\n";
text += PINK + "" + BOLD + "17 " + RESET + PURPLE + "- Delay Message " + GRAY + "(None set)\n";
}else{
text += PINK + "" + BOLD + "18 " + RESET + PURPLE + "- Delay Message " + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + "delayMessage") + "\"" + GRAY + ")\n";
text += PINK + "" + BOLD + "17 " + RESET + PURPLE + "- Delay Message " + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + "delayMessage") + "\"" + GRAY + ")\n";
}
if(questFactory.quests.denizen == null){
text += GRAY + "" + BOLD + "19 " + RESET + GRAY + "- Denizen Script " + GRAY + "(Denizen not installed)\n";
text += GRAY + "" + BOLD + "18 " + RESET + GRAY + "- Denizen Script " + GRAY + "(Denizen not installed)\n";
}else{
if(context.getSessionData(pref + "denizen") == null){
text += GRAY + "" + BOLD + "19 " + RESET + PURPLE + "- Denizen Script " + GRAY + "(None set)\n";
text += GRAY + "" + BOLD + "18 " + RESET + PURPLE + "- Denizen Script " + GRAY + "(None set)\n";
}else{
text += PINK + "" + BOLD + "19 " + RESET + PURPLE + "- Denizen Script " + GRAY + "(" + AQUA + context.getSessionData(pref + "denizen") + GRAY + "\n";
text += PINK + "" + BOLD + "18 " + RESET + PURPLE + "- Denizen Script " + GRAY + "(" + AQUA + context.getSessionData(pref + "denizen") + GRAY + "\n";
}
}
text += RED + "" + BOLD + "20 " + RESET + PURPLE + "- Delete Stage\n";
text += GREEN + "" + BOLD + "21 " + RESET + PURPLE + "- Done\n";
text += RED + "" + BOLD + "19 " + RESET + PURPLE + "- Delete Stage\n";
text += GREEN + "" + BOLD + "20 " + RESET + PURPLE + "- Done\n";
return text;
@ -382,31 +362,24 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase("14")) {
return new ShearListPrompt();
} else if (input.equalsIgnoreCase("15")) {
if(questFactory.quests.citizens != null)
return new NPCKillListPrompt();
else{
context.getForWhom().sendRawMessage(RED + "Citizens is not installed!");
return new CreateStagePrompt(stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("16")) {
return new EventPrompt();
} else if (input.equalsIgnoreCase("17")) {
} else if (input.equalsIgnoreCase("16")) {
return new DelayPrompt();
} else if (input.equalsIgnoreCase("18")) {
} else if (input.equalsIgnoreCase("17")) {
if(context.getSessionData(pref + "delay") == null){
context.getForWhom().sendRawMessage(RED + "You must set a delay first!");
return new CreateStagePrompt(stageNum, questFactory, citizens);
}else
return new DelayMessagePrompt();
} else if (input.equalsIgnoreCase("19")) {
} else if (input.equalsIgnoreCase("18")) {
if(questFactory.quests.denizen == null){
context.getForWhom().sendRawMessage(RED + "Denizen is not installed!");
return new CreateStagePrompt(stageNum, questFactory, citizens);
}else
return new DenizenPrompt();
} else if (input.equalsIgnoreCase("20")) {
} else if (input.equalsIgnoreCase("19")) {
return new DeletePrompt();
} else if (input.equalsIgnoreCase("21")) {
} else if (input.equalsIgnoreCase("20")) {
return new StagesPrompt(questFactory);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -3468,196 +3441,4 @@ public class CreateStagePrompt extends FixedSetPrompt {
}
}
private class NPCKillListPrompt extends FixedSetPrompt {
public NPCKillListPrompt() {
super("1", "2", "3", "4", "5", "6");
}
@Override
public String getPromptText(ConversationContext context) {
String text = GOLD + "- Kill NPCs -\n";
if (context.getSessionData(pref + "npcIdsToKill") == null) {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set NPC IDs (None set)\n";
text += GRAY + "2 - Set kill amounts (No NPC IDs set)\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done";
} else {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set NPC IDs\n";
for (int i : getNPCIds(context)) {
text += GRAY + " - " + AQUA + citizens.getNPCRegistry().getById(i).getName() + " (" + i + ")\n";
}
if (context.getSessionData(pref + "npcAmountsToKill") == null) {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set kill amounts (None set)\n";
} else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set kill amounts\n";
for (Integer i : getKillAmounts(context)) {
text += GRAY + " - " + AQUA + i + "\n";
}
}
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new NPCIDsToKillPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(pref + "npcIdsToKill") == null) {
context.getForWhom().sendRawMessage(RED + "You must set NPC ids first!");
return new NPCKillListPrompt();
} else {
return new NPCAmountsToKillPrompt();
}
} else if (input.equalsIgnoreCase("3")) {
context.getForWhom().sendRawMessage(YELLOW + "Kill NPCs objective cleared.");
context.setSessionData(pref + "npcIdsToKill", null);
context.setSessionData(pref + "npcAmountsToKill", null);
return new NPCKillListPrompt();
} else if (input.equalsIgnoreCase("4")) {
int one;
int two;
if (context.getSessionData(pref + "npcIdsToKill") != null) {
one = ((List<Integer>) context.getSessionData(pref + "npcIdsToKill")).size();
} else {
one = 0;
}
if (context.getSessionData(pref + "npcAmountsToKill") != null) {
two = ((List<Integer>) context.getSessionData(pref + "npcAmountsToKill")).size();
} else {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(RED + "The list sizes are not equal!");
return new NPCKillListPrompt();
}
}
return null;
}
private List<Integer> getNPCIds(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + "npcIdsToKill");
}
private List<Integer> getKillAmounts(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + "npcAmountsToKill");
}
}
private class NPCIDsToKillPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + "Enter NPC IDs, separating each one by a space, or enter \'cancel\' to return.";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) {
String[] args = input.split(" ");
LinkedList<Integer> npcs = new LinkedList<Integer>();
for (String s : args) {
try {
Integer i = Integer.parseInt(s);
if (citizens.getNPCRegistry().getById(i) != null) {
npcs.add(i);
} else {
context.getForWhom().sendRawMessage(PINK + "" + i + RED + " is not a valid NPC ID!");
return new NPCIDsToKillPrompt();
}
} catch (Exception e) {
context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!");
return new NPCIDsToKillPrompt();
}
}
context.setSessionData(pref + "npcIdsToKill", npcs);
}
return new NPCKillListPrompt();
}
}
private class NPCAmountsToKillPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + "Enter kill amounts, separating each one by a space, or enter \'cancel\' to return.";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) {
String[] args = input.split(" ");
LinkedList<Integer> amounts = new LinkedList<Integer>();
for (String s : args) {
try {
Integer i = Integer.parseInt(s);
amounts.add(i);
} catch (Exception e) {
context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!");
return new NPCAmountsToKillPrompt();
}
}
context.setSessionData(pref + "npcAmountsToKill", amounts);
}
return new NPCKillListPrompt();
}
}
}

View File

@ -165,9 +165,6 @@ public class StagesPrompt extends StringPrompt{
cc.setSessionData(newPref + "shearColors", cc.getSessionData(pref + "shearColors"));
cc.setSessionData(newPref + "shearAmounts", cc.getSessionData(pref + "shearAmounts"));
cc.setSessionData(newPref + "npcIdsToKill", cc.getSessionData(pref + "npcIdsToKill"));
cc.setSessionData(newPref + "npcAmountsToKill", cc.getSessionData(pref + "npcAmountsToKill"));
cc.setSessionData(newPref + "event", cc.getSessionData(pref + "event"));
@ -224,9 +221,6 @@ public class StagesPrompt extends StringPrompt{
cc.setSessionData(pref + "shearColors", null);
cc.setSessionData(pref + "shearAmounts", null);
cc.setSessionData(pref + "npcIdsToKill", null);
cc.setSessionData(pref + "npcAmountsToKill", null);
cc.setSessionData(pref + "event", null);

View File

@ -44,9 +44,6 @@ stage#tameAmounts
stage#shearColors
stage#shearAmounts
stage#npcIdsToKill
stage#npcAmountsToKill
stage#event
stage#delay