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

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.CommandExecutor;

View file

@ -1,4 +1,4 @@
package alisolarflare.uhc;
package alisolarflare.events.uhc;
import java.util.ArrayList;
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 {
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();
}
}

View file

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

View file

@ -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(){
}
}

View file

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

View file

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

View file

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

View file

@ -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<String,Location> portalMap = new HashMap<String,Location>();
public static List<String> playersToBeFlaired = new ArrayList<String>();
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<String,Location> portalMap = new HashMap<String,Location>();
public static List<String> playersToBeFlaired = new ArrayList<String>();
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());
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -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<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//POWER ACTIVATION
public static void PowerUpPlayer(Player player, String colour){
//debug("POWERRRED UP");
player.sendMessage("POWERRED UP!");
PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
public static void PowerUpPlayer(Player player){
//debug("POWERRRED UP");
player.sendMessage("POWERRED UP!");
if(PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = true;
}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<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//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<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//POWER ACTIVATION
public static void PowerUpPlayer(Player player, String colour){
//debug("POWERRRED UP");
player.sendMessage("POWERRED UP!");
PlayerMap.put(player.getUniqueId(), new poweredPlayer(player.getUniqueId(), colour, true));
}
public static void PowerUpPlayer(Player player){
//debug("POWERRRED UP");
player.sendMessage("POWERRED UP!");
if(PlayerMap.containsKey(player.getUniqueId())){
PlayerMap.get(player.getUniqueId()).isPowersActive = true;
}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<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//for (UUID uuidKey:PlayerMap.keySet()){
//UUID uuidToSave = poweredPlayer.uuid;
//}
}
public void loadMemoryState(){
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -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 <frequency> [x] [y] [z]. This command creates an Ali-Link,

View file

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

View file

@ -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<Link> aliLink = deserializer.loadLink(aliLink);
//System.out.println(aliLink);
}
@SuppressWarnings("unchecked")
public List<Link> loadLinkList(){
List<Link> aliLinkList;
try{
FileInputStream fin = new FileInputStream("AliLinkList.ser");
ObjectInputStream ois = new ObjectInputStream(fin);
aliLinkList = (List<Link>) 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<Link> aliLink = deserializer.loadLink(aliLink);
//System.out.println(aliLink);
}
@SuppressWarnings("unchecked")
public List<Link> loadLinkList(){
List<Link> aliLinkList;
try{
FileInputStream fin = new FileInputStream("AliLinkList.ser");
ObjectInputStream ois = new ObjectInputStream(fin);
aliLinkList = (List<Link>) ois.readObject();
ois.close();
return aliLinkList;
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}
}

View file

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

View file

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

View file

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