ButtonArchives/src/alisolarflare/gpowers/gPowerMemory.java

89 lines
2.4 KiB
Java
Raw Normal View History

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 static AliPresents plugin;
private static boolean debugMode = true;
public gPowerMemory(AliPresents plugin){
gPowerMemory.plugin = plugin;
}
//SHORT TERM MEMORY STORAGE
2016-10-22 01:20:36 +00:00
public static Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//POWER ACTIVATION
2016-10-22 01:38:22 +00:00
public static void PowerUpPlayer(Player player, String colour){
debug("POWERRRED UP");
if (PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).playerPowersActivated = true;
}else{
PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
}
//POWER DEACTIVATION
2016-10-22 01:38:22 +00:00
public static void PowerDownPlayer(Player player){
debug("POWERRRED DOWN");
if (PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).playerPowersActivated = false;
}else{
return;
}
}
2016-10-22 01:38:22 +00:00
public static void PowerDownPlayer(UUID UniqueID){
debug("POWEERRED DOWN");
if (PlayerMap.containsKey(UniqueID)){
PlayerMap.get(UniqueID).playerPowersActivated = false;
}else{
return;
}
}
2016-10-22 01:38:22 +00:00
public static boolean isPlayerPowered(UUID UniqueID){
debug("IS PLAYER POWERED?");
if (PlayerMap.containsKey(UniqueID)){
return PlayerMap.get(UniqueID).playerPowersActivated;
}else{
return false;
}
}
2016-10-22 01:38:22 +00:00
public static boolean isPlayerPowered(Player player){
debug("IS PLAYER POWERED?");
if (PlayerMap.containsKey(player.getUniqueId())){
return PlayerMap.get(player.getUniqueId()).playerPowersActivated;
}else{
return false;
}
}
//MEMORY UNIT
2016-10-22 01:38:22 +00:00
public static 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 + "]";
}
}
2016-10-22 01:20:36 +00:00
//DEBUG
@SuppressWarnings({ "deprecation" })
public static void debug(String debugString){
if (plugin.getServer().getPlayer("alisolarflare").isOnline() && debugMode == true){
plugin.getServer().getPlayer("alisolarflare").sendMessage("[gPowerTest]:"+debugString);
}
}
}