From 50107bff819984aca2c47f3e41968e955ea9031a Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 31 Oct 2016 00:12:40 -0400 Subject: [PATCH] Begun work on Object Orientating my classes, so that things are more organized --- src/alisolarflare/AliPresents.java | 110 +++---- src/alisolarflare/Module.java | 48 +++ src/alisolarflare/Registerable.java | 11 + src/alisolarflare/events/uhc/AddToUHC.java | 2 +- src/alisolarflare/events/uhc/UHCMatch.java | 2 +- src/alisolarflare/events/uhc/UHCModule.java | 29 +- .../magictrick/aliarrow/AliArrowListener.java | 89 +++--- .../aliarrow/AliArrowSubPlugin.java | 52 ++-- .../magictrick/aliarrow/AliArrowTask.java | 80 ++--- .../tools/flairdoors/FlairDoorsSubPlug.java | 44 +-- .../tools/flairdoors/FlairMe.java | 36 +-- .../tools/flairdoors/PortalListener.java | 288 +++++++++--------- .../tools/flairdoors/SetFlairDoorColour.java | 96 +++--- .../tools/gpowers/commands/PowerDown.java | 30 +- .../tools/gpowers/commands/PowerUp.java | 40 +-- .../tools/gpowers/gPowerCommand.java | 112 +++---- .../tools/gpowers/gPowerMemory.java | 203 ++++++------ .../gpowers/listeners/gPowerApplyingTask.java | 106 +++---- .../gpowers/listeners/gPowerListener.java | 60 ++-- .../tools/links/AliLinkSubPlug.java | 8 +- .../tools/links/commands/PressAliLink.java | 6 +- .../tools/links/commands/SetAliLink.java | 6 +- .../tools/links/entities/Link.java | 74 ++--- .../tools/links/serializer/Deserializer.java | 72 ++--- .../tools/links/serializer/Serializer.java | 64 ++-- .../tools/links/tasks/UnpressTask.java | 42 +-- .../tools/shulker/AliShulker.java | 2 +- 27 files changed, 886 insertions(+), 826 deletions(-) create mode 100644 src/alisolarflare/Module.java create mode 100644 src/alisolarflare/Registerable.java diff --git a/src/alisolarflare/AliPresents.java b/src/alisolarflare/AliPresents.java index 064ae40..9c82e32 100644 --- a/src/alisolarflare/AliPresents.java +++ b/src/alisolarflare/AliPresents.java @@ -1,55 +1,55 @@ -package alisolarflare; - -import java.util.logging.Logger; - -import org.bukkit.plugin.PluginDescriptionFile; - -import alisolarflare.flairdoors.FlairMe; -import alisolarflare.flairdoors.PortalListener; -import alisolarflare.flairdoors.SetFlairDoorColour; -import alisolarflare.gpowers.gPowerCommand; -import alisolarflare.gpowers.commands.PowerDown; -import alisolarflare.gpowers.commands.PowerUp; -import alisolarflare.gpowers.listeners.gPowerListener; - -//import alisolarflare.links.AliLinkSubPlug; -import org.bukkit.plugin.java.JavaPlugin; -import alisolarflare.shulker.AliShulker; -import alisolarflare.aliarrow.AliArrowSubPlugin; - -public class AliPresents extends JavaPlugin{ - public void onEnable(){ - PluginDescriptionFile pdfFile = getDescription(); - Logger logger = getLogger(); - - - logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); - - registerSubPlugins(); - registerCommands(); - registerEvents(); - - logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); - - - } - private void registerEvents() { - getServer().getPluginManager().registerEvents(new PortalListener(this), this); - getServer().getPluginManager().registerEvents(new gPowerListener(this), this); - } - public void registerSubPlugins(){ - AliArrowSubPlugin aliArrowSubPlugin = new AliArrowSubPlugin(this); - aliArrowSubPlugin.register(); - //AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this); - //alilinksubplugin.register(); - } - public void registerCommands(){ - getCommand("powerup").setExecutor(new PowerUp()); - getCommand("powerdown").setExecutor(new PowerDown()); - getCommand("gpowercommand").setExecutor(new gPowerCommand()); - getCommand("flairme").setExecutor(new FlairMe()); - getCommand("alishulker").setExecutor(new AliShulker()); - getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour()); - - } -} +package alisolarflare; + +import java.util.logging.Logger; + +import org.bukkit.plugin.PluginDescriptionFile; +//import alisolarflare.links.AliLinkSubPlug; +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.magictrick.aliarrow.AliArrowSubPlugin; +import alisolarflare.tools.flairdoors.FlairMe; +import alisolarflare.tools.flairdoors.PortalListener; +import alisolarflare.tools.flairdoors.SetFlairDoorColour; +import alisolarflare.tools.gpowers.gPowerCommand; +import alisolarflare.tools.gpowers.commands.PowerDown; +import alisolarflare.tools.gpowers.commands.PowerUp; +import alisolarflare.tools.gpowers.listeners.gPowerListener; +import alisolarflare.tools.shulker.AliShulker; + +public class AliPresents extends JavaPlugin{ + public void onEnable(){ + PluginDescriptionFile pdfFile = getDescription(); + Logger logger = getLogger(); + + + logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); + + registerModules(); + registerCommands(); + registerEvents(); + + logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); + + + } + private void registerEvents() { + getServer().getPluginManager().registerEvents(new PortalListener(this), this); + getServer().getPluginManager().registerEvents(new gPowerListener(this), this); + } + public void registerModules(){ + new AliArrowSubPlugin(this).register(); + + + //AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this); + //alilinksubplugin.register(); + } + public void registerCommands(){ + getCommand("powerup").setExecutor(new PowerUp()); + getCommand("powerdown").setExecutor(new PowerDown()); + getCommand("gpowercommand").setExecutor(new gPowerCommand()); + getCommand("flairme").setExecutor(new FlairMe()); + getCommand("alishulker").setExecutor(new AliShulker()); + getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour()); + + } +} diff --git a/src/alisolarflare/Module.java b/src/alisolarflare/Module.java new file mode 100644 index 0000000..af580b5 --- /dev/null +++ b/src/alisolarflare/Module.java @@ -0,0 +1,48 @@ +package alisolarflare; + +import org.bukkit.command.CommandExecutor; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.magictrick.aliarrow.AliArrowListener; + +/** + * A Module class is a helper class that allows the compacting of projects into one single package. + * Each feature, whether game, arrow trail listener, or command tool, can have its command and listener + * registration coded into the Module class, as well as any other pointers to memory units, or other + * classes in the package. + * + * This package can then be moved from eclipse project to eclipse project smoothly, + * as long as the destination project has the Module abstract class, and as long as all dependencies are either + * contained in the moved package, or moved along with it. + * @author Alisolarflare + * + */ +public abstract class Module implements Registerable{ + /** + * Registers the project, when called by the Main JavaPlugin class that handles + * the main plugin. + * + * To register a command, call plugin.getCommand(//label).setExecutor(//commandExecutor); where + * label is a string containing the name of the command in plugin.yml, and where commandExecutor + * is a class implementing command executor + * + * To register a listener, + * @param plugin Plugin class called to register commands and listeners + */ + public abstract void register(JavaPlugin plugin); + /** + * Lazy route to type plugin.getCommand("label").setExecutor + * @param plugin Main plugin responsible for stuff + * @param label Name of the command in plugin.yml + * @param commandExecutor Custom coded CommandExecutor class + */ + protected CommandExecutor registerCommand(JavaPlugin plugin, String label, CommandExecutor commandExecutor){ + plugin.getCommand(label).setExecutor(commandExecutor); + return commandExecutor; + } + protected Listener registerListener(JavaPlugin plugin, Listener listener){ + plugin.getServer().getPluginManager().registerEvents(listener, plugin); + return listener; + } +} diff --git a/src/alisolarflare/Registerable.java b/src/alisolarflare/Registerable.java new file mode 100644 index 0000000..22cf3a0 --- /dev/null +++ b/src/alisolarflare/Registerable.java @@ -0,0 +1,11 @@ +package alisolarflare; + +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Allows the project to be registered by any Main JavaPlugin class, by calling //modulename.register(this) + * in any JavaPlugin class. + */ +public interface Registerable { + public void register(JavaPlugin plugin); +} diff --git a/src/alisolarflare/events/uhc/AddToUHC.java b/src/alisolarflare/events/uhc/AddToUHC.java index b084d4b..2abc2c4 100644 --- a/src/alisolarflare/events/uhc/AddToUHC.java +++ b/src/alisolarflare/events/uhc/AddToUHC.java @@ -1,4 +1,4 @@ -package alisolarflare.uhc; +package alisolarflare.events.uhc; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; diff --git a/src/alisolarflare/events/uhc/UHCMatch.java b/src/alisolarflare/events/uhc/UHCMatch.java index f4e6ccc..e9a078d 100644 --- a/src/alisolarflare/events/uhc/UHCMatch.java +++ b/src/alisolarflare/events/uhc/UHCMatch.java @@ -1,4 +1,4 @@ -package alisolarflare.uhc; +package alisolarflare.events.uhc; import java.util.ArrayList; import java.util.List; diff --git a/src/alisolarflare/events/uhc/UHCModule.java b/src/alisolarflare/events/uhc/UHCModule.java index 3841da1..8acaf0e 100644 --- a/src/alisolarflare/events/uhc/UHCModule.java +++ b/src/alisolarflare/events/uhc/UHCModule.java @@ -1,27 +1,24 @@ -package alisolarflare.uhc; +package alisolarflare.events.uhc; -import alisolarflare.AliPresents; +import org.bukkit.plugin.java.JavaPlugin; -public class UHCSubPlugin { - public AliPresents plugin; +import alisolarflare.Module; + +public class UHCModule extends Module { public UHCMatch generalMemory; - public UHCSubPlugin(AliPresents plugin){ - this.plugin = plugin; + public void register(JavaPlugin plugin){ + registerCommands(plugin); + registerListeners(plugin); + registerMemoryUnits(plugin); } - public void register(){ - registerCommands(); - registerListeners(); - registerMemoryUnits(); + private void registerListeners(JavaPlugin plugin) { } - private void registerListeners() { - } - private void registerCommands() { + private void registerCommands(JavaPlugin plugin) { // TODO Auto-generated method stub - plugin.getCommand("addToUHC").setExecutor(new AddToUHC(this.generalMemory)); + registerCommand(plugin, "addToUHC", new AddToUHC(this.generalMemory)); } - private void registerMemoryUnits(){ + private void registerMemoryUnits(JavaPlugin plugin){ generalMemory = new UHCMatch(); } - } diff --git a/src/alisolarflare/magictrick/aliarrow/AliArrowListener.java b/src/alisolarflare/magictrick/aliarrow/AliArrowListener.java index 32a1a6c..12227b1 100644 --- a/src/alisolarflare/magictrick/aliarrow/AliArrowListener.java +++ b/src/alisolarflare/magictrick/aliarrow/AliArrowListener.java @@ -1,45 +1,46 @@ -package alisolarflare.aliarrow; - -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.ProjectileLaunchEvent; - -import alisolarflare.AliPresents; - -public class AliArrowListener implements Listener { - private final AliPresents plugin; - - public AliArrowListener(AliPresents plugin){ - this.plugin = plugin; - } - - @EventHandler - public void onProjectileLaunch(ProjectileLaunchEvent event){ - try{ - if(!(event.getEntity().getType() == EntityType.ARROW)){ - return; - } - Projectile projectile = event.getEntity(); - Arrow arrow = (Arrow) projectile; - if (!(arrow.isCritical())){ - return; - } - if (projectile.getShooter().equals(plugin.getServer().getPlayer("alisolarflare"))){ - AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"alisolarflare"); - aliArrowTask.runTaskTimer(plugin, 2, 1); - return; - }else if (projectile.getShooter().equals(plugin.getServer().getPlayer("Zanthr"))){ - AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"zanthr"); - aliArrowTask.runTaskTimer(plugin, 2, 1); - return; - } - return; - - }catch(Exception e){ - return; - } - } +package alisolarflare.magictrick.aliarrow; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileLaunchEvent; + +import alisolarflare.AliPresents; + +public class AliArrowListener implements Listener { + private final AliPresents plugin; + + public AliArrowListener(AliPresents plugin){ + this.plugin = plugin; + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onProjectileLaunch(ProjectileLaunchEvent event){ + try{ + if(!(event.getEntity().getType() == EntityType.ARROW)){ + return; + } + Projectile projectile = event.getEntity(); + Arrow arrow = (Arrow) projectile; + if (!(arrow.isCritical())){ + return; + } + if (projectile.getShooter().equals(plugin.getServer().getPlayer("alisolarflare"))){ + AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"alisolarflare"); + aliArrowTask.runTaskTimer(plugin, 2, 1); + return; + }else if (projectile.getShooter().equals(plugin.getServer().getPlayer("Zanthr"))){ + AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"zanthr"); + aliArrowTask.runTaskTimer(plugin, 2, 1); + return; + } + return; + + }catch(Exception e){ + return; + } + } } \ No newline at end of file diff --git a/src/alisolarflare/magictrick/aliarrow/AliArrowSubPlugin.java b/src/alisolarflare/magictrick/aliarrow/AliArrowSubPlugin.java index 2d88ab4..05d63c3 100644 --- a/src/alisolarflare/magictrick/aliarrow/AliArrowSubPlugin.java +++ b/src/alisolarflare/magictrick/aliarrow/AliArrowSubPlugin.java @@ -1,25 +1,27 @@ -package alisolarflare.aliarrow; - -import java.util.logging.Level; - -import alisolarflare.AliPresents; - -public class AliArrowSubPlugin { - private AliPresents plugin; - - public AliArrowSubPlugin(AliPresents plugin){ - this.plugin = plugin; - } - public void register(){ - registerEvents(); - registerCommands(); - plugin.getLogger().log(Level.INFO, "Discord Sub Plugin Registered!"); - } - private void registerEvents(){ - plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); - - } - private void registerCommands(){ - - } -} +package alisolarflare.magictrick.aliarrow; + +import java.util.logging.Level; +import alisolarflare.AliPresents; + +public class AliArrowSubPlugin { + private AliPresents plugin; + + public AliArrowSubPlugin(AliPresents plugin){ + this.plugin = plugin; + } + /** + * Registers the plugin, activating listeners, commands, and events + */ + public void register(){ + registerEvents(); + registerCommands(); + plugin.getLogger().log(Level.INFO, "Discord Sub Plugin Registered!"); + } + private void registerEvents(){ + plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); + + } + private void registerCommands(){ + + } +} diff --git a/src/alisolarflare/magictrick/aliarrow/AliArrowTask.java b/src/alisolarflare/magictrick/aliarrow/AliArrowTask.java index 8281039..e52f984 100644 --- a/src/alisolarflare/magictrick/aliarrow/AliArrowTask.java +++ b/src/alisolarflare/magictrick/aliarrow/AliArrowTask.java @@ -1,40 +1,40 @@ -package alisolarflare.aliarrow; - -import org.bukkit.Particle; -import org.bukkit.entity.Arrow; -import org.bukkit.scheduler.BukkitRunnable; - -import alisolarflare.AliPresents; - -public class AliArrowTask extends BukkitRunnable{ - AliPresents plugin; - String name; - Arrow arrow; - - - - public AliArrowTask(AliPresents plugin, Arrow arrow, String name){ - this.name = name; - this.plugin = plugin; - this.arrow = arrow; - } - - @Override - public void run() { - if (arrow.isOnGround() || arrow.isDead()){ - this.cancel(); - } - if (name.equalsIgnoreCase("alisolarflare")){ - arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1); - } - if (name.equalsIgnoreCase("Zanthr")){ - arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1); - arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); - - } - - - - } - -} +package alisolarflare.magictrick.aliarrow; + +import org.bukkit.Particle; +import org.bukkit.entity.Arrow; +import org.bukkit.scheduler.BukkitRunnable; + +import alisolarflare.AliPresents; + +public class AliArrowTask extends BukkitRunnable{ + AliPresents plugin; + String name; + Arrow arrow; + + + + public AliArrowTask(AliPresents plugin, Arrow arrow, String name){ + this.name = name; + this.plugin = plugin; + this.arrow = arrow; + } + + @Override + public void run() { + if (arrow.isOnGround() || arrow.isDead()){ + this.cancel(); + } + if (name.equalsIgnoreCase("alisolarflare")){ + arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1); + } + if (name.equalsIgnoreCase("Zanthr")){ + arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1); + arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); + + } + + + + } + +} diff --git a/src/alisolarflare/tools/flairdoors/FlairDoorsSubPlug.java b/src/alisolarflare/tools/flairdoors/FlairDoorsSubPlug.java index 46407d0..1fea366 100644 --- a/src/alisolarflare/tools/flairdoors/FlairDoorsSubPlug.java +++ b/src/alisolarflare/tools/flairdoors/FlairDoorsSubPlug.java @@ -1,22 +1,22 @@ -package alisolarflare.flairdoors; - -import alisolarflare.AliPresents; - -public class FlairDoorsSubPlug{ - @SuppressWarnings("unused") - private AliPresents plugin; - public FlairDoorsSubPlug(AliPresents plugin){ - this.plugin = plugin; - } - public void register(){ - registerCommands(); - registerEvents(); - } - private void registerCommands() { - //plugin.getCommand("FlairMe").setExecutor(new FlairMe()); - } - private void registerEvents() { - // TODO Auto-generated method stub - - } -} +package alisolarflare.tools.flairdoors; + +import alisolarflare.AliPresents; + +public class FlairDoorsSubPlug{ + @SuppressWarnings("unused") + private AliPresents plugin; + public FlairDoorsSubPlug(AliPresents plugin){ + this.plugin = plugin; + } + public void register(){ + registerCommands(); + registerEvents(); + } + private void registerCommands() { + //plugin.getCommand("FlairMe").setExecutor(new FlairMe()); + } + private void registerEvents() { + // TODO Auto-generated method stub + + } +} diff --git a/src/alisolarflare/tools/flairdoors/FlairMe.java b/src/alisolarflare/tools/flairdoors/FlairMe.java index 789524d..49e04fb 100644 --- a/src/alisolarflare/tools/flairdoors/FlairMe.java +++ b/src/alisolarflare/tools/flairdoors/FlairMe.java @@ -1,18 +1,18 @@ -package alisolarflare.flairdoors; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -public class FlairMe implements CommandExecutor{ - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - sender.sendMessage("Flairing..." + sender.getName()); - PortalListener.playersToBeFlaired.add(sender.getName()); - sender.sendMessage("Finished Preparation! Walk through a portal to get your flair"); - - return false; - } - -} +package alisolarflare.tools.flairdoors; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class FlairMe implements CommandExecutor{ + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + sender.sendMessage("Flairing..." + sender.getName()); + PortalListener.playersToBeFlaired.add(sender.getName()); + sender.sendMessage("Finished Preparation! Walk through a portal to get your flair"); + + return false; + } + +} diff --git a/src/alisolarflare/tools/flairdoors/PortalListener.java b/src/alisolarflare/tools/flairdoors/PortalListener.java index 9bf9b1e..887697b 100644 --- a/src/alisolarflare/tools/flairdoors/PortalListener.java +++ b/src/alisolarflare/tools/flairdoors/PortalListener.java @@ -1,144 +1,144 @@ -package alisolarflare.flairdoors; - -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.material.MaterialData; -import org.bukkit.material.Wool; - -import alisolarflare.AliPresents; - -public class PortalListener implements Listener{ - AbstractMap portalMap = new HashMap(); - public static List playersToBeFlaired = new ArrayList(); - public AliPresents plugin; - - //TODO: CREATE - LIST OF PORTALS (only x-z values) - - - public PortalListener(AliPresents plugin) { - this.plugin = plugin; - } - @EventHandler - public void onPortalEnter(PlayerPortalEvent event){ - //SANITATION - Player - if(!(event.getPlayer() instanceof Player)){ - return; - } - - //INIT - Player - Player player = event.getPlayer(); - player.sendMessage("MAY THE FLAIRING COMMENCE"); - - //SANITATION - PlayersToBeFlaired - if(!(playersToBeFlaired.contains(player.getName()))){ - return; - } - player.sendMessage("-MAY THE FLAIRING COMMENCE-"); - player.sendMessage("Deactivating regular portal behaviour..."); - event.setTo(player.getLocation()); - - //INIT - x,y,z - int x = player.getLocation().getBlockX(); - int y = player.getLocation().getBlockY(); - int z = player.getLocation().getBlockZ(); - - //INIT - Blocks Under Portal - Block blockTopper = player.getWorld().getBlockAt(x,y-1,z); - Block blockMiddle = player.getWorld().getBlockAt(x,y-2,z); - Block blockBottom = player.getWorld().getBlockAt(x,y-3,z); - - player.sendMessage("Blocks being inspected:"); - player.sendMessage(blockTopper.toString()); - player.sendMessage(blockMiddle.toString()); - player.sendMessage(blockBottom.toString()); - - //RECOLOUR PLAYER - if(blockTopper.getType() == Material.STONE){ - player.sendMessage("STONE DETECTED"); - recolourPlayer(player, DyeColor.GRAY); - - //TOP BLOCK IS WOOL? - }else if(blockTopper.getType() == Material.WOOL){ - player.sendMessage("WOOL DETECTED T"); - Wool wool = (Wool) blockTopper.getState().getData(); - recolourPlayer(player, wool.getColor()); - - //MIDDLE BLOCK IS WOOL? - }else if(blockMiddle.getType() == Material.WOOL){ - - player.sendMessage("WOOL DETECTED M"); - MaterialData mData = blockMiddle.getState().getData(); - player.sendMessage("MATERIAL DATA COLLECTED: "+ mData.toString()); - Wool wool = (Wool) mData; - player.sendMessage("WOOL DATA CONVERTED: "+ wool.toString()); - - recolourPlayer(player, wool.getColor()); - - //BOTTOM BLOCK IS WOOL? - }else if (blockBottom.getType() == Material.WOOL){ - player.sendMessage("WOOL DETECTED B"); - Wool wool = (Wool) blockBottom.getState().getData(); - recolourPlayer(player, wool.getColor()); - } - - } - public void recolourPlayer(Player player, DyeColor dyecolour){ - player.sendMessage("Recolouring Player as..." + dyecolour.toString()); - String name = player.getName(); - player.sendMessage("name:" + name); - for(int i = 0; i < name.length(); i++){ - if (name.charAt(i) == '&'){ - //TODO: Remove all &* symbols - name = name.substring(0, i) + name.substring(i + 1, name.length()); - - } - } - player.sendMessage("Adjusted Name: " + name); - - if(dyecolour == DyeColor.GRAY){ - player.sendMessage("Adding GRAY"); - player.setCustomName("&7" + name); - - }else if(dyecolour == DyeColor.RED){ - player.sendMessage("Adding RED"); - player.setCustomName("&4" + name); - - }else if(dyecolour == DyeColor.ORANGE){ - player.sendMessage("Adding ORANGE"); - player.setCustomName("&6" + name); - - }else if(dyecolour == DyeColor.YELLOW){ - player.sendMessage("Adding YELLOW"); - player.setCustomName("&e" + name); - - }else if(dyecolour == DyeColor.GREEN){ - player.sendMessage("Adding GREEN"); - player.setCustomName("&a" + name); - - }else if(dyecolour == DyeColor.BLUE){ - player.sendMessage("Adding BLUE"); - player.setCustomName("&9" + name); - - }else if(dyecolour == DyeColor.PURPLE){ - player.sendMessage("Adding PURPLE"); - player.setCustomName("&5" + name); - - }else{ - player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK"); - return; - } - player.sendMessage("Your name is now: " + player.getCustomName() +"! Removing you from playersToBeFlaired..."); - playersToBeFlaired.remove(player.getName()); - } -} +package alisolarflare.tools.flairdoors; + +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.material.MaterialData; +import org.bukkit.material.Wool; + +import alisolarflare.AliPresents; + +public class PortalListener implements Listener{ + AbstractMap portalMap = new HashMap(); + public static List playersToBeFlaired = new ArrayList(); + public AliPresents plugin; + + //TODO: CREATE - LIST OF PORTALS (only x-z values) + + + public PortalListener(AliPresents plugin) { + this.plugin = plugin; + } + @EventHandler + public void onPortalEnter(PlayerPortalEvent event){ + //SANITATION - Player + if(!(event.getPlayer() instanceof Player)){ + return; + } + + //INIT - Player + Player player = event.getPlayer(); + player.sendMessage("MAY THE FLAIRING COMMENCE"); + + //SANITATION - PlayersToBeFlaired + if(!(playersToBeFlaired.contains(player.getName()))){ + return; + } + player.sendMessage("-MAY THE FLAIRING COMMENCE-"); + player.sendMessage("Deactivating regular portal behaviour..."); + event.setTo(player.getLocation()); + + //INIT - x,y,z + int x = player.getLocation().getBlockX(); + int y = player.getLocation().getBlockY(); + int z = player.getLocation().getBlockZ(); + + //INIT - Blocks Under Portal + Block blockTopper = player.getWorld().getBlockAt(x,y-1,z); + Block blockMiddle = player.getWorld().getBlockAt(x,y-2,z); + Block blockBottom = player.getWorld().getBlockAt(x,y-3,z); + + player.sendMessage("Blocks being inspected:"); + player.sendMessage(blockTopper.toString()); + player.sendMessage(blockMiddle.toString()); + player.sendMessage(blockBottom.toString()); + + //RECOLOUR PLAYER + if(blockTopper.getType() == Material.STONE){ + player.sendMessage("STONE DETECTED"); + recolourPlayer(player, DyeColor.GRAY); + + //TOP BLOCK IS WOOL? + }else if(blockTopper.getType() == Material.WOOL){ + player.sendMessage("WOOL DETECTED T"); + Wool wool = (Wool) blockTopper.getState().getData(); + recolourPlayer(player, wool.getColor()); + + //MIDDLE BLOCK IS WOOL? + }else if(blockMiddle.getType() == Material.WOOL){ + + player.sendMessage("WOOL DETECTED M"); + MaterialData mData = blockMiddle.getState().getData(); + player.sendMessage("MATERIAL DATA COLLECTED: "+ mData.toString()); + Wool wool = (Wool) mData; + player.sendMessage("WOOL DATA CONVERTED: "+ wool.toString()); + + recolourPlayer(player, wool.getColor()); + + //BOTTOM BLOCK IS WOOL? + }else if (blockBottom.getType() == Material.WOOL){ + player.sendMessage("WOOL DETECTED B"); + Wool wool = (Wool) blockBottom.getState().getData(); + recolourPlayer(player, wool.getColor()); + } + + } + public void recolourPlayer(Player player, DyeColor dyecolour){ + player.sendMessage("Recolouring Player as..." + dyecolour.toString()); + String name = player.getName(); + player.sendMessage("name:" + name); + for(int i = 0; i < name.length(); i++){ + if (name.charAt(i) == '&'){ + //TODO: Remove all &* symbols + name = name.substring(0, i) + name.substring(i + 1, name.length()); + + } + } + player.sendMessage("Adjusted Name: " + name); + + if(dyecolour == DyeColor.GRAY){ + player.sendMessage("Adding GRAY"); + player.setCustomName("&7" + name); + + }else if(dyecolour == DyeColor.RED){ + player.sendMessage("Adding RED"); + player.setCustomName("&4" + name); + + }else if(dyecolour == DyeColor.ORANGE){ + player.sendMessage("Adding ORANGE"); + player.setCustomName("&6" + name); + + }else if(dyecolour == DyeColor.YELLOW){ + player.sendMessage("Adding YELLOW"); + player.setCustomName("&e" + name); + + }else if(dyecolour == DyeColor.GREEN){ + player.sendMessage("Adding GREEN"); + player.setCustomName("&a" + name); + + }else if(dyecolour == DyeColor.BLUE){ + player.sendMessage("Adding BLUE"); + player.setCustomName("&9" + name); + + }else if(dyecolour == DyeColor.PURPLE){ + player.sendMessage("Adding PURPLE"); + player.setCustomName("&5" + name); + + }else{ + player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK"); + return; + } + player.sendMessage("Your name is now: " + player.getCustomName() +"! Removing you from playersToBeFlaired..."); + playersToBeFlaired.remove(player.getName()); + } +} diff --git a/src/alisolarflare/tools/flairdoors/SetFlairDoorColour.java b/src/alisolarflare/tools/flairdoors/SetFlairDoorColour.java index f76e163..965acf5 100644 --- a/src/alisolarflare/tools/flairdoors/SetFlairDoorColour.java +++ b/src/alisolarflare/tools/flairdoors/SetFlairDoorColour.java @@ -1,48 +1,48 @@ -package alisolarflare.flairdoors; - -import java.util.Arrays; -import java.util.List; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -public class SetFlairDoorColour implements CommandExecutor { - public static String FlairDoorColorMode = "null"; - public static final List COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray"); - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (args.length > 1){ - sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA"); - } - - String firstCommand = args[0]; - firstCommand = firstCommand.toLowerCase(); - if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ - sender.sendMessage("Flair Door Colour Mode set to gray"); - FlairDoorColorMode = "gray"; - }else if(firstCommand.startsWith("r")){ - sender.sendMessage("Flair Door Colour Mode set to Red"); - FlairDoorColorMode = "red"; - }else if(firstCommand.startsWith("o")){ - sender.sendMessage("Flair Door Colour Mode set to Orange"); - FlairDoorColorMode = "orange"; - }else if(firstCommand.startsWith("y")){ - sender.sendMessage("Flair Door Colour Mode set to Yellow"); - FlairDoorColorMode = "yellow"; - }else if(firstCommand.startsWith("g")){ - sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)"); - FlairDoorColorMode = "green"; - }else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){ - sender.sendMessage("Flair Door Colour Mode set to Blue"); - FlairDoorColorMode = "blue"; - }else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){ - sender.sendMessage("Flair Door Colour Mode set to Purple"); - FlairDoorColorMode = "purple"; - }else if(firstCommand.startsWith("n")){ - sender.sendMessage("Flair Door Colour Mode set to Null"); - FlairDoorColorMode = "null"; - } - return false; - } -} +package alisolarflare.tools.flairdoors; + +import java.util.Arrays; +import java.util.List; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class SetFlairDoorColour implements CommandExecutor { + public static String FlairDoorColorMode = "null"; + public static final List COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray"); + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length > 1){ + sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA"); + } + + String firstCommand = args[0]; + firstCommand = firstCommand.toLowerCase(); + if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ + sender.sendMessage("Flair Door Colour Mode set to gray"); + FlairDoorColorMode = "gray"; + }else if(firstCommand.startsWith("r")){ + sender.sendMessage("Flair Door Colour Mode set to Red"); + FlairDoorColorMode = "red"; + }else if(firstCommand.startsWith("o")){ + sender.sendMessage("Flair Door Colour Mode set to Orange"); + FlairDoorColorMode = "orange"; + }else if(firstCommand.startsWith("y")){ + sender.sendMessage("Flair Door Colour Mode set to Yellow"); + FlairDoorColorMode = "yellow"; + }else if(firstCommand.startsWith("g")){ + sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)"); + FlairDoorColorMode = "green"; + }else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){ + sender.sendMessage("Flair Door Colour Mode set to Blue"); + FlairDoorColorMode = "blue"; + }else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){ + sender.sendMessage("Flair Door Colour Mode set to Purple"); + FlairDoorColorMode = "purple"; + }else if(firstCommand.startsWith("n")){ + sender.sendMessage("Flair Door Colour Mode set to Null"); + FlairDoorColorMode = "null"; + } + return false; + } +} diff --git a/src/alisolarflare/tools/gpowers/commands/PowerDown.java b/src/alisolarflare/tools/gpowers/commands/PowerDown.java index e94855e..bcdc714 100644 --- a/src/alisolarflare/tools/gpowers/commands/PowerDown.java +++ b/src/alisolarflare/tools/gpowers/commands/PowerDown.java @@ -1,15 +1,15 @@ -package alisolarflare.gpowers.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -public class PowerDown implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { - // TODO Auto-generated method stub - return false; - } - -} +package alisolarflare.tools.gpowers.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class PowerDown implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/alisolarflare/tools/gpowers/commands/PowerUp.java b/src/alisolarflare/tools/gpowers/commands/PowerUp.java index 535dd48..c89fcd5 100644 --- a/src/alisolarflare/tools/gpowers/commands/PowerUp.java +++ b/src/alisolarflare/tools/gpowers/commands/PowerUp.java @@ -1,20 +1,20 @@ -package alisolarflare.gpowers.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - - -public class PowerUp 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!"); - } - //gPowerMemory.PowerUpPlayer(player, colour); - return false; - } - -} +package alisolarflare.tools.gpowers.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + + +public class PowerUp 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!"); + } + //gPowerMemory.PowerUpPlayer(player, colour); + return false; + } + +} diff --git a/src/alisolarflare/tools/gpowers/gPowerCommand.java b/src/alisolarflare/tools/gpowers/gPowerCommand.java index c49ae63..2170d8c 100644 --- a/src/alisolarflare/tools/gpowers/gPowerCommand.java +++ b/src/alisolarflare/tools/gpowers/gPowerCommand.java @@ -1,56 +1,56 @@ -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 gPowerCommand implements CommandExecutor{ - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - sender.sendMessage("G power activate!"); - 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; - } - String colour; - player.sendMessage("Checking terms..."); - if(args[0].startsWith("r") || - args[0].startsWith("o")|| - args[0].startsWith("y")|| - args[0].startsWith("g")|| - args[0].startsWith("b")|| - args[0].startsWith("p")){ - colour = args[0]; - }else{ - player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:"); - player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); - return false; - } - boolean isActive; - if(args[1].startsWith("t")){ - isActive = true; - }else if (args[1].startsWith("f")){ - isActive = false; - }else{ - player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:"); - player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); - return false; - } - player.sendMessage("Terms Vaild!"); - if(isActive){ - gPowerMemory.PowerUpPlayer(player, colour); - }else{ - gPowerMemory.PowerDownPlayer(player); - } - return false; - } - -} +package alisolarflare.tools.gpowers; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class gPowerCommand implements CommandExecutor{ + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + sender.sendMessage("G power activate!"); + 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; + } + String colour; + player.sendMessage("Checking terms..."); + if(args[0].startsWith("r") || + args[0].startsWith("o")|| + args[0].startsWith("y")|| + args[0].startsWith("g")|| + args[0].startsWith("b")|| + args[0].startsWith("p")){ + colour = args[0]; + }else{ + player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:"); + player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); + return false; + } + boolean isActive; + if(args[1].startsWith("t")){ + isActive = true; + }else if (args[1].startsWith("f")){ + isActive = false; + }else{ + player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:"); + player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); + return false; + } + player.sendMessage("Terms Vaild!"); + if(isActive){ + gPowerMemory.PowerUpPlayer(player, colour); + }else{ + gPowerMemory.PowerDownPlayer(player); + } + return false; + } + +} diff --git a/src/alisolarflare/tools/gpowers/gPowerMemory.java b/src/alisolarflare/tools/gpowers/gPowerMemory.java index ad8282a..56c9a58 100644 --- a/src/alisolarflare/tools/gpowers/gPowerMemory.java +++ b/src/alisolarflare/tools/gpowers/gPowerMemory.java @@ -1,101 +1,102 @@ -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{ - @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(); - - //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; - }else{ - player.sendMessage("You must instantiate your power settings using /gpowercommand"); - } - } - - //POWER DEACTIVATION - public static void PowerDownPlayer(Player player){ - //debug("POWERRRED DOWN"); - if (PlayerMap.containsKey(player.getUniqueId())){ - PlayerMap.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 String colour; - public Boolean isPowersActive; - - @SuppressWarnings("static-access") - public poweredPlayer(UUID uuid, String colour, Boolean activated){ - this.uuid = (uuid); - this.colour = (colour); - this.isPowersActive = (activated); - } - public String toString(){ - return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]"; - } - } - - public void saveMemoryState(){ - Map PlayerMap = new HashMap(); - //for (UUID uuidKey:PlayerMap.keySet()){ - - //UUID uuidToSave = poweredPlayer.uuid; - - //} - } - public void loadMemoryState(){ - - } -} - +package alisolarflare.tools.gpowers; + +import java.util.HashMap; +import java.util.Map; +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(); + + //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; + }else{ + player.sendMessage("You must instantiate your power settings using /gpowercommand"); + } + } + + //POWER DEACTIVATION + public static void PowerDownPlayer(Player player){ + //debug("POWERRRED DOWN"); + if (PlayerMap.containsKey(player.getUniqueId())){ + PlayerMap.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 String colour; + public Boolean isPowersActive; + + @SuppressWarnings("static-access") + public poweredPlayer(UUID uuid, String colour, Boolean activated){ + this.uuid = (uuid); + this.colour = (colour); + this.isPowersActive = (activated); + } + public String toString(){ + 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/tools/gpowers/listeners/gPowerApplyingTask.java b/src/alisolarflare/tools/gpowers/listeners/gPowerApplyingTask.java index d110477..63d1676 100644 --- a/src/alisolarflare/tools/gpowers/listeners/gPowerApplyingTask.java +++ b/src/alisolarflare/tools/gpowers/listeners/gPowerApplyingTask.java @@ -1,53 +1,53 @@ -package alisolarflare.gpowers.listeners; - -import org.bukkit.Color; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; - -import alisolarflare.AliPresents; -import alisolarflare.gpowers.gPowerMemory; - -public class gPowerApplyingTask extends BukkitRunnable{ - - private AliPresents plugin; - - public gPowerApplyingTask(AliPresents plugin) { - this.plugin = plugin; - } - - //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); - } - } - } - - private void activatePower(Player player, String colour) { - 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)); - }else if (colour.startsWith("r")){ - player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0, true, false, Color.RED)); - }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)); - }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)); - }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)); - }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)); - }else if (colour.startsWith("p")){ - player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 200, 0, true, false, Color.PURPLE)); - }else{ - } - } - -} +package alisolarflare.tools.gpowers.listeners; + +import org.bukkit.Color; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + +import alisolarflare.AliPresents; +import alisolarflare.tools.gpowers.gPowerMemory; + +public class gPowerApplyingTask extends BukkitRunnable{ + + private AliPresents plugin; + + public gPowerApplyingTask(AliPresents plugin) { + this.plugin = plugin; + } + + //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); + } + } + } + + private void activatePower(Player player, String colour) { + 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)); + }else if (colour.startsWith("r")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0, true, false, Color.RED)); + }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)); + }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)); + }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)); + }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)); + }else if (colour.startsWith("p")){ + player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 200, 0, true, false, Color.PURPLE)); + }else{ + } + } + +} diff --git a/src/alisolarflare/tools/gpowers/listeners/gPowerListener.java b/src/alisolarflare/tools/gpowers/listeners/gPowerListener.java index c8197e8..bca5927 100644 --- a/src/alisolarflare/tools/gpowers/listeners/gPowerListener.java +++ b/src/alisolarflare/tools/gpowers/listeners/gPowerListener.java @@ -1,31 +1,31 @@ -package alisolarflare.gpowers.listeners; - -import org.bukkit.event.Listener; -import org.bukkit.scheduler.BukkitTask; - -import alisolarflare.AliPresents; - -public class gPowerListener implements Listener{ - private AliPresents plugin; - public gPowerApplyingTask powerApplyingTask; - public BukkitTask bukkitTask; - public gPowerListener(AliPresents 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); - } -} +package alisolarflare.tools.gpowers.listeners; + +import org.bukkit.event.Listener; +import org.bukkit.scheduler.BukkitTask; + +import alisolarflare.AliPresents; + +public class gPowerListener implements Listener{ + private AliPresents plugin; + public gPowerApplyingTask powerApplyingTask; + public BukkitTask bukkitTask; + public gPowerListener(AliPresents 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 diff --git a/src/alisolarflare/tools/links/AliLinkSubPlug.java b/src/alisolarflare/tools/links/AliLinkSubPlug.java index f5e2843..c85db53 100644 --- a/src/alisolarflare/tools/links/AliLinkSubPlug.java +++ b/src/alisolarflare/tools/links/AliLinkSubPlug.java @@ -1,10 +1,10 @@ -package alisolarflare.links; +package alisolarflare.tools.links; import java.util.List; import alisolarflare.AliPresents; -import alisolarflare.links.commands.PressAliLink; -import alisolarflare.links.commands.SetAliLink; -import alisolarflare.links.entities.Link; +import alisolarflare.tools.links.commands.PressAliLink; +import alisolarflare.tools.links.commands.SetAliLink; +import alisolarflare.tools.links.entities.Link; public class AliLinkSubPlug{ public AliPresents plugin; diff --git a/src/alisolarflare/tools/links/commands/PressAliLink.java b/src/alisolarflare/tools/links/commands/PressAliLink.java index de76443..e8ec607 100644 --- a/src/alisolarflare/tools/links/commands/PressAliLink.java +++ b/src/alisolarflare/tools/links/commands/PressAliLink.java @@ -1,11 +1,11 @@ -package alisolarflare.links.commands; +package alisolarflare.tools.links.commands; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import alisolarflare.links.AliLinkSubPlug; -import alisolarflare.links.entities.Link; +import alisolarflare.tools.links.AliLinkSubPlug; +import alisolarflare.tools.links.entities.Link; public class PressAliLink implements CommandExecutor{ private AliLinkSubPlug subplugin; diff --git a/src/alisolarflare/tools/links/commands/SetAliLink.java b/src/alisolarflare/tools/links/commands/SetAliLink.java index 5fd5fa7..4d5f74a 100644 --- a/src/alisolarflare/tools/links/commands/SetAliLink.java +++ b/src/alisolarflare/tools/links/commands/SetAliLink.java @@ -1,4 +1,4 @@ -package alisolarflare.links.commands; +package alisolarflare.tools.links.commands; import java.util.ArrayList; @@ -12,8 +12,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import alisolarflare.AliPresents; -import alisolarflare.links.AliLinkSubPlug; -import alisolarflare.links.entities.Link; +import alisolarflare.tools.links.AliLinkSubPlug; +import alisolarflare.tools.links.entities.Link; /** * This class manages the command /SetAliLink [x] [y] [z]. This command creates an Ali-Link, diff --git a/src/alisolarflare/tools/links/entities/Link.java b/src/alisolarflare/tools/links/entities/Link.java index a0a7449..d9868b5 100644 --- a/src/alisolarflare/tools/links/entities/Link.java +++ b/src/alisolarflare/tools/links/entities/Link.java @@ -1,37 +1,37 @@ -package alisolarflare.links.entities; - -import java.io.Serializable; - -import org.bukkit.Location; -import org.bukkit.Material; - -import alisolarflare.links.AliLinkSubPlug; -import alisolarflare.links.tasks.UnpressTask; - -public class Link implements Serializable{ - /** - * - */ - private static final long serialVersionUID = 1L; - public String frequency; - public String world; - public String x; - public String y; - public String z; - - - public Link(String frequency, Location location){ - this.frequency = frequency; - this.world = location.getWorld().getName(); - this.x = "" + location.getBlockX(); - this.y = "" + location.getBlockY(); - this.z = "" + location.getBlockZ(); - //plugin.plugin.getConfig().set("frequency", 10); - } - public void press(AliLinkSubPlug plugin) { - Location location = new Location(plugin.plugin.getServer().getWorld(world), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z)); - location.getBlock().setType(Material.REDSTONE_BLOCK); - UnpressTask unPressTask = new UnpressTask(location); - unPressTask.runTaskTimer(plugin.plugin, 2, 1); - } -} +package alisolarflare.tools.links.entities; + +import java.io.Serializable; + +import org.bukkit.Location; +import org.bukkit.Material; + +import alisolarflare.tools.links.AliLinkSubPlug; +import alisolarflare.tools.links.tasks.UnpressTask; + +public class Link implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 1L; + public String frequency; + public String world; + public String x; + public String y; + public String z; + + + public Link(String frequency, Location location){ + this.frequency = frequency; + this.world = location.getWorld().getName(); + this.x = "" + location.getBlockX(); + this.y = "" + location.getBlockY(); + this.z = "" + location.getBlockZ(); + //plugin.plugin.getConfig().set("frequency", 10); + } + public void press(AliLinkSubPlug plugin) { + Location location = new Location(plugin.plugin.getServer().getWorld(world), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z)); + location.getBlock().setType(Material.REDSTONE_BLOCK); + UnpressTask unPressTask = new UnpressTask(location); + unPressTask.runTaskTimer(plugin.plugin, 2, 1); + } +} diff --git a/src/alisolarflare/tools/links/serializer/Deserializer.java b/src/alisolarflare/tools/links/serializer/Deserializer.java index db5da86..7aacfb8 100644 --- a/src/alisolarflare/tools/links/serializer/Deserializer.java +++ b/src/alisolarflare/tools/links/serializer/Deserializer.java @@ -1,36 +1,36 @@ -package alisolarflare.links.serializer; - - -import java.io.FileInputStream; -import java.io.ObjectInputStream; -import java.util.List; - -import alisolarflare.links.entities.Link; - -public class Deserializer{ - - public static void main (String args[]) { - - //Deserializer deserializer = new Deserializer(); - //List aliLink = deserializer.loadLink(aliLink); - //System.out.println(aliLink); - } - - @SuppressWarnings("unchecked") - public List loadLinkList(){ - List aliLinkList; - try{ - - FileInputStream fin = new FileInputStream("AliLinkList.ser"); - ObjectInputStream ois = new ObjectInputStream(fin); - aliLinkList = (List) ois.readObject(); - ois.close(); - - return aliLinkList; - - }catch(Exception ex){ - ex.printStackTrace(); - return null; - } - } -} +package alisolarflare.tools.links.serializer; + + +import java.io.FileInputStream; +import java.io.ObjectInputStream; +import java.util.List; + +import alisolarflare.tools.links.entities.Link; + +public class Deserializer{ + + public static void main (String args[]) { + + //Deserializer deserializer = new Deserializer(); + //List aliLink = deserializer.loadLink(aliLink); + //System.out.println(aliLink); + } + + @SuppressWarnings("unchecked") + public List loadLinkList(){ + List aliLinkList; + try{ + + FileInputStream fin = new FileInputStream("AliLinkList.ser"); + ObjectInputStream ois = new ObjectInputStream(fin); + aliLinkList = (List) ois.readObject(); + ois.close(); + + return aliLinkList; + + }catch(Exception ex){ + ex.printStackTrace(); + return null; + } + } +} diff --git a/src/alisolarflare/tools/links/serializer/Serializer.java b/src/alisolarflare/tools/links/serializer/Serializer.java index f05ab1b..20b9daa 100644 --- a/src/alisolarflare/tools/links/serializer/Serializer.java +++ b/src/alisolarflare/tools/links/serializer/Serializer.java @@ -1,33 +1,33 @@ -package alisolarflare.links.serializer; - - -import java.io.FileOutputStream; -import java.io.ObjectOutputStream; -import java.util.List; - -import alisolarflare.links.entities.Link; - -public class Serializer { - - public static void main (String args[]) { - - //Serializer serializer = new Serializer(); - //serializer.saveLink(plugin, frequency, location) - } - - public void saveLinkList(List aliLinkList){ - //saves link - - try{ - - FileOutputStream fout = new FileOutputStream("AliLinkList.ser"); - ObjectOutputStream oos = new ObjectOutputStream(fout); - oos.writeObject(aliLinkList); - oos.close(); - System.out.println("Done"); - - }catch(Exception ex){ - ex.printStackTrace(); - } - } +package alisolarflare.tools.links.serializer; + + +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +import alisolarflare.tools.links.entities.Link; + +public class Serializer { + + public static void main (String args[]) { + + //Serializer serializer = new Serializer(); + //serializer.saveLink(plugin, frequency, location) + } + + public void saveLinkList(List aliLinkList){ + //saves link + + try{ + + FileOutputStream fout = new FileOutputStream("AliLinkList.ser"); + ObjectOutputStream oos = new ObjectOutputStream(fout); + oos.writeObject(aliLinkList); + oos.close(); + System.out.println("Done"); + + }catch(Exception ex){ + ex.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/alisolarflare/tools/links/tasks/UnpressTask.java b/src/alisolarflare/tools/links/tasks/UnpressTask.java index c65c76f..79a457c 100644 --- a/src/alisolarflare/tools/links/tasks/UnpressTask.java +++ b/src/alisolarflare/tools/links/tasks/UnpressTask.java @@ -1,21 +1,21 @@ -package alisolarflare.links.tasks; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.scheduler.BukkitRunnable; - -public class UnpressTask extends BukkitRunnable { - private Location location; - public UnpressTask(Location location){ - this.location = location; - } - - @SuppressWarnings("deprecation") - @Override - public void run() { - location.getBlock().setType(Material.STAINED_CLAY); - location.getBlock().setData((byte) 14); - this.cancel(); - } - -} +package alisolarflare.tools.links.tasks; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.scheduler.BukkitRunnable; + +public class UnpressTask extends BukkitRunnable { + private Location location; + public UnpressTask(Location location){ + this.location = location; + } + + @SuppressWarnings("deprecation") + @Override + public void run() { + location.getBlock().setType(Material.STAINED_CLAY); + location.getBlock().setData((byte) 14); + this.cancel(); + } + +} diff --git a/src/alisolarflare/tools/shulker/AliShulker.java b/src/alisolarflare/tools/shulker/AliShulker.java index 6f503a9..0bd2534 100644 --- a/src/alisolarflare/tools/shulker/AliShulker.java +++ b/src/alisolarflare/tools/shulker/AliShulker.java @@ -1,4 +1,4 @@ -package alisolarflare.shulker; +package alisolarflare.tools.shulker; import org.bukkit.Location; import org.bukkit.command.Command;