From 895e9d96114a359d4c3395f861453e2c34078433 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 22 Oct 2016 17:47:10 -0400 Subject: [PATCH] Moved AliArrows into AliPresents --- src/alisolarflare/AliPresents.java | 3 ++ .../aliarrow/AliArrowListener.java | 45 +++++++++++++++++++ .../aliarrow/AliArrowSubPlugin.java | 25 +++++++++++ src/alisolarflare/aliarrow/AliArrowTask.java | 40 +++++++++++++++++ .../gpowers/commands/PowerUp.java | 4 +- src/alisolarflare/gpowers/gPowerMemory.java | 7 +-- 6 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 src/alisolarflare/aliarrow/AliArrowListener.java create mode 100644 src/alisolarflare/aliarrow/AliArrowSubPlugin.java create mode 100644 src/alisolarflare/aliarrow/AliArrowTask.java diff --git a/src/alisolarflare/AliPresents.java b/src/alisolarflare/AliPresents.java index 0a34135..064ae40 100644 --- a/src/alisolarflare/AliPresents.java +++ b/src/alisolarflare/AliPresents.java @@ -15,6 +15,7 @@ import alisolarflare.gpowers.listeners.gPowerListener; //import alisolarflare.links.AliLinkSubPlug; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.shulker.AliShulker; +import alisolarflare.aliarrow.AliArrowSubPlugin; public class AliPresents extends JavaPlugin{ public void onEnable(){ @@ -37,6 +38,8 @@ public class AliPresents extends JavaPlugin{ getServer().getPluginManager().registerEvents(new gPowerListener(this), this); } public void registerSubPlugins(){ + AliArrowSubPlugin aliArrowSubPlugin = new AliArrowSubPlugin(this); + aliArrowSubPlugin.register(); //AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this); //alilinksubplugin.register(); } diff --git a/src/alisolarflare/aliarrow/AliArrowListener.java b/src/alisolarflare/aliarrow/AliArrowListener.java new file mode 100644 index 0000000..32a1a6c --- /dev/null +++ b/src/alisolarflare/aliarrow/AliArrowListener.java @@ -0,0 +1,45 @@ +package alisolarflare.aliarrow; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +import alisolarflare.AliPresents; + +public class AliArrowListener implements Listener { + private final AliPresents plugin; + + public AliArrowListener(AliPresents plugin){ + this.plugin = plugin; + } + + @EventHandler + public void onProjectileLaunch(ProjectileLaunchEvent event){ + try{ + if(!(event.getEntity().getType() == EntityType.ARROW)){ + return; + } + Projectile projectile = event.getEntity(); + Arrow arrow = (Arrow) projectile; + if (!(arrow.isCritical())){ + return; + } + if (projectile.getShooter().equals(plugin.getServer().getPlayer("alisolarflare"))){ + AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"alisolarflare"); + aliArrowTask.runTaskTimer(plugin, 2, 1); + return; + }else if (projectile.getShooter().equals(plugin.getServer().getPlayer("Zanthr"))){ + AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"zanthr"); + aliArrowTask.runTaskTimer(plugin, 2, 1); + return; + } + return; + + }catch(Exception e){ + return; + } + } +} \ No newline at end of file diff --git a/src/alisolarflare/aliarrow/AliArrowSubPlugin.java b/src/alisolarflare/aliarrow/AliArrowSubPlugin.java new file mode 100644 index 0000000..2d88ab4 --- /dev/null +++ b/src/alisolarflare/aliarrow/AliArrowSubPlugin.java @@ -0,0 +1,25 @@ +package alisolarflare.aliarrow; + +import java.util.logging.Level; + +import alisolarflare.AliPresents; + +public class AliArrowSubPlugin { + private AliPresents plugin; + + public AliArrowSubPlugin(AliPresents plugin){ + this.plugin = plugin; + } + public void register(){ + registerEvents(); + registerCommands(); + plugin.getLogger().log(Level.INFO, "Discord Sub Plugin Registered!"); + } + private void registerEvents(){ + plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); + + } + private void registerCommands(){ + + } +} diff --git a/src/alisolarflare/aliarrow/AliArrowTask.java b/src/alisolarflare/aliarrow/AliArrowTask.java new file mode 100644 index 0000000..8281039 --- /dev/null +++ b/src/alisolarflare/aliarrow/AliArrowTask.java @@ -0,0 +1,40 @@ +package alisolarflare.aliarrow; + +import org.bukkit.Particle; +import org.bukkit.entity.Arrow; +import org.bukkit.scheduler.BukkitRunnable; + +import alisolarflare.AliPresents; + +public class AliArrowTask extends BukkitRunnable{ + AliPresents plugin; + String name; + Arrow arrow; + + + + public AliArrowTask(AliPresents plugin, Arrow arrow, String name){ + this.name = name; + this.plugin = plugin; + this.arrow = arrow; + } + + @Override + public void run() { + if (arrow.isOnGround() || arrow.isDead()){ + this.cancel(); + } + if (name.equalsIgnoreCase("alisolarflare")){ + arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1); + } + if (name.equalsIgnoreCase("Zanthr")){ + arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1); + arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); + + } + + + + } + +} diff --git a/src/alisolarflare/gpowers/commands/PowerUp.java b/src/alisolarflare/gpowers/commands/PowerUp.java index a172ce3..535dd48 100644 --- a/src/alisolarflare/gpowers/commands/PowerUp.java +++ b/src/alisolarflare/gpowers/commands/PowerUp.java @@ -3,8 +3,8 @@ package alisolarflare.gpowers.commands; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; -import alisolarflare.gpowers.gPowerMemory; public class PowerUp implements CommandExecutor{ @@ -13,7 +13,7 @@ public class PowerUp implements CommandExecutor{ if (!(sender instanceof Player)){ sender.sendMessage("You must be a player to use this command!"); } - gPowerMemory.PowerUpPlayer(player, colour); + //gPowerMemory.PowerUpPlayer(player, colour); return false; } diff --git a/src/alisolarflare/gpowers/gPowerMemory.java b/src/alisolarflare/gpowers/gPowerMemory.java index b6c073d..ad8282a 100644 --- a/src/alisolarflare/gpowers/gPowerMemory.java +++ b/src/alisolarflare/gpowers/gPowerMemory.java @@ -75,6 +75,7 @@ public class gPowerMemory{ public String colour; public Boolean isPowersActive; + @SuppressWarnings("static-access") public poweredPlayer(UUID uuid, String colour, Boolean activated){ this.uuid = (uuid); this.colour = (colour); @@ -87,11 +88,11 @@ public class gPowerMemory{ public void saveMemoryState(){ Map PlayerMap = new HashMap(); - for (UUID uuidKey:PlayerMap.keySet()){ + //for (UUID uuidKey:PlayerMap.keySet()){ - UUID uuidToSave = poweredPlayer.uuid; + //UUID uuidToSave = poweredPlayer.uuid; - } + //} } public void loadMemoryState(){