Begun work on Object Orientating my classes, so that things are more

organized
This commit is contained in:
alisolarflare 2016-10-31 00:12:40 -04:00
parent e10a5fea0f
commit 50107bff81
27 changed files with 886 additions and 826 deletions

View file

@ -1,55 +1,55 @@
package alisolarflare; package alisolarflare;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
//import alisolarflare.links.AliLinkSubPlug;
import alisolarflare.flairdoors.FlairMe; import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.flairdoors.PortalListener;
import alisolarflare.flairdoors.SetFlairDoorColour; import alisolarflare.magictrick.aliarrow.AliArrowSubPlugin;
import alisolarflare.gpowers.gPowerCommand; import alisolarflare.tools.flairdoors.FlairMe;
import alisolarflare.gpowers.commands.PowerDown; import alisolarflare.tools.flairdoors.PortalListener;
import alisolarflare.gpowers.commands.PowerUp; import alisolarflare.tools.flairdoors.SetFlairDoorColour;
import alisolarflare.gpowers.listeners.gPowerListener; import alisolarflare.tools.gpowers.gPowerCommand;
import alisolarflare.tools.gpowers.commands.PowerDown;
//import alisolarflare.links.AliLinkSubPlug; import alisolarflare.tools.gpowers.commands.PowerUp;
import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.tools.gpowers.listeners.gPowerListener;
import alisolarflare.shulker.AliShulker; import alisolarflare.tools.shulker.AliShulker;
import alisolarflare.aliarrow.AliArrowSubPlugin;
public class AliPresents extends JavaPlugin{
public class AliPresents extends JavaPlugin{ public void onEnable(){
public void onEnable(){ PluginDescriptionFile pdfFile = getDescription();
PluginDescriptionFile pdfFile = getDescription(); Logger logger = getLogger();
Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
registerModules();
registerSubPlugins(); registerCommands();
registerCommands(); registerEvents();
registerEvents();
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
}
} private void registerEvents() {
private void registerEvents() { getServer().getPluginManager().registerEvents(new PortalListener(this), this);
getServer().getPluginManager().registerEvents(new PortalListener(this), this); getServer().getPluginManager().registerEvents(new gPowerListener(this), this);
getServer().getPluginManager().registerEvents(new gPowerListener(this), this); }
} public void registerModules(){
public void registerSubPlugins(){ new AliArrowSubPlugin(this).register();
AliArrowSubPlugin aliArrowSubPlugin = new AliArrowSubPlugin(this);
aliArrowSubPlugin.register();
//AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this); //AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this);
//alilinksubplugin.register(); //alilinksubplugin.register();
} }
public void registerCommands(){ public void registerCommands(){
getCommand("powerup").setExecutor(new PowerUp()); getCommand("powerup").setExecutor(new PowerUp());
getCommand("powerdown").setExecutor(new PowerDown()); getCommand("powerdown").setExecutor(new PowerDown());
getCommand("gpowercommand").setExecutor(new gPowerCommand()); getCommand("gpowercommand").setExecutor(new gPowerCommand());
getCommand("flairme").setExecutor(new FlairMe()); getCommand("flairme").setExecutor(new FlairMe());
getCommand("alishulker").setExecutor(new AliShulker()); getCommand("alishulker").setExecutor(new AliShulker());
getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour()); getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour());
} }
} }

View file

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

View file

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

View file

@ -1,4 +1,4 @@
package alisolarflare.uhc; package alisolarflare.events.uhc;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View file

@ -1,4 +1,4 @@
package alisolarflare.uhc; package alisolarflare.events.uhc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -1,27 +1,24 @@
package alisolarflare.uhc; package alisolarflare.events.uhc;
import alisolarflare.AliPresents; import org.bukkit.plugin.java.JavaPlugin;
public class UHCSubPlugin { import alisolarflare.Module;
public AliPresents plugin;
public class UHCModule extends Module {
public UHCMatch generalMemory; public UHCMatch generalMemory;
public UHCSubPlugin(AliPresents plugin){ public void register(JavaPlugin plugin){
this.plugin = plugin; registerCommands(plugin);
registerListeners(plugin);
registerMemoryUnits(plugin);
} }
public void register(){ private void registerListeners(JavaPlugin plugin) {
registerCommands();
registerListeners();
registerMemoryUnits();
} }
private void registerListeners() { private void registerCommands(JavaPlugin plugin) {
}
private void registerCommands() {
// TODO Auto-generated method stub // 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(); generalMemory = new UHCMatch();
} }
} }

View file

@ -1,45 +1,46 @@
package alisolarflare.aliarrow; package alisolarflare.magictrick.aliarrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class AliArrowListener implements Listener { public class AliArrowListener implements Listener {
private final AliPresents plugin; private final AliPresents plugin;
public AliArrowListener(AliPresents plugin){ public AliArrowListener(AliPresents plugin){
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler @SuppressWarnings("deprecation")
public void onProjectileLaunch(ProjectileLaunchEvent event){ @EventHandler
try{ public void onProjectileLaunch(ProjectileLaunchEvent event){
if(!(event.getEntity().getType() == EntityType.ARROW)){ try{
return; if(!(event.getEntity().getType() == EntityType.ARROW)){
} return;
Projectile projectile = event.getEntity(); }
Arrow arrow = (Arrow) projectile; Projectile projectile = event.getEntity();
if (!(arrow.isCritical())){ Arrow arrow = (Arrow) projectile;
return; if (!(arrow.isCritical())){
} return;
if (projectile.getShooter().equals(plugin.getServer().getPlayer("alisolarflare"))){ }
AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"alisolarflare"); if (projectile.getShooter().equals(plugin.getServer().getPlayer("alisolarflare"))){
aliArrowTask.runTaskTimer(plugin, 2, 1); AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"alisolarflare");
return; aliArrowTask.runTaskTimer(plugin, 2, 1);
}else if (projectile.getShooter().equals(plugin.getServer().getPlayer("Zanthr"))){ return;
AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"zanthr"); }else if (projectile.getShooter().equals(plugin.getServer().getPlayer("Zanthr"))){
aliArrowTask.runTaskTimer(plugin, 2, 1); AliArrowTask aliArrowTask = new AliArrowTask(plugin,arrow,"zanthr");
return; aliArrowTask.runTaskTimer(plugin, 2, 1);
} return;
return; }
return;
}catch(Exception e){
return; }catch(Exception e){
} return;
} }
}
} }

View file

@ -1,25 +1,27 @@
package alisolarflare.aliarrow; package alisolarflare.magictrick.aliarrow;
import java.util.logging.Level; import java.util.logging.Level;
import alisolarflare.AliPresents;
import alisolarflare.AliPresents;
public class AliArrowSubPlugin {
public class AliArrowSubPlugin { private AliPresents plugin;
private AliPresents plugin;
public AliArrowSubPlugin(AliPresents plugin){
public AliArrowSubPlugin(AliPresents plugin){ this.plugin = plugin;
this.plugin = plugin; }
} /**
public void register(){ * Registers the plugin, activating listeners, commands, and events
registerEvents(); */
registerCommands(); public void register(){
plugin.getLogger().log(Level.INFO, "Discord Sub Plugin Registered!"); registerEvents();
} registerCommands();
private void registerEvents(){ plugin.getLogger().log(Level.INFO, "Discord Sub Plugin Registered!");
plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); }
private void registerEvents(){
} plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin);
private void registerCommands(){
}
} private void registerCommands(){
}
}
}

View file

@ -1,40 +1,40 @@
package alisolarflare.aliarrow; package alisolarflare.magictrick.aliarrow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class AliArrowTask extends BukkitRunnable{ public class AliArrowTask extends BukkitRunnable{
AliPresents plugin; AliPresents plugin;
String name; String name;
Arrow arrow; Arrow arrow;
public AliArrowTask(AliPresents plugin, Arrow arrow, String name){ public AliArrowTask(AliPresents plugin, Arrow arrow, String name){
this.name = name; this.name = name;
this.plugin = plugin; this.plugin = plugin;
this.arrow = arrow; this.arrow = arrow;
} }
@Override @Override
public void run() { public void run() {
if (arrow.isOnGround() || arrow.isDead()){ if (arrow.isOnGround() || arrow.isDead()){
this.cancel(); this.cancel();
} }
if (name.equalsIgnoreCase("alisolarflare")){ if (name.equalsIgnoreCase("alisolarflare")){
arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1); arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1);
} }
if (name.equalsIgnoreCase("Zanthr")){ if (name.equalsIgnoreCase("Zanthr")){
arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1); arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1);
arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1);
} }
} }
} }

View file

@ -1,22 +1,22 @@
package alisolarflare.flairdoors; package alisolarflare.tools.flairdoors;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class FlairDoorsSubPlug{ public class FlairDoorsSubPlug{
@SuppressWarnings("unused") @SuppressWarnings("unused")
private AliPresents plugin; private AliPresents plugin;
public FlairDoorsSubPlug(AliPresents plugin){ public FlairDoorsSubPlug(AliPresents plugin){
this.plugin = plugin; this.plugin = plugin;
} }
public void register(){ public void register(){
registerCommands(); registerCommands();
registerEvents(); registerEvents();
} }
private void registerCommands() { private void registerCommands() {
//plugin.getCommand("FlairMe").setExecutor(new FlairMe()); //plugin.getCommand("FlairMe").setExecutor(new FlairMe());
} }
private void registerEvents() { private void registerEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

View file

@ -1,18 +1,18 @@
package alisolarflare.flairdoors; package alisolarflare.tools.flairdoors;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class FlairMe implements CommandExecutor{ public class FlairMe implements CommandExecutor{
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage("Flairing..." + sender.getName()); sender.sendMessage("Flairing..." + sender.getName());
PortalListener.playersToBeFlaired.add(sender.getName()); PortalListener.playersToBeFlaired.add(sender.getName());
sender.sendMessage("Finished Preparation! Walk through a portal to get your flair"); sender.sendMessage("Finished Preparation! Walk through a portal to get your flair");
return false; return false;
} }
} }

View file

@ -1,144 +1,144 @@
package alisolarflare.flairdoors; package alisolarflare.tools.flairdoors;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.material.Wool; import org.bukkit.material.Wool;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class PortalListener implements Listener{ public class PortalListener implements Listener{
AbstractMap<String,Location> portalMap = new HashMap<String,Location>(); AbstractMap<String,Location> portalMap = new HashMap<String,Location>();
public static List<String> playersToBeFlaired = new ArrayList<String>(); public static List<String> playersToBeFlaired = new ArrayList<String>();
public AliPresents plugin; public AliPresents plugin;
//TODO: CREATE - LIST OF PORTALS (only x-z values) //TODO: CREATE - LIST OF PORTALS (only x-z values)
public PortalListener(AliPresents plugin) { public PortalListener(AliPresents plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler @EventHandler
public void onPortalEnter(PlayerPortalEvent event){ public void onPortalEnter(PlayerPortalEvent event){
//SANITATION - Player //SANITATION - Player
if(!(event.getPlayer() instanceof Player)){ if(!(event.getPlayer() instanceof Player)){
return; return;
} }
//INIT - Player //INIT - Player
Player player = event.getPlayer(); Player player = event.getPlayer();
player.sendMessage("MAY THE FLAIRING COMMENCE"); player.sendMessage("MAY THE FLAIRING COMMENCE");
//SANITATION - PlayersToBeFlaired //SANITATION - PlayersToBeFlaired
if(!(playersToBeFlaired.contains(player.getName()))){ if(!(playersToBeFlaired.contains(player.getName()))){
return; return;
} }
player.sendMessage("-MAY THE FLAIRING COMMENCE-"); player.sendMessage("-MAY THE FLAIRING COMMENCE-");
player.sendMessage("Deactivating regular portal behaviour..."); player.sendMessage("Deactivating regular portal behaviour...");
event.setTo(player.getLocation()); event.setTo(player.getLocation());
//INIT - x,y,z //INIT - x,y,z
int x = player.getLocation().getBlockX(); int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY(); int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ(); int z = player.getLocation().getBlockZ();
//INIT - Blocks Under Portal //INIT - Blocks Under Portal
Block blockTopper = player.getWorld().getBlockAt(x,y-1,z); Block blockTopper = player.getWorld().getBlockAt(x,y-1,z);
Block blockMiddle = player.getWorld().getBlockAt(x,y-2,z); Block blockMiddle = player.getWorld().getBlockAt(x,y-2,z);
Block blockBottom = player.getWorld().getBlockAt(x,y-3,z); Block blockBottom = player.getWorld().getBlockAt(x,y-3,z);
player.sendMessage("Blocks being inspected:"); player.sendMessage("Blocks being inspected:");
player.sendMessage(blockTopper.toString()); player.sendMessage(blockTopper.toString());
player.sendMessage(blockMiddle.toString()); player.sendMessage(blockMiddle.toString());
player.sendMessage(blockBottom.toString()); player.sendMessage(blockBottom.toString());
//RECOLOUR PLAYER //RECOLOUR PLAYER
if(blockTopper.getType() == Material.STONE){ if(blockTopper.getType() == Material.STONE){
player.sendMessage("STONE DETECTED"); player.sendMessage("STONE DETECTED");
recolourPlayer(player, DyeColor.GRAY); recolourPlayer(player, DyeColor.GRAY);
//TOP BLOCK IS WOOL? //TOP BLOCK IS WOOL?
}else if(blockTopper.getType() == Material.WOOL){ }else if(blockTopper.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED T"); player.sendMessage("WOOL DETECTED T");
Wool wool = (Wool) blockTopper.getState().getData(); Wool wool = (Wool) blockTopper.getState().getData();
recolourPlayer(player, wool.getColor()); recolourPlayer(player, wool.getColor());
//MIDDLE BLOCK IS WOOL? //MIDDLE BLOCK IS WOOL?
}else if(blockMiddle.getType() == Material.WOOL){ }else if(blockMiddle.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED M"); player.sendMessage("WOOL DETECTED M");
MaterialData mData = blockMiddle.getState().getData(); MaterialData mData = blockMiddle.getState().getData();
player.sendMessage("MATERIAL DATA COLLECTED: "+ mData.toString()); player.sendMessage("MATERIAL DATA COLLECTED: "+ mData.toString());
Wool wool = (Wool) mData; Wool wool = (Wool) mData;
player.sendMessage("WOOL DATA CONVERTED: "+ wool.toString()); player.sendMessage("WOOL DATA CONVERTED: "+ wool.toString());
recolourPlayer(player, wool.getColor()); recolourPlayer(player, wool.getColor());
//BOTTOM BLOCK IS WOOL? //BOTTOM BLOCK IS WOOL?
}else if (blockBottom.getType() == Material.WOOL){ }else if (blockBottom.getType() == Material.WOOL){
player.sendMessage("WOOL DETECTED B"); player.sendMessage("WOOL DETECTED B");
Wool wool = (Wool) blockBottom.getState().getData(); Wool wool = (Wool) blockBottom.getState().getData();
recolourPlayer(player, wool.getColor()); recolourPlayer(player, wool.getColor());
} }
} }
public void recolourPlayer(Player player, DyeColor dyecolour){ public void recolourPlayer(Player player, DyeColor dyecolour){
player.sendMessage("Recolouring Player as..." + dyecolour.toString()); player.sendMessage("Recolouring Player as..." + dyecolour.toString());
String name = player.getName(); String name = player.getName();
player.sendMessage("name:" + name); player.sendMessage("name:" + name);
for(int i = 0; i < name.length(); i++){ for(int i = 0; i < name.length(); i++){
if (name.charAt(i) == '&'){ if (name.charAt(i) == '&'){
//TODO: Remove all &* symbols //TODO: Remove all &* symbols
name = name.substring(0, i) + name.substring(i + 1, name.length()); name = name.substring(0, i) + name.substring(i + 1, name.length());
} }
} }
player.sendMessage("Adjusted Name: " + name); player.sendMessage("Adjusted Name: " + name);
if(dyecolour == DyeColor.GRAY){ if(dyecolour == DyeColor.GRAY){
player.sendMessage("Adding GRAY"); player.sendMessage("Adding GRAY");
player.setCustomName("&7" + name); player.setCustomName("&7" + name);
}else if(dyecolour == DyeColor.RED){ }else if(dyecolour == DyeColor.RED){
player.sendMessage("Adding RED"); player.sendMessage("Adding RED");
player.setCustomName("&4" + name); player.setCustomName("&4" + name);
}else if(dyecolour == DyeColor.ORANGE){ }else if(dyecolour == DyeColor.ORANGE){
player.sendMessage("Adding ORANGE"); player.sendMessage("Adding ORANGE");
player.setCustomName("&6" + name); player.setCustomName("&6" + name);
}else if(dyecolour == DyeColor.YELLOW){ }else if(dyecolour == DyeColor.YELLOW){
player.sendMessage("Adding YELLOW"); player.sendMessage("Adding YELLOW");
player.setCustomName("&e" + name); player.setCustomName("&e" + name);
}else if(dyecolour == DyeColor.GREEN){ }else if(dyecolour == DyeColor.GREEN){
player.sendMessage("Adding GREEN"); player.sendMessage("Adding GREEN");
player.setCustomName("&a" + name); player.setCustomName("&a" + name);
}else if(dyecolour == DyeColor.BLUE){ }else if(dyecolour == DyeColor.BLUE){
player.sendMessage("Adding BLUE"); player.sendMessage("Adding BLUE");
player.setCustomName("&9" + name); player.setCustomName("&9" + name);
}else if(dyecolour == DyeColor.PURPLE){ }else if(dyecolour == DyeColor.PURPLE){
player.sendMessage("Adding PURPLE"); player.sendMessage("Adding PURPLE");
player.setCustomName("&5" + name); player.setCustomName("&5" + name);
}else{ }else{
player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK"); player.sendMessage("ERROR, PORTAL HAS INVALID UNDER-BLOCK");
return; return;
} }
player.sendMessage("Your name is now: " + player.getCustomName() +"! Removing you from playersToBeFlaired..."); player.sendMessage("Your name is now: " + player.getCustomName() +"! Removing you from playersToBeFlaired...");
playersToBeFlaired.remove(player.getName()); playersToBeFlaired.remove(player.getName());
} }
} }

View file

@ -1,48 +1,48 @@
package alisolarflare.flairdoors; package alisolarflare.tools.flairdoors;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class SetFlairDoorColour implements CommandExecutor { public class SetFlairDoorColour implements CommandExecutor {
public static String FlairDoorColorMode = "null"; public static String FlairDoorColorMode = "null";
public static final List<String> COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray"); public static final List<String> COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray");
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 1){ if (args.length > 1){
sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA"); sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA");
} }
String firstCommand = args[0]; String firstCommand = args[0];
firstCommand = firstCommand.toLowerCase(); firstCommand = firstCommand.toLowerCase();
if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){
sender.sendMessage("Flair Door Colour Mode set to gray"); sender.sendMessage("Flair Door Colour Mode set to gray");
FlairDoorColorMode = "gray"; FlairDoorColorMode = "gray";
}else if(firstCommand.startsWith("r")){ }else if(firstCommand.startsWith("r")){
sender.sendMessage("Flair Door Colour Mode set to Red"); sender.sendMessage("Flair Door Colour Mode set to Red");
FlairDoorColorMode = "red"; FlairDoorColorMode = "red";
}else if(firstCommand.startsWith("o")){ }else if(firstCommand.startsWith("o")){
sender.sendMessage("Flair Door Colour Mode set to Orange"); sender.sendMessage("Flair Door Colour Mode set to Orange");
FlairDoorColorMode = "orange"; FlairDoorColorMode = "orange";
}else if(firstCommand.startsWith("y")){ }else if(firstCommand.startsWith("y")){
sender.sendMessage("Flair Door Colour Mode set to Yellow"); sender.sendMessage("Flair Door Colour Mode set to Yellow");
FlairDoorColorMode = "yellow"; FlairDoorColorMode = "yellow";
}else if(firstCommand.startsWith("g")){ }else if(firstCommand.startsWith("g")){
sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)"); sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)");
FlairDoorColorMode = "green"; FlairDoorColorMode = "green";
}else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){ }else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){
sender.sendMessage("Flair Door Colour Mode set to Blue"); sender.sendMessage("Flair Door Colour Mode set to Blue");
FlairDoorColorMode = "blue"; FlairDoorColorMode = "blue";
}else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){ }else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){
sender.sendMessage("Flair Door Colour Mode set to Purple"); sender.sendMessage("Flair Door Colour Mode set to Purple");
FlairDoorColorMode = "purple"; FlairDoorColorMode = "purple";
}else if(firstCommand.startsWith("n")){ }else if(firstCommand.startsWith("n")){
sender.sendMessage("Flair Door Colour Mode set to Null"); sender.sendMessage("Flair Door Colour Mode set to Null");
FlairDoorColorMode = "null"; FlairDoorColorMode = "null";
} }
return false; return false;
} }
} }

View file

@ -1,15 +1,15 @@
package alisolarflare.gpowers.commands; package alisolarflare.tools.gpowers.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class PowerDown implements CommandExecutor { public class PowerDown implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
} }

View file

@ -1,20 +1,20 @@
package alisolarflare.gpowers.commands; package alisolarflare.tools.gpowers.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class PowerUp implements CommandExecutor{ public class PowerUp implements CommandExecutor{
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)){ if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!"); sender.sendMessage("You must be a player to use this command!");
} }
//gPowerMemory.PowerUpPlayer(player, colour); //gPowerMemory.PowerUpPlayer(player, colour);
return false; return false;
} }
} }

View file

@ -1,56 +1,56 @@
package alisolarflare.gpowers; package alisolarflare.tools.gpowers;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class gPowerCommand implements CommandExecutor{ public class gPowerCommand implements CommandExecutor{
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage("G power activate!"); sender.sendMessage("G power activate!");
if (!(sender instanceof Player)){ if (!(sender instanceof Player)){
sender.sendMessage("You must be a player to use this command!"); sender.sendMessage("You must be a player to use this command!");
return false; return false;
} }
Player player = (Player) sender; Player player = (Player) sender;
if (args.length < 2){ if (args.length < 2){
player.sendMessage("Proper Usage to test G-Powers:"); player.sendMessage("Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
return false; return false;
} }
String colour; String colour;
player.sendMessage("Checking terms..."); player.sendMessage("Checking terms...");
if(args[0].startsWith("r") || if(args[0].startsWith("r") ||
args[0].startsWith("o")|| args[0].startsWith("o")||
args[0].startsWith("y")|| args[0].startsWith("y")||
args[0].startsWith("g")|| args[0].startsWith("g")||
args[0].startsWith("b")|| args[0].startsWith("b")||
args[0].startsWith("p")){ args[0].startsWith("p")){
colour = args[0]; colour = args[0];
}else{ }else{
player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:"); player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
return false; return false;
} }
boolean isActive; boolean isActive;
if(args[1].startsWith("t")){ if(args[1].startsWith("t")){
isActive = true; isActive = true;
}else if (args[1].startsWith("f")){ }else if (args[1].startsWith("f")){
isActive = false; isActive = false;
}else{ }else{
player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:"); player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:");
player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]");
return false; return false;
} }
player.sendMessage("Terms Vaild!"); player.sendMessage("Terms Vaild!");
if(isActive){ if(isActive){
gPowerMemory.PowerUpPlayer(player, colour); gPowerMemory.PowerUpPlayer(player, colour);
}else{ }else{
gPowerMemory.PowerDownPlayer(player); gPowerMemory.PowerDownPlayer(player);
} }
return false; return false;
} }
} }

View file

@ -1,101 +1,102 @@
package alisolarflare.gpowers; package alisolarflare.tools.gpowers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class gPowerMemory{ public class gPowerMemory{
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static AliPresents plugin; private static AliPresents plugin;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static boolean debugMode = true; private static boolean debugMode = true;
public gPowerMemory(AliPresents plugin){ public gPowerMemory(AliPresents plugin){
gPowerMemory.plugin = plugin; gPowerMemory.plugin = plugin;
} }
//SHORT TERM MEMORY STORAGE //SHORT TERM MEMORY STORAGE
public static Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>(); public static Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//POWER ACTIVATION //POWER ACTIVATION
public static void PowerUpPlayer(Player player, String colour){ public static void PowerUpPlayer(Player player, String colour){
//debug("POWERRRED UP"); //debug("POWERRRED UP");
player.sendMessage("POWERRED UP!"); player.sendMessage("POWERRED UP!");
PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true)); PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
} }
public static void PowerUpPlayer(Player player){ public static void PowerUpPlayer(Player player){
//debug("POWERRRED UP"); //debug("POWERRRED UP");
player.sendMessage("POWERRED UP!"); player.sendMessage("POWERRED UP!");
if(PlayerMap.containsKey(player.getUniqueId())){ if(PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = true; 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 /gpowercommand");
} }
} }
//POWER DEACTIVATION //POWER DEACTIVATION
public static void PowerDownPlayer(Player player){ public static void PowerDownPlayer(Player player){
//debug("POWERRRED DOWN"); //debug("POWERRRED DOWN");
if (PlayerMap.containsKey(player.getUniqueId())){ if (PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = false; PlayerMap.get(player.getUniqueId()).isPowersActive = false;
}else{ }else{
return; return;
} }
} }
public static void PowerDownPlayer(UUID UniqueID){ public static void PowerDownPlayer(UUID UniqueID){
//debug("POWEERRED DOWN"); //debug("POWEERRED DOWN");
if (PlayerMap.containsKey(UniqueID)){ if (PlayerMap.containsKey(UniqueID)){
PlayerMap.get(UniqueID).isPowersActive = false; PlayerMap.get(UniqueID).isPowersActive = false;
}else{ }else{
return; return;
} }
} }
public static boolean isPlayerPowered(UUID UniqueID){ public static boolean isPlayerPowered(UUID UniqueID){
//debug("IS PLAYER POWERED?"); //debug("IS PLAYER POWERED?");
if (PlayerMap.containsKey(UniqueID)){ if (PlayerMap.containsKey(UniqueID)){
return PlayerMap.get(UniqueID).isPowersActive; return PlayerMap.get(UniqueID).isPowersActive;
}else{ }else{
return false; return false;
} }
} }
public static boolean isPlayerPowered(Player player){ public static boolean isPlayerPowered(Player player){
//debug("IS PLAYER POWERED?"); //debug("IS PLAYER POWERED?");
if (PlayerMap.containsKey(player.getUniqueId())){ if (PlayerMap.containsKey(player.getUniqueId())){
return PlayerMap.get(player.getUniqueId()).isPowersActive; return PlayerMap.get(player.getUniqueId()).isPowersActive;
}else{ }else{
return false; return false;
} }
} }
//MEMORY UNIT //MEMORY UNIT
public static class poweredPlayer{ public static class poweredPlayer{
public static UUID uuid; public static UUID uuid;
public String colour; public String colour;
public Boolean isPowersActive; public Boolean isPowersActive;
@SuppressWarnings("static-access") @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);
this.isPowersActive = (activated); this.isPowersActive = (activated);
} }
public String toString(){ public String toString(){
return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]"; return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+isPowersActive + "]";
} }
} }
public void saveMemoryState(){ public void saveMemoryState(){
Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>(); @SuppressWarnings("unused")
//for (UUID uuidKey:PlayerMap.keySet()){ Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//for (UUID uuidKey:PlayerMap.keySet()){
//UUID uuidToSave = poweredPlayer.uuid;
//UUID uuidToSave = poweredPlayer.uuid;
//}
} //}
public void loadMemoryState(){ }
public void loadMemoryState(){
}
} }
}

View file

@ -1,53 +1,53 @@
package alisolarflare.gpowers.listeners; package alisolarflare.tools.gpowers.listeners;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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.AliPresents; import alisolarflare.AliPresents;
import alisolarflare.gpowers.gPowerMemory; import alisolarflare.tools.gpowers.gPowerMemory;
public class gPowerApplyingTask extends BukkitRunnable{ public class gPowerApplyingTask extends BukkitRunnable{
private AliPresents plugin; private AliPresents plugin;
public gPowerApplyingTask(AliPresents plugin) { public gPowerApplyingTask(AliPresents plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
//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 : plugin.getServer().getOnlinePlayers()){
if(gPowerMemory.PlayerMap.containsKey(player.getUniqueId())){ if(gPowerMemory.PlayerMap.containsKey(player.getUniqueId())){
activatePower(player, gPowerMemory.PlayerMap.get(player.getUniqueId()).colour); activatePower(player, gPowerMemory.PlayerMap.get(player.getUniqueId()).colour);
} }
} }
} }
private void activatePower(Player player, String colour) { private void activatePower(Player player, String colour) {
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));
}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));
}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));
}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));
}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));
}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));
}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));
}else{ }else{
} }
} }
} }

View file

@ -1,31 +1,31 @@
package alisolarflare.gpowers.listeners; package alisolarflare.tools.gpowers.listeners;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
public class gPowerListener implements Listener{ public class gPowerListener implements Listener{
private AliPresents plugin; private AliPresents plugin;
public gPowerApplyingTask powerApplyingTask; public gPowerApplyingTask powerApplyingTask;
public BukkitTask bukkitTask; public BukkitTask bukkitTask;
public gPowerListener(AliPresents plugin){ public gPowerListener(AliPresents plugin){
this.plugin = plugin; this.plugin = plugin;
this.powerApplyingTask = new gPowerApplyingTask(this.plugin); this.powerApplyingTask = new gPowerApplyingTask(this.plugin);
bukkitTask = powerApplyingTask.runTaskTimer(plugin, 190, 190); bukkitTask = powerApplyingTask.runTaskTimer(plugin, 190, 190);
} }
} }
/* /*
* public class CyclicalDisplayListener implements Listener{ * public class CyclicalDisplayListener implements Listener{
private final ButtonRebirthPlugin plugin; private final ButtonRebirthPlugin plugin;
public CyclicalDisplayTask cyclicalDisplayTask; public CyclicalDisplayTask cyclicalDisplayTask;
public BukkitTask bukkitTask; public BukkitTask bukkitTask;
public CyclicalDisplayListener (ButtonRebirthPlugin initPlugin){ public CyclicalDisplayListener (ButtonRebirthPlugin initPlugin){
plugin = initPlugin; plugin = initPlugin;
cyclicalDisplayTask = new CyclicalDisplayTask (this.plugin); cyclicalDisplayTask = new CyclicalDisplayTask (this.plugin);
bukkitTask = cyclicalDisplayTask.runTaskTimer(this.plugin, 20, 20); bukkitTask = cyclicalDisplayTask.runTaskTimer(this.plugin, 20, 20);
} }
} }
*/ */

View file

@ -1,10 +1,10 @@
package alisolarflare.links; package alisolarflare.tools.links;
import java.util.List; import java.util.List;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
import alisolarflare.links.commands.PressAliLink; import alisolarflare.tools.links.commands.PressAliLink;
import alisolarflare.links.commands.SetAliLink; import alisolarflare.tools.links.commands.SetAliLink;
import alisolarflare.links.entities.Link; import alisolarflare.tools.links.entities.Link;
public class AliLinkSubPlug{ public class AliLinkSubPlug{
public AliPresents plugin; public AliPresents plugin;

View file

@ -1,11 +1,11 @@
package alisolarflare.links.commands; package alisolarflare.tools.links.commands;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import alisolarflare.links.AliLinkSubPlug; import alisolarflare.tools.links.AliLinkSubPlug;
import alisolarflare.links.entities.Link; import alisolarflare.tools.links.entities.Link;
public class PressAliLink implements CommandExecutor{ public class PressAliLink implements CommandExecutor{
private AliLinkSubPlug subplugin; private AliLinkSubPlug subplugin;

View file

@ -1,4 +1,4 @@
package alisolarflare.links.commands; package alisolarflare.tools.links.commands;
import java.util.ArrayList; import java.util.ArrayList;
@ -12,8 +12,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import alisolarflare.AliPresents; import alisolarflare.AliPresents;
import alisolarflare.links.AliLinkSubPlug; import alisolarflare.tools.links.AliLinkSubPlug;
import alisolarflare.links.entities.Link; import alisolarflare.tools.links.entities.Link;
/** /**
* This class manages the command /SetAliLink <frequency> [x] [y] [z]. This command creates an Ali-Link, * This class manages the command /SetAliLink <frequency> [x] [y] [z]. This command creates an Ali-Link,

View file

@ -1,37 +1,37 @@
package alisolarflare.links.entities; package alisolarflare.tools.links.entities;
import java.io.Serializable; import java.io.Serializable;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import alisolarflare.links.AliLinkSubPlug; import alisolarflare.tools.links.AliLinkSubPlug;
import alisolarflare.links.tasks.UnpressTask; import alisolarflare.tools.links.tasks.UnpressTask;
public class Link implements Serializable{ public class Link implements Serializable{
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public String frequency; public String frequency;
public String world; public String world;
public String x; public String x;
public String y; public String y;
public String z; public String z;
public Link(String frequency, Location location){ public Link(String frequency, Location location){
this.frequency = frequency; this.frequency = frequency;
this.world = location.getWorld().getName(); this.world = location.getWorld().getName();
this.x = "" + location.getBlockX(); this.x = "" + location.getBlockX();
this.y = "" + location.getBlockY(); this.y = "" + location.getBlockY();
this.z = "" + location.getBlockZ(); this.z = "" + location.getBlockZ();
//plugin.plugin.getConfig().set("frequency", 10); //plugin.plugin.getConfig().set("frequency", 10);
} }
public void press(AliLinkSubPlug plugin) { public void press(AliLinkSubPlug plugin) {
Location location = new Location(plugin.plugin.getServer().getWorld(world), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z)); Location location = new Location(plugin.plugin.getServer().getWorld(world), Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z));
location.getBlock().setType(Material.REDSTONE_BLOCK); location.getBlock().setType(Material.REDSTONE_BLOCK);
UnpressTask unPressTask = new UnpressTask(location); UnpressTask unPressTask = new UnpressTask(location);
unPressTask.runTaskTimer(plugin.plugin, 2, 1); unPressTask.runTaskTimer(plugin.plugin, 2, 1);
} }
} }

View file

@ -1,36 +1,36 @@
package alisolarflare.links.serializer; package alisolarflare.tools.links.serializer;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.util.List; import java.util.List;
import alisolarflare.links.entities.Link; import alisolarflare.tools.links.entities.Link;
public class Deserializer{ public class Deserializer{
public static void main (String args[]) { public static void main (String args[]) {
//Deserializer deserializer = new Deserializer(); //Deserializer deserializer = new Deserializer();
//List<Link> aliLink = deserializer.loadLink(aliLink); //List<Link> aliLink = deserializer.loadLink(aliLink);
//System.out.println(aliLink); //System.out.println(aliLink);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Link> loadLinkList(){ public List<Link> loadLinkList(){
List<Link> aliLinkList; List<Link> aliLinkList;
try{ try{
FileInputStream fin = new FileInputStream("AliLinkList.ser"); FileInputStream fin = new FileInputStream("AliLinkList.ser");
ObjectInputStream ois = new ObjectInputStream(fin); ObjectInputStream ois = new ObjectInputStream(fin);
aliLinkList = (List<Link>) ois.readObject(); aliLinkList = (List<Link>) ois.readObject();
ois.close(); ois.close();
return aliLinkList; return aliLinkList;
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();
return null; return null;
} }
} }
} }

View file

@ -1,33 +1,33 @@
package alisolarflare.links.serializer; package alisolarflare.tools.links.serializer;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.List; import java.util.List;
import alisolarflare.links.entities.Link; import alisolarflare.tools.links.entities.Link;
public class Serializer { public class Serializer {
public static void main (String args[]) { public static void main (String args[]) {
//Serializer serializer = new Serializer(); //Serializer serializer = new Serializer();
//serializer.saveLink(plugin, frequency, location) //serializer.saveLink(plugin, frequency, location)
} }
public void saveLinkList(List<Link> aliLinkList){ public void saveLinkList(List<Link> aliLinkList){
//saves link //saves link
try{ try{
FileOutputStream fout = new FileOutputStream("AliLinkList.ser"); FileOutputStream fout = new FileOutputStream("AliLinkList.ser");
ObjectOutputStream oos = new ObjectOutputStream(fout); ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(aliLinkList); oos.writeObject(aliLinkList);
oos.close(); oos.close();
System.out.println("Done"); System.out.println("Done");
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();
} }
} }
} }

View file

@ -1,21 +1,21 @@
package alisolarflare.links.tasks; package alisolarflare.tools.links.tasks;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class UnpressTask extends BukkitRunnable { public class UnpressTask extends BukkitRunnable {
private Location location; private Location location;
public UnpressTask(Location location){ public UnpressTask(Location location){
this.location = location; this.location = location;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void run() { public void run() {
location.getBlock().setType(Material.STAINED_CLAY); location.getBlock().setType(Material.STAINED_CLAY);
location.getBlock().setData((byte) 14); location.getBlock().setData((byte) 14);
this.cancel(); this.cancel();
} }
} }

View file

@ -1,4 +1,4 @@
package alisolarflare.shulker; package alisolarflare.tools.shulker;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;