From a49811f4fd564f20adafba74e6ca59f1ee35f06e Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 21 Oct 2016 21:20:36 -0400 Subject: [PATCH] Finished Building The Parts --- .../{gPowerTest.java => gPowerCommand.java} | 2 +- src/alisolarflare/gpowers/gPowerMemory.java | 6 ++- .../gpowers/listeners/gPowerApplyingTask.java | 52 +++++++++++++++++++ .../gpowers/listeners/gPowerListener.java | 5 +- .../listeners/gPowerRepeatingTask.java | 6 --- 5 files changed, 60 insertions(+), 11 deletions(-) rename src/alisolarflare/gpowers/{gPowerTest.java => gPowerCommand.java} (92%) create mode 100644 src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java delete mode 100644 src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java diff --git a/src/alisolarflare/gpowers/gPowerTest.java b/src/alisolarflare/gpowers/gPowerCommand.java similarity index 92% rename from src/alisolarflare/gpowers/gPowerTest.java rename to src/alisolarflare/gpowers/gPowerCommand.java index 432c6d4..fc9ad00 100644 --- a/src/alisolarflare/gpowers/gPowerTest.java +++ b/src/alisolarflare/gpowers/gPowerCommand.java @@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class gPowerTest implements CommandExecutor{ +public class gPowerCommand implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { diff --git a/src/alisolarflare/gpowers/gPowerMemory.java b/src/alisolarflare/gpowers/gPowerMemory.java index 209b734..7d0ad73 100644 --- a/src/alisolarflare/gpowers/gPowerMemory.java +++ b/src/alisolarflare/gpowers/gPowerMemory.java @@ -15,7 +15,7 @@ public class gPowerMemory { this.plugin = plugin; } //SHORT TERM MEMORY STORAGE - Map PlayerMap = new HashMap(); + public static Map PlayerMap = new HashMap(); //POWER ACTIVATION public void PowerUpPlayer(Player player, String colour){ @@ -57,7 +57,7 @@ public class gPowerMemory { } } //MEMORY UNIT - class poweredPlayer{ + public class poweredPlayer{ public UUID uuid; public String colour; public Boolean playerPowersActivated; @@ -71,6 +71,8 @@ public class gPowerMemory { return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+playerPowersActivated + "]"; } } + + //DEBUG @SuppressWarnings({ "deprecation" }) public void debug(String debugString){ if (plugin.getServer().getPlayer("alisolarflare").isOnline() && debugMode == true){ diff --git a/src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java b/src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java new file mode 100644 index 0000000..e281815 --- /dev/null +++ b/src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java @@ -0,0 +1,52 @@ +package alisolarflare.gpowers.listeners; + +import org.bukkit.Color; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + +import alisolarflare.AliPresents; +import alisolarflare.gpowers.gPowerMemory; + +public class gPowerApplyingTask extends BukkitRunnable{ + + private AliPresents plugin; + + public gPowerApplyingTask(AliPresents plugin) { + this.plugin = plugin; + } + + //REPEATS EVERY 5 SECONDS + @Override + public void run() { + for (Player player : plugin.getServer().getOnlinePlayers()){ + if(gPowerMemory.PlayerMap.containsKey(player.getUniqueId())){ + activatePower(player, gPowerMemory.PlayerMap.get(player.getUniqueId()).colour); + } + } + } + + private void activatePower(Player player, String colour) { + if ((colour.startsWith("grey") || colour.startsWith("gra")) && (player.getWorld().getTime() > 12575 && player.getWorld().getTime() < 22925)){ + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1, true, false, Color.GRAY)); + player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("r")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("o")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100, 1, true, false, Color.GRAY)); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("y") && player.getLocation().getBlock().getLightFromSky() == 15){ + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("g")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.LUCK, 100, 1, true, false, Color.GRAY)); + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("b")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 1, true, false, Color.GRAY)); + player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 100, 1, true, false, Color.GRAY)); + }else if (colour.startsWith("p")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100, 1, true, false, Color.GRAY)); + } + } + +} diff --git a/src/alisolarflare/gpowers/listeners/gPowerListener.java b/src/alisolarflare/gpowers/listeners/gPowerListener.java index 714581f..63d74ea 100644 --- a/src/alisolarflare/gpowers/listeners/gPowerListener.java +++ b/src/alisolarflare/gpowers/listeners/gPowerListener.java @@ -6,12 +6,13 @@ import org.bukkit.scheduler.BukkitTask; import alisolarflare.AliPresents; public class gPowerListener implements Listener{ - @SuppressWarnings("unused") private AliPresents plugin; - public gPowerRepeatingTask powerRepeatingTask; + public gPowerApplyingTask powerRepeatingTask; public BukkitTask bukkitTask; public gPowerListener(AliPresents plugin){ this.plugin = plugin; + this.powerRepeatingTask = new gPowerApplyingTask(this.plugin); + bukkitTask = powerRepeatingTask.runTaskTimer(plugin, 5, 5); } } diff --git a/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java b/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java deleted file mode 100644 index c5ef87d..0000000 --- a/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java +++ /dev/null @@ -1,6 +0,0 @@ -package alisolarflare.gpowers.listeners; - -public class gPowerRepeatingTask { - //REPEATS EVERY 5 SECONDS - -}