Mystery Commit. I have no idea where this came from

This commit is contained in:
alisolarflare 2016-11-04 23:18:35 -04:00
parent 5ec330baf8
commit 7cc32b84a4
6 changed files with 52 additions and 105 deletions

View file

@ -6,76 +6,34 @@ import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.AliPresents; public class GPowerMemory{
public Map<UUID, poweredPlayer> poweredPlayerList = new HashMap<UUID, poweredPlayer>();
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<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//POWER ACTIVATION public void PowerUpPlayer(Player player, String colour){
public static void PowerUpPlayer(Player player, String colour){ poweredPlayerList.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
//debug("POWERRRED UP");
player.sendMessage("POWERRED UP!");
PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
} }
public static void PowerUpPlayer(Player player){ public void PowerUpPlayer(Player player){
//debug("POWERRRED UP"); if(poweredPlayerList.containsKey(player.getUniqueId())){
player.sendMessage("POWERRED UP!"); poweredPlayerList.get(player.getUniqueId()).isPowersActive = true;
if(PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = true;
}else{ }else{
player.sendMessage("You must instantiate your power settings using /gpowercommand"); player.sendMessage("You must instantiate your power settings using /GPower");
} }
} }
//POWER DEACTIVATION public void PowerDownPlayer(Player player){
public static void PowerDownPlayer(Player player){ if (poweredPlayerList.containsKey(player.getUniqueId())){
//debug("POWERRRED DOWN"); poweredPlayerList.get(player.getUniqueId()).isPowersActive = false;
if (PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = false;
}else{ }else{
return; return;
} }
} }
public static void PowerDownPlayer(UUID UniqueID){
//debug("POWEERRED DOWN"); public class poweredPlayer{
if (PlayerMap.containsKey(UniqueID)){ public UUID uuid;
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 String colour; public String colour;
public Boolean isPowersActive; public Boolean isPowersActive;
@SuppressWarnings("static-access")
public poweredPlayer(UUID uuid, String colour, Boolean activated){ public poweredPlayer(UUID uuid, String colour, Boolean activated){
this.uuid = (uuid); this.uuid = (uuid);
this.colour = (colour); this.colour = (colour);
@ -85,18 +43,5 @@ public class gPowerMemory{
return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]"; return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]";
} }
} }
public void saveMemoryState(){
@SuppressWarnings("unused")
Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//for (UUID uuidKey:PlayerMap.keySet()){
//UUID uuidToSave = poweredPlayer.uuid;
//}
}
public void loadMemoryState(){
}
} }

View file

@ -10,9 +10,10 @@ public class GPowerModule extends Module {
@Override @Override
public void register(JavaPlugin plugin) { 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));
} }
} }

View file

@ -3,11 +3,17 @@ package alisolarflare.components.gpowers.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.components.gpowers.gPowerMemory; import alisolarflare.components.gpowers.GPowerMemory;
import buttondevteam.lib.chat.TBMCCommandBase; import buttondevteam.lib.chat.TBMCCommandBase;
public class GPower extends TBMCCommandBase { public class GPower extends TBMCCommandBase {
private GPowerMemory gPowerMemory;
public GPower(GPowerMemory gPowerMemory) {
this.gPowerMemory = gPowerMemory;
}
@Override @Override
public boolean OnCommand(CommandSender sender, String label, String[] args) { public boolean OnCommand(CommandSender sender, String label, String[] args) {
sender.sendMessage("G power activate!"); sender.sendMessage("G power activate!");

View file

@ -1,51 +1,64 @@
package alisolarflare.components.gpowers.listeners; package alisolarflare.components.gpowers.listeners;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import alisolarflare.components.gpowers.gPowerMemory; import alisolarflare.components.gpowers.GPowerMemory.poweredPlayer;
public class gPowerApplyingTask extends BukkitRunnable{ public class gPowerApplyingTask extends BukkitRunnable{
private JavaPlugin plugin; private Server server;
private Map<UUID, poweredPlayer> poweredPlayerList;
public gPowerApplyingTask(JavaPlugin plugin) { public gPowerApplyingTask(Server server, Map<UUID, poweredPlayer> poweredPlayerList) {
this.plugin = plugin; this.server = server;
this.poweredPlayerList = poweredPlayerList;
} }
//REPEATS EVERY 5 SECONDS //REPEATS EVERY 5 SECONDS
@Override @Override
public void run() { public void run() {
for (Player player : plugin.getServer().getOnlinePlayers()){ for (Player player : server.getOnlinePlayers()){
if(gPowerMemory.PlayerMap.containsKey(player.getUniqueId())){ if(poweredPlayerList.containsKey(player.getUniqueId())){
activatePower(player, gPowerMemory.PlayerMap.get(player.getUniqueId()).colour); activatePower(player, poweredPlayerList.get(player.getUniqueId()).colour);
} }
} }
} }
private void activatePower(Player player, String colour) { private void activatePower(Player player, String colour) {
//GREY
if ((colour.startsWith("grey") || colour.startsWith("gra")) && (player.getWorld().getTime() > 12575 && player.getWorld().getTime() < 22925)){ 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.REGENERATION, 200, 0, true, false, Color.GRAY));
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 300, 0, true, false, Color.GRAY)); player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 300, 0, true, false, Color.GRAY));
//RED
}else if (colour.startsWith("r")){ }else if (colour.startsWith("r")){
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0, true, false, Color.RED)); player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0, true, false, Color.RED));
//ORANGE
}else if (colour.startsWith("o")){ }else if (colour.startsWith("o")){
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 200, 0, true, false, Color.ORANGE)); 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)); 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){ }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)); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 0, true, false, Color.YELLOW));
//GREEN
}else if (colour.startsWith("g") && !colour.startsWith("gra") && !colour.startsWith("grey")){ }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.LUCK, 200, 1, true, false, Color.GREEN));
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, 0, true, false, Color.GREEN)); player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 200, 0, true, false, Color.GREEN));
//BLUE
}else if (colour.startsWith("b")){ }else if (colour.startsWith("b")){
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 1, true, false, Color.BLUE)); 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)); player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 200, 0, true, false, Color.BLUE));
//PURPLE
}else if (colour.startsWith("p")){ }else if (colour.startsWith("p")){
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 200, 0, true, false, Color.PURPLE)); player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 200, 0, true, false, Color.PURPLE));
//NULL
}else{ }else{
} }
} }

View file

@ -2,30 +2,12 @@ package alisolarflare.components.gpowers.listeners;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import alisolarflare.components.gpowers.GPowerMemory;
public class gPowerListener implements Listener{ public class gPowerListener implements Listener{
private JavaPlugin plugin;
public gPowerApplyingTask powerApplyingTask;
public BukkitTask bukkitTask;
public gPowerListener(JavaPlugin plugin){ public gPowerListener(JavaPlugin plugin, GPowerMemory gPowerMemory){
this.plugin = plugin; new gPowerApplyingTask(plugin.getServer(), gPowerMemory.poweredPlayerList).runTaskTimer(plugin, 190, 190);
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);
}
}
*/

View file

@ -92,7 +92,7 @@ public class BoomBowListener implements Listener {
player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20); player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20);
event.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2); event.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
player.damage(9.0, player); player.damage(9.0, player);
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() - 3)); player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 3));