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

@ -3,19 +3,18 @@ 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;
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(){
@ -25,7 +24,7 @@ public class AliPresents extends JavaPlugin{
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
registerSubPlugins();
registerModules();
registerCommands();
registerEvents();
@ -37,9 +36,10 @@ public class AliPresents extends JavaPlugin{
getServer().getPluginManager().registerEvents(new PortalListener(this), this);
getServer().getPluginManager().registerEvents(new gPowerListener(this), this);
}
public void registerSubPlugins(){
AliArrowSubPlugin aliArrowSubPlugin = new AliArrowSubPlugin(this);
aliArrowSubPlugin.register();
public void registerModules(){
new AliArrowSubPlugin(this).register();
//AliLinkSubPlug alilinksubplugin = new AliLinkSubPlug(this);
//alilinksubplugin.register();
}

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,4 +1,4 @@
package alisolarflare.aliarrow;
package alisolarflare.magictrick.aliarrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
@ -16,6 +16,7 @@ public class AliArrowListener implements Listener {
this.plugin = plugin;
}
@SuppressWarnings("deprecation")
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
try{

View file

@ -1,7 +1,6 @@
package alisolarflare.aliarrow;
package alisolarflare.magictrick.aliarrow;
import java.util.logging.Level;
import alisolarflare.AliPresents;
public class AliArrowSubPlugin {
@ -10,6 +9,9 @@ public class AliArrowSubPlugin {
public AliArrowSubPlugin(AliPresents plugin){
this.plugin = plugin;
}
/**
* Registers the plugin, activating listeners, commands, and events
*/
public void register(){
registerEvents();
registerCommands();

View file

@ -1,4 +1,4 @@
package alisolarflare.aliarrow;
package alisolarflare.magictrick.aliarrow;
import org.bukkit.Particle;
import org.bukkit.entity.Arrow;

View file

@ -1,4 +1,4 @@
package alisolarflare.flairdoors;
package alisolarflare.tools.flairdoors;
import alisolarflare.AliPresents;

View file

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

View file

@ -1,4 +1,4 @@
package alisolarflare.flairdoors;
package alisolarflare.tools.flairdoors;
import java.util.AbstractMap;
import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package alisolarflare.flairdoors;
package alisolarflare.tools.flairdoors;
import java.util.Arrays;
import java.util.List;

View file

@ -1,4 +1,4 @@
package alisolarflare.gpowers.commands;
package alisolarflare.tools.gpowers.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;

View file

@ -1,4 +1,4 @@
package alisolarflare.gpowers.commands;
package alisolarflare.tools.gpowers.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;

View file

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

View file

@ -1,4 +1,4 @@
package alisolarflare.gpowers;
package alisolarflare.tools.gpowers;
import java.util.HashMap;
import java.util.Map;
@ -87,6 +87,7 @@ public class gPowerMemory{
}
public void saveMemoryState(){
@SuppressWarnings("unused")
Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
//for (UUID uuidKey:PlayerMap.keySet()){

View file

@ -1,4 +1,4 @@
package alisolarflare.gpowers.listeners;
package alisolarflare.tools.gpowers.listeners;
import org.bukkit.Color;
import org.bukkit.entity.Player;
@ -7,7 +7,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import alisolarflare.AliPresents;
import alisolarflare.gpowers.gPowerMemory;
import alisolarflare.tools.gpowers.gPowerMemory;
public class gPowerApplyingTask extends BukkitRunnable{

View file

@ -1,4 +1,4 @@
package alisolarflare.gpowers.listeners;
package alisolarflare.tools.gpowers.listeners;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitTask;

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,12 +1,12 @@
package alisolarflare.links.entities;
package alisolarflare.tools.links.entities;
import java.io.Serializable;
import org.bukkit.Location;
import org.bukkit.Material;
import alisolarflare.links.AliLinkSubPlug;
import alisolarflare.links.tasks.UnpressTask;
import alisolarflare.tools.links.AliLinkSubPlug;
import alisolarflare.tools.links.tasks.UnpressTask;
public class Link implements Serializable{
/**

View file

@ -1,11 +1,11 @@
package alisolarflare.links.serializer;
package alisolarflare.tools.links.serializer;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.List;
import alisolarflare.links.entities.Link;
import alisolarflare.tools.links.entities.Link;
public class Deserializer{

View file

@ -1,11 +1,11 @@
package alisolarflare.links.serializer;
package alisolarflare.tools.links.serializer;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.List;
import alisolarflare.links.entities.Link;
import alisolarflare.tools.links.entities.Link;
public class Serializer {

View file

@ -1,4 +1,4 @@
package alisolarflare.links.tasks;
package alisolarflare.tools.links.tasks;
import org.bukkit.Location;
import org.bukkit.Material;

View file

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