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 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;
public void PowerUpPlayer(Player player, String colour){
poweredPlayerList.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
//SHORT TERM MEMORY STORAGE
public static Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//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 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<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
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.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!");

View file

@ -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<UUID, poweredPlayer> poweredPlayerList;
public gPowerApplyingTask(JavaPlugin plugin) {
this.plugin = plugin;
public gPowerApplyingTask(Server server, Map<UUID, poweredPlayer> 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{
}
}

View file

@ -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);
public gPowerListener(JavaPlugin plugin, GPowerMemory gPowerMemory){
new gPowerApplyingTask(plugin.getServer(), gPowerMemory.poweredPlayerList).runTaskTimer(plugin, 190, 190);
}
}
*/

View file

@ -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));