From 91e1fd840d5492917da801e7005be8d19fa05df0 Mon Sep 17 00:00:00 2001 From: Blackvein Date: Fri, 12 Apr 2013 18:25:19 -0700 Subject: [PATCH] Added NPC Effects --- .gitattributes | 22 ++ .gitignore | 20 +- build/classes/events.yml | 26 +- manifest.mf | 6 +- nbproject/private/private.properties | 2 +- nbproject/project.properties | 6 +- pom.xml | 192 ++++++------- src/.DS_Store | Bin 0 -> 6148 bytes src/config.yml | 2 + src/events.yml | 26 +- src/me/blackvein/quests/Event.java | 8 +- src/me/blackvein/quests/NpcEffectThread.java | 160 +++++++++++ src/me/blackvein/quests/NpcListener.java | 82 +++--- src/me/blackvein/quests/ParticleEffect.java | 66 +++++ src/me/blackvein/quests/PlayerListener.java | 4 +- src/me/blackvein/quests/QuestFactory.java | 21 +- src/me/blackvein/quests/Quester.java | 6 +- src/me/blackvein/quests/Quests.java | 31 ++- .../blackvein/quests/ReflectionUtilities.java | 19 ++ src/me/blackvein/quests/particles | 12 + .../quests/prompts/CreateStagePrompt.java | 255 ++---------------- .../quests/prompts/StagesPrompt.java | 6 - src/me/blackvein/quests/stageDataNames.txt | 3 - 23 files changed, 535 insertions(+), 440 deletions(-) create mode 100644 .gitattributes create mode 100644 src/.DS_Store create mode 100644 src/me/blackvein/quests/NpcEffectThread.java create mode 100644 src/me/blackvein/quests/ParticleEffect.java create mode 100644 src/me/blackvein/quests/ReflectionUtilities.java create mode 100644 src/me/blackvein/quests/particles diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..412eeda78 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore index 8c019194a..346031c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,17 @@ -/lib/Quests/build/ -/lib/Quests/dist/ -/lib/Quests/nbproject/private/ \ No newline at end of file +nbproject/ +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml +nbproject\project.properties + +# Class Files # +*.class + +# Package Files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/build/classes/events.yml b/build/classes/events.yml index 4053f9f51..e7b554ba7 100644 --- a/build/classes/events.yml +++ b/build/classes/events.yml @@ -1,13 +1,13 @@ -events: - ExampleEvent: - message: 'Event happened!' - potion-effect-types: - - Speed - - Jump - potion-effect-durations: - - 100 - - 25 - potion-effect-amplifiers: - - 3 - - 2 - +events: + ExampleEvent: + message: 'Event happened!' + potion-effect-types: + - Speed + - Jump + potion-effect-durations: + - 100 + - 25 + potion-effect-amplifiers: + - 3 + - 2 + diff --git a/manifest.mf b/manifest.mf index 1574df4a2..328e8e5bc 100755 --- a/manifest.mf +++ b/manifest.mf @@ -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 + diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index dae6e0247..cb35e40eb 100755 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -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 diff --git a/nbproject/project.properties b/nbproject/project.properties index 41997e4e0..d39fde3ad 100755 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -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 diff --git a/pom.xml b/pom.xml index 2bbdbf77e..ad97515e1 100644 --- a/pom.xml +++ b/pom.xml @@ -1,97 +1,97 @@ - - 4.0.0 - - me.blackvein.quests - quests - 1.5.2-SNAPSHOT - quests - http://dev.bukkit.org/server-mods/quests/ - jar - - - - UTF-8 - - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public - - - citizensapi-repo - http://ci.citizensnpcs.com/plugin/repository/everything - - - denizens-repo - http://ci.citizensnpcs.com/view/Characters/job/Denizen/592/maven-repository/repository/ - - - vault-repo - http://ci.herocraftonline.com/plugin/repository/everything - - - - - - org.bukkit - bukkit - 1.4.2-R0.2 - - - net.citizensnpcs - citizensapi - 2.0.4-SNAPSHOT - - - net.aufdemrand - denizen - 0.76-SNAPSHOT - - - net.milkbowl.vault - Vault - 1.2.22-SNAPSHOT - - - com.gmail.nossr50.mcMMO - mcMMO - 1.3.11 - - - - - - - . - ${basedir}/src/main/resources/ - true - - config.yml - plugin.yml - events.yml - quests.yml - - - - . - ${basedir}/ - false - - README.md - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - true - - - - + + 4.0.0 + + me.blackvein.quests + quests + 1.5.2-SNAPSHOT + quests + http://dev.bukkit.org/server-mods/quests/ + jar + + + + UTF-8 + + + + + bukkit-repo + http://repo.bukkit.org/content/groups/public + + + citizensapi-repo + http://ci.citizensnpcs.com/plugin/repository/everything + + + denizens-repo + http://ci.citizensnpcs.com/view/Characters/job/Denizen/592/maven-repository/repository/ + + + vault-repo + http://ci.herocraftonline.com/plugin/repository/everything + + + + + + org.bukkit + bukkit + 1.4.2-R0.2 + + + net.citizensnpcs + citizensapi + 2.0.4-SNAPSHOT + + + net.aufdemrand + denizen + 0.76-SNAPSHOT + + + net.milkbowl.vault + Vault + 1.2.22-SNAPSHOT + + + com.gmail.nossr50.mcMMO + mcMMO + 1.3.11 + + + + + + + . + ${basedir}/src/main/resources/ + true + + config.yml + plugin.yml + events.yml + quests.yml + + + + . + ${basedir}/ + false + + README.md + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + true + + + + \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..88774d4dc02cec2f6aea74c6e2061a4bb6a77225 GIT binary patch literal 6148 zcmeHKOG*Pl5PcORgt*DlWiMR`-e3q(aH|)P#8CocM$riF<`^Ez19%&K)m4$qWZa5q z6;!|K?s`4l52il=WV*gS0VV)ObVbpi$F#Y(Yv9TIM9E_;af@TT;0{&KK)) zHCDL6*8I<_dNHr+Ir~+dGy2g-Hb%-R@l0Rg36GmKcQ|hy&VagNU8yy%%8482~p}>~{x<4ek zV&T{r=B~+FpM%32nE^->{)f9=l>~xnchc!n-aB9AQbpx3dnGFIh%4(ezxu`PtV#! uzoM&YUZVkxaqAMmitZzaxzqZS#>^`m8$%sM+cTXQ7lABD6rsQmDDVj=Nl%dg literal 0 HcmV?d00001 diff --git a/src/config.yml b/src/config.yml index 9827eaa11..bb74cac8e 100644 --- a/src/config.yml +++ b/src/config.yml @@ -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*" diff --git a/src/events.yml b/src/events.yml index 4053f9f51..e7b554ba7 100644 --- a/src/events.yml +++ b/src/events.yml @@ -1,13 +1,13 @@ -events: - ExampleEvent: - message: 'Event happened!' - potion-effect-types: - - Speed - - Jump - potion-effect-durations: - - 100 - - 25 - potion-effect-amplifiers: - - 3 - - 2 - +events: + ExampleEvent: + message: 'Event happened!' + potion-effect-types: + - Speed + - Jump + potion-effect-durations: + - 100 + - 25 + potion-effect-amplifiers: + - 3 + - 2 + diff --git a/src/me/blackvein/quests/Event.java b/src/me/blackvein/quests/Event.java index d54b22988..703a35e76 100644 --- a/src/me/blackvein/quests/Event.java +++ b/src/me/blackvein/quests/Event.java @@ -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)); diff --git a/src/me/blackvein/quests/NpcEffectThread.java b/src/me/blackvein/quests/NpcEffectThread.java new file mode 100644 index 000000000..714387dea --- /dev/null +++ b/src/me/blackvein/quests/NpcEffectThread.java @@ -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 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!"); + + } + + } + +} diff --git a/src/me/blackvein/quests/NpcListener.java b/src/me/blackvein/quests/NpcListener.java index 4e7c67ec2..3e0ebb841 100644 --- a/src/me/blackvein/quests/NpcListener.java +++ b/src/me/blackvein/quests/NpcListener.java @@ -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()); - } - - } } } - } - } + + } diff --git a/src/me/blackvein/quests/ParticleEffect.java b/src/me/blackvein/quests/ParticleEffect.java new file mode 100644 index 000000000..7dee5f25a --- /dev/null +++ b/src/me/blackvein/quests/ParticleEffect.java @@ -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); + } + +} diff --git a/src/me/blackvein/quests/PlayerListener.java b/src/me/blackvein/quests/PlayerListener.java index 3934658b1..46418aff0 100644 --- a/src/me/blackvein/quests/PlayerListener.java +++ b/src/me/blackvein/quests/PlayerListener.java @@ -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; diff --git a/src/me/blackvein/quests/QuestFactory.java b/src/me/blackvein/quests/QuestFactory.java index 208e51b4e..8c32fe069 100644 --- a/src/me/blackvein/quests/QuestFactory.java +++ b/src/me/blackvein/quests/QuestFactory.java @@ -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 shearColors; LinkedList shearAmounts; - - LinkedList npcKillIds; - LinkedList 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) cc.getSessionData(pref + "shearColors"); shearAmounts = (LinkedList) cc.getSessionData(pref + "shearAmounts"); } - - if (cc.getSessionData(pref + "npcIdsToKill") != null) { - npcKillIds = (LinkedList) cc.getSessionData(pref + "npcIdsToKill"); - npcKillAmounts = (LinkedList) 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); diff --git a/src/me/blackvein/quests/Quester.java b/src/me/blackvein/quests/Quester.java index 58fab7311..dbf682c62 100644 --- a/src/me/blackvein/quests/Quester.java +++ b/src/me/blackvein/quests/Quester.java @@ -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))); } diff --git a/src/me/blackvein/quests/Quests.java b/src/me/blackvein/quests/Quests.java index 15bf6080b..9eb127a7f 100644 --- a/src/me/blackvein/quests/Quests.java +++ b/src/me/blackvein/quests/Quests.java @@ -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 questerBlacklist = new LinkedList(); 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; + } } diff --git a/src/me/blackvein/quests/ReflectionUtilities.java b/src/me/blackvein/quests/ReflectionUtilities.java new file mode 100644 index 000000000..492e1c37a --- /dev/null +++ b/src/me/blackvein/quests/ReflectionUtilities.java @@ -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); + } + +} diff --git a/src/me/blackvein/quests/particles b/src/me/blackvein/quests/particles new file mode 100644 index 000000000..e866a85e5 --- /dev/null +++ b/src/me/blackvein/quests/particles @@ -0,0 +1,12 @@ +enchant +crit +spell +magiccrit +mobspell +note +portal +dust +witch +snowball +splash +smoke \ No newline at end of file diff --git a/src/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/me/blackvein/quests/prompts/CreateStagePrompt.java index 5df3f5b60..8fa38929b 100644 --- a/src/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -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 npcs = (LinkedList) context.getSessionData(pref + "npcIdsToKill"); - LinkedList amounts = (LinkedList) 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) context.getSessionData(pref + "npcIdsToKill")).size(); - } else { - one = 0; - } - - if (context.getSessionData(pref + "npcAmountsToKill") != null) { - two = ((List) 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 getNPCIds(ConversationContext context) { - return (List) context.getSessionData(pref + "npcIdsToKill"); - } - - private List getKillAmounts(ConversationContext context) { - return (List) 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 npcs = new LinkedList(); - 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 amounts = new LinkedList(); - 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(); - - } - } } diff --git a/src/me/blackvein/quests/prompts/StagesPrompt.java b/src/me/blackvein/quests/prompts/StagesPrompt.java index bb053479f..1c86ca4b1 100644 --- a/src/me/blackvein/quests/prompts/StagesPrompt.java +++ b/src/me/blackvein/quests/prompts/StagesPrompt.java @@ -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); diff --git a/src/me/blackvein/quests/stageDataNames.txt b/src/me/blackvein/quests/stageDataNames.txt index 7810079bf..18cd5dd7c 100644 --- a/src/me/blackvein/quests/stageDataNames.txt +++ b/src/me/blackvein/quests/stageDataNames.txt @@ -44,9 +44,6 @@ stage#tameAmounts stage#shearColors stage#shearAmounts -stage#npcIdsToKill -stage#npcAmountsToKill - stage#event stage#delay