From dd77078ec0a7ec69d5c0639d5d87b0ddb9c98776 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 21 Oct 2016 15:23:46 -0400 Subject: [PATCH] Created the Framework for Ghostie Powers --- .../flairdoors/PortalListener.java | 2 +- src/alisolarflare/gpowers/gPowerMemory.java | 81 +++++++++++++++++++ src/alisolarflare/gpowers/gPowerTest.java | 26 ++++++ src/alisolarflare/gpowers/gPowers.java | 5 ++ .../gpowers/listeners/gPowerListener.java | 30 +++++++ .../listeners/gPowerRepeatingTask.java | 6 ++ 6 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 src/alisolarflare/gpowers/gPowerMemory.java create mode 100644 src/alisolarflare/gpowers/gPowerTest.java create mode 100644 src/alisolarflare/gpowers/gPowers.java create mode 100644 src/alisolarflare/gpowers/listeners/gPowerListener.java create mode 100644 src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java diff --git a/src/alisolarflare/flairdoors/PortalListener.java b/src/alisolarflare/flairdoors/PortalListener.java index eff0aac..9bf9b1e 100644 --- a/src/alisolarflare/flairdoors/PortalListener.java +++ b/src/alisolarflare/flairdoors/PortalListener.java @@ -95,7 +95,7 @@ public class PortalListener implements Listener{ } public void recolourPlayer(Player player, DyeColor dyecolour){ player.sendMessage("Recolouring Player as..." + dyecolour.toString()); - String name = player.getCustomName(); + String name = player.getName(); player.sendMessage("name:" + name); for(int i = 0; i < name.length(); i++){ if (name.charAt(i) == '&'){ diff --git a/src/alisolarflare/gpowers/gPowerMemory.java b/src/alisolarflare/gpowers/gPowerMemory.java new file mode 100644 index 0000000..209b734 --- /dev/null +++ b/src/alisolarflare/gpowers/gPowerMemory.java @@ -0,0 +1,81 @@ +package alisolarflare.gpowers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.entity.Player; + +import alisolarflare.AliPresents; + +public class gPowerMemory { + private AliPresents plugin; + private boolean debugMode = true; + public gPowerMemory(AliPresents plugin){ + this.plugin = plugin; + } + //SHORT TERM MEMORY STORAGE + Map PlayerMap = new HashMap(); + + //POWER ACTIVATION + public void PowerUpPlayer(Player player, String colour){ + if (PlayerMap.containsKey(player.getUniqueId())){ + PlayerMap.get(player.getUniqueId()).playerPowersActivated = true; + }else{ + PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true)); + } + } + + //POWER DEACTIVATION + public void PowerDownPlayer(Player player){ + if (PlayerMap.containsKey(player.getUniqueId())){ + PlayerMap.get(player.getUniqueId()).playerPowersActivated = false; + }else{ + return; + } + + } + public void PowerDownPlayer(UUID UniqueID){ + if (PlayerMap.containsKey(UniqueID)){ + PlayerMap.get(UniqueID).playerPowersActivated = false; + }else{ + return; + } + } + public boolean isPlayerPowered(UUID UniqueID){ + if (PlayerMap.containsKey(UniqueID)){ + return PlayerMap.get(UniqueID).playerPowersActivated; + }else{ + return false; + } + } + public boolean isPlayerPowered(Player player){ + if (PlayerMap.containsKey(player.getUniqueId())){ + return PlayerMap.get(player.getUniqueId()).playerPowersActivated; + }else{ + return false; + } + } + //MEMORY UNIT + class poweredPlayer{ + public UUID uuid; + public String colour; + public Boolean playerPowersActivated; + + public poweredPlayer(UUID uuid, String colour, Boolean activated){ + this.uuid = (uuid); + this.colour = (colour); + this.playerPowersActivated = (activated); + } + public String toString(){ + return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+playerPowersActivated + "]"; + } + } + @SuppressWarnings({ "deprecation" }) + public void debug(String debugString){ + if (plugin.getServer().getPlayer("alisolarflare").isOnline() && debugMode == true){ + plugin.getServer().getPlayer("alisolarflare").sendMessage("[gPowerTest]:"+debugString); + } + } +} + diff --git a/src/alisolarflare/gpowers/gPowerTest.java b/src/alisolarflare/gpowers/gPowerTest.java new file mode 100644 index 0000000..432c6d4 --- /dev/null +++ b/src/alisolarflare/gpowers/gPowerTest.java @@ -0,0 +1,26 @@ +package alisolarflare.gpowers; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class gPowerTest implements CommandExecutor{ + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!(sender instanceof Player)){ + sender.sendMessage("You must be a player to use this command!"); + return false; + } + Player player = (Player) sender; + if (!(args.length < 2)){ + player.sendMessage("Proper Usage to test G-Powers:"); + player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); + return false; + } + + return false; + } + +} diff --git a/src/alisolarflare/gpowers/gPowers.java b/src/alisolarflare/gpowers/gPowers.java new file mode 100644 index 0000000..6f82784 --- /dev/null +++ b/src/alisolarflare/gpowers/gPowers.java @@ -0,0 +1,5 @@ +package alisolarflare.gpowers; + +public class gPowers { + +} diff --git a/src/alisolarflare/gpowers/listeners/gPowerListener.java b/src/alisolarflare/gpowers/listeners/gPowerListener.java new file mode 100644 index 0000000..714581f --- /dev/null +++ b/src/alisolarflare/gpowers/listeners/gPowerListener.java @@ -0,0 +1,30 @@ +package alisolarflare.gpowers.listeners; + +import org.bukkit.event.Listener; +import org.bukkit.scheduler.BukkitTask; + +import alisolarflare.AliPresents; + +public class gPowerListener implements Listener{ + @SuppressWarnings("unused") + private AliPresents plugin; + public gPowerRepeatingTask powerRepeatingTask; + public BukkitTask bukkitTask; + public gPowerListener(AliPresents plugin){ + this.plugin = plugin; + } + +} +/* + * 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 diff --git a/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java b/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java new file mode 100644 index 0000000..c5ef87d --- /dev/null +++ b/src/alisolarflare/gpowers/listeners/gPowerRepeatingTask.java @@ -0,0 +1,6 @@ +package alisolarflare.gpowers.listeners; + +public class gPowerRepeatingTask { + //REPEATS EVERY 5 SECONDS + +}