From 7cc32b84a4540628afb77e3d829ce792dc069fcd Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 4 Nov 2016 23:18:35 -0400 Subject: [PATCH] Mystery Commit. I have no idea where this came from --- .../components/gpowers/GPowerMemory.java | 83 ++++--------------- .../components/gpowers/GPowerModule.java | 5 +- .../components/gpowers/commands/GPower.java | 8 +- .../gpowers/listeners/gPowerApplyingTask.java | 29 +++++-- .../gpowers/listeners/gPowerListener.java | 30 ++----- .../magic/tricks/BoomBowListener.java | 2 +- 6 files changed, 52 insertions(+), 105 deletions(-) diff --git a/src/alisolarflare/components/gpowers/GPowerMemory.java b/src/alisolarflare/components/gpowers/GPowerMemory.java index f37fd7a..5a99b16 100644 --- a/src/alisolarflare/components/gpowers/GPowerMemory.java +++ b/src/alisolarflare/components/gpowers/GPowerMemory.java @@ -6,76 +6,34 @@ import java.util.UUID; import org.bukkit.entity.Player; -import alisolarflare.AliPresents; - -public class gPowerMemory{ - @SuppressWarnings("unused") - private static AliPresents plugin; - @SuppressWarnings("unused") - private static boolean debugMode = true; - public gPowerMemory(AliPresents plugin){ - gPowerMemory.plugin = plugin; - } - //SHORT TERM MEMORY STORAGE - public static Map PlayerMap = new HashMap(); +public class GPowerMemory{ + public Map poweredPlayerList = new HashMap(); - //POWER ACTIVATION - public static void PowerUpPlayer(Player player, String colour){ - //debug("POWERRRED UP"); - player.sendMessage("POWERRED UP!"); - PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true)); + public void PowerUpPlayer(Player player, String colour){ + poweredPlayerList.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true)); } - public static void PowerUpPlayer(Player player){ - //debug("POWERRRED UP"); - player.sendMessage("POWERRED UP!"); - if(PlayerMap.containsKey(player.getUniqueId())){ - PlayerMap.get(player.getUniqueId()).isPowersActive = true; + public void PowerUpPlayer(Player player){ + if(poweredPlayerList.containsKey(player.getUniqueId())){ + poweredPlayerList.get(player.getUniqueId()).isPowersActive = true; }else{ - player.sendMessage("You must instantiate your power settings using /gpowercommand"); + player.sendMessage("You must instantiate your power settings using /GPower"); } } - //POWER DEACTIVATION - public static void PowerDownPlayer(Player player){ - //debug("POWERRRED DOWN"); - if (PlayerMap.containsKey(player.getUniqueId())){ - PlayerMap.get(player.getUniqueId()).isPowersActive = false; + public void PowerDownPlayer(Player player){ + if (poweredPlayerList.containsKey(player.getUniqueId())){ + poweredPlayerList.get(player.getUniqueId()).isPowersActive = false; }else{ return; } } - public static void PowerDownPlayer(UUID UniqueID){ - //debug("POWEERRED DOWN"); - if (PlayerMap.containsKey(UniqueID)){ - PlayerMap.get(UniqueID).isPowersActive = false; - }else{ - return; - } - } - public static boolean isPlayerPowered(UUID UniqueID){ - //debug("IS PLAYER POWERED?"); - if (PlayerMap.containsKey(UniqueID)){ - return PlayerMap.get(UniqueID).isPowersActive; - }else{ - return false; - } - } - public static boolean isPlayerPowered(Player player){ - //debug("IS PLAYER POWERED?"); - if (PlayerMap.containsKey(player.getUniqueId())){ - return PlayerMap.get(player.getUniqueId()).isPowersActive; - }else{ - return false; - } - } - //MEMORY UNIT - public static class poweredPlayer{ - public static UUID uuid; + + public class poweredPlayer{ + public UUID uuid; public String colour; public Boolean isPowersActive; - @SuppressWarnings("static-access") public poweredPlayer(UUID uuid, String colour, Boolean activated){ this.uuid = (uuid); this.colour = (colour); @@ -85,18 +43,5 @@ public class gPowerMemory{ return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]"; } } - - public void saveMemoryState(){ - @SuppressWarnings("unused") - Map PlayerMap = new HashMap(); - //for (UUID uuidKey:PlayerMap.keySet()){ - - //UUID uuidToSave = poweredPlayer.uuid; - - //} - } - public void loadMemoryState(){ - - } } diff --git a/src/alisolarflare/components/gpowers/GPowerModule.java b/src/alisolarflare/components/gpowers/GPowerModule.java index b46d651..c3c4a53 100644 --- a/src/alisolarflare/components/gpowers/GPowerModule.java +++ b/src/alisolarflare/components/gpowers/GPowerModule.java @@ -10,9 +10,10 @@ public class GPowerModule extends Module { @Override public void register(JavaPlugin plugin) { - registerCommand(plugin, new GPower()); + GPowerMemory gPowerMemory = new GPowerMemory(); + registerCommand(plugin, new GPower(gPowerMemory)); - registerListener(plugin, new gPowerListener(plugin)); + registerListener(plugin, new gPowerListener(plugin, gPowerMemory)); } } diff --git a/src/alisolarflare/components/gpowers/commands/GPower.java b/src/alisolarflare/components/gpowers/commands/GPower.java index e37d2b7..6c2fcd9 100644 --- a/src/alisolarflare/components/gpowers/commands/GPower.java +++ b/src/alisolarflare/components/gpowers/commands/GPower.java @@ -3,11 +3,17 @@ package alisolarflare.components.gpowers.commands; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import alisolarflare.components.gpowers.gPowerMemory; +import alisolarflare.components.gpowers.GPowerMemory; import buttondevteam.lib.chat.TBMCCommandBase; public class GPower extends TBMCCommandBase { + private GPowerMemory gPowerMemory; + + public GPower(GPowerMemory gPowerMemory) { + this.gPowerMemory = gPowerMemory; + } + @Override public boolean OnCommand(CommandSender sender, String label, String[] args) { sender.sendMessage("G power activate!"); diff --git a/src/alisolarflare/components/gpowers/listeners/gPowerApplyingTask.java b/src/alisolarflare/components/gpowers/listeners/gPowerApplyingTask.java index 60f2709..d966e63 100644 --- a/src/alisolarflare/components/gpowers/listeners/gPowerApplyingTask.java +++ b/src/alisolarflare/components/gpowers/listeners/gPowerApplyingTask.java @@ -1,51 +1,64 @@ package alisolarflare.components.gpowers.listeners; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Color; +import org.bukkit.Server; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; -import alisolarflare.components.gpowers.gPowerMemory; +import alisolarflare.components.gpowers.GPowerMemory.poweredPlayer; public class gPowerApplyingTask extends BukkitRunnable{ - private JavaPlugin plugin; + private Server server; + private Map poweredPlayerList; - public gPowerApplyingTask(JavaPlugin plugin) { - this.plugin = plugin; + public gPowerApplyingTask(Server server, Map poweredPlayerList) { + this.server = server; + this.poweredPlayerList = poweredPlayerList; } //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); + for (Player player : server.getOnlinePlayers()){ + if(poweredPlayerList.containsKey(player.getUniqueId())){ + activatePower(player, poweredPlayerList.get(player.getUniqueId()).colour); } } } private void activatePower(Player player, String colour) { + //GREY if ((colour.startsWith("grey") || colour.startsWith("gra")) && (player.getWorld().getTime() > 12575 && player.getWorld().getTime() < 22925)){ player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 0, true, false, Color.GRAY)); player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 300, 0, true, false, Color.GRAY)); + //RED }else if (colour.startsWith("r")){ player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0, true, false, Color.RED)); + //ORANGE }else if (colour.startsWith("o")){ player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 200, 0, true, false, Color.ORANGE)); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 200, 0, true, false, Color.ORANGE)); + //YELLOW }else if (colour.startsWith("y") && player.getLocation().getBlock().getLightFromSky() == 15 && player.getLocation().getBlock().getLightFromBlocks() == 15){ player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 0, true, false, Color.YELLOW)); + //GREEN }else if (colour.startsWith("g") && !colour.startsWith("gra") && !colour.startsWith("grey")){ player.addPotionEffect(new PotionEffect(PotionEffectType.LUCK, 200, 1, true, false, Color.GREEN)); player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, 0, true, false, Color.GREEN)); + //BLUE }else if (colour.startsWith("b")){ player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 1, true, false, Color.BLUE)); player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 200, 0, true, false, Color.BLUE)); + //PURPLE }else if (colour.startsWith("p")){ player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 200, 0, true, false, Color.PURPLE)); + //NULL }else{ } } diff --git a/src/alisolarflare/components/gpowers/listeners/gPowerListener.java b/src/alisolarflare/components/gpowers/listeners/gPowerListener.java index 5ec3780..1b71481 100644 --- a/src/alisolarflare/components/gpowers/listeners/gPowerListener.java +++ b/src/alisolarflare/components/gpowers/listeners/gPowerListener.java @@ -2,30 +2,12 @@ package alisolarflare.components.gpowers.listeners; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitTask; + +import alisolarflare.components.gpowers.GPowerMemory; public class gPowerListener implements Listener{ - private JavaPlugin plugin; - public gPowerApplyingTask powerApplyingTask; - public BukkitTask bukkitTask; - public gPowerListener(JavaPlugin plugin){ - this.plugin = plugin; - this.powerApplyingTask = new gPowerApplyingTask(this.plugin); - bukkitTask = powerApplyingTask.runTaskTimer(plugin, 190, 190); - } - -} -/* - * public class CyclicalDisplayListener implements Listener{ - private final ButtonRebirthPlugin plugin; - public CyclicalDisplayTask cyclicalDisplayTask; - public BukkitTask bukkitTask; - - public CyclicalDisplayListener (ButtonRebirthPlugin initPlugin){ - plugin = initPlugin; - cyclicalDisplayTask = new CyclicalDisplayTask (this.plugin); - bukkitTask = cyclicalDisplayTask.runTaskTimer(this.plugin, 20, 20); - } -} - */ \ No newline at end of file + public gPowerListener(JavaPlugin plugin, GPowerMemory gPowerMemory){ + new gPowerApplyingTask(plugin.getServer(), gPowerMemory.poweredPlayerList).runTaskTimer(plugin, 190, 190); + } +} \ No newline at end of file diff --git a/src/alisolarflare/magic/tricks/BoomBowListener.java b/src/alisolarflare/magic/tricks/BoomBowListener.java index a7f6a3b..47a02d7 100644 --- a/src/alisolarflare/magic/tricks/BoomBowListener.java +++ b/src/alisolarflare/magic/tricks/BoomBowListener.java @@ -92,7 +92,7 @@ public class BoomBowListener implements Listener { player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20); event.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2); player.damage(9.0, player); - player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() - 3)); + player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 3));