diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..0a1dadd --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..8549fe9 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + ButtonPresents + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..f9fe345 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..abec6ca --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..165dff1 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,7 @@ +main: buttondevteam.presents.Main +name: ButtonPresents +version: 0.0.1 + +commands: + hello: + description: A set of Hello World commands and listeners, type in /hello to see subcommands \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..84778c0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + + com.github.tbmcplugins + ButtonPresents + 0.0.1-SNAPSHOT + jar + + ButtonPresents + http://maven.apache.org + + + UTF-8 + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + jcenter + http://jcenter.bintray.com + + + jitpack.io + https://jitpack.io + + + + + org.spigotmc + spigot-api + 1.11-R0.1-SNAPSHOT + + + com.github.TBMCPlugins.ButtonCore + ButtonCore + master-SNAPSHOT + + + junit + junit + 3.8.1 + test + + + diff --git a/src/main/java/buttondevteam/presents/Main.java b/src/main/java/buttondevteam/presents/Main.java new file mode 100644 index 0000000..5026769 --- /dev/null +++ b/src/main/java/buttondevteam/presents/Main.java @@ -0,0 +1,17 @@ +package buttondevteam.presents; + +import java.util.logging.Logger; + +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPlugin; + +public class Main extends JavaPlugin{ + public void onEnable(){ +PluginDescriptionFile pdfFile = getDescription(); + + Logger logger = getLogger(); + logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); + + logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); + } +} diff --git a/src/main/java/buttondevteam/presents/architecture/Component.java b/src/main/java/buttondevteam/presents/architecture/Component.java new file mode 100644 index 0000000..cf79f87 --- /dev/null +++ b/src/main/java/buttondevteam/presents/architecture/Component.java @@ -0,0 +1,70 @@ +package buttondevteam.presents.architecture; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.chat.TBMCChatAPI; +import buttondevteam.presents.architecture.commands.BaseCommand; + +/** + * A Module class allows the compacting of projects into one single package. + * + * Each feature can have its commands and listeners 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 Component{ + /** + * Registers the module, when called by the JavaPlugin class. Call + * registerCommand() and registerListener() within this method. + * + * @param plugin Plugin class called to register commands and listeners + */ + public abstract void register(JavaPlugin plugin); + /** + * Registers a TBMCCommand to the plugin + * @param plugin Main plugin responsible for stuff + * @param label Name of the command in plugin.yml + * @param commandExecutor Custom coded CommandExecutor class + */ + protected void registerCommand(JavaPlugin plugin, BaseCommand commandBase){ + TBMCChatAPI.AddCommand(plugin, commandBase); + //plugin.getCommand(commandBase.getClass().getSimpleName().toString()).setExecutor(commandBase); + } + /** + * Registers a Listener to this plugin + * @param plugin Main plugin responsible for stuff + * @param label Name of the command in plugin.yml + * @param commandExecutor Custom coded CommandExecutor class + */ + protected Listener registerListener(JavaPlugin plugin, Listener listener){ + TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin); + return listener; + } + + public void saveData(FileConfiguration config, String pathToData, Object data){ + config.set("moduledata." + this.getClassName() + "." + pathToData, data); + } + public Object getData(FileConfiguration config, String pathToData, Object data){ + return config.get("moduledata." + this.getClassName() + "." + pathToData, data); + } + + public String getClassName(){ + Class enclosingClass = getClass().getEnclosingClass(); + String className = "nullModule"; + if (enclosingClass != null) { + className = (enclosingClass.getName()); + } else { + className = (getClass().getName()); + } + return className; + } + +} diff --git a/src/main/java/buttondevteam/presents/architecture/commands/BaseCommand.java b/src/main/java/buttondevteam/presents/architecture/commands/BaseCommand.java new file mode 100644 index 0000000..13da81d --- /dev/null +++ b/src/main/java/buttondevteam/presents/architecture/commands/BaseCommand.java @@ -0,0 +1,22 @@ +package buttondevteam.presents.architecture.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import buttondevteam.lib.chat.TBMCCommandBase; + +public abstract class BaseCommand extends TBMCCommandBase implements CommandExecutor{ + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + // TODO Auto-generated method stub + return OnCommand(sender, label, args); + } + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text ask a dev to write one", + "If you're a dev, write the help text you lazy bastard. -Ali" + }; + } +} diff --git a/src/main/java/buttondevteam/presents/architecture/commands/CommandBlockCommand.java b/src/main/java/buttondevteam/presents/architecture/commands/CommandBlockCommand.java new file mode 100644 index 0000000..68943be --- /dev/null +++ b/src/main/java/buttondevteam/presents/architecture/commands/CommandBlockCommand.java @@ -0,0 +1,21 @@ +package buttondevteam.presents.architecture.commands; + +public abstract class CommandBlockCommand extends BaseCommand{ + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text. ", + }; + } + + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/main/java/buttondevteam/presents/architecture/commands/ModCommand.java b/src/main/java/buttondevteam/presents/architecture/commands/ModCommand.java new file mode 100644 index 0000000..eaafbbf --- /dev/null +++ b/src/main/java/buttondevteam/presents/architecture/commands/ModCommand.java @@ -0,0 +1,17 @@ +package buttondevteam.presents.architecture.commands; + +public abstract class ModCommand extends PlayerCommand{ + + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text, ask a dev to add one", + "If you're a dev, write the help text you lazy bastard. -Ali" + }; + } + + @Override + public boolean GetModOnly() { + return true; + } +} diff --git a/src/main/java/buttondevteam/presents/architecture/commands/PlayerCommand.java b/src/main/java/buttondevteam/presents/architecture/commands/PlayerCommand.java new file mode 100644 index 0000000..f374db4 --- /dev/null +++ b/src/main/java/buttondevteam/presents/architecture/commands/PlayerCommand.java @@ -0,0 +1,38 @@ +package buttondevteam.presents.architecture.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public abstract class PlayerCommand extends BaseCommand{ + /**replaces CommandExecutor functionality*/ + @Override + public boolean onCommand(CommandSender sender, Command command, String string, String[] args){ + return OnCommand(sender, string, args); + } + /**replaces TBMCCommandBase functionality*/ + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args){ + return OnCommand((Player) sender, alias, args); + } + public abstract boolean OnCommand(Player player, String alias, String[] args); + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + return false; + } + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text. ", + "If you're a player, ask a mod to write one", + "If you're a mod, ask a dev to write one", + "If you're a dev, write the help text you lazy bastard. -Ali" + }; + } + +} diff --git a/src/main/java/buttondevteam/presents/hello/Hello.java b/src/main/java/buttondevteam/presents/hello/Hello.java new file mode 100644 index 0000000..25779a8 --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/Hello.java @@ -0,0 +1,14 @@ +package buttondevteam.presents.hello; + +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.Component; + +public class Hello extends Component{ + + @Override + public void register(JavaPlugin plugin) { + this.registerCommand(plugin, new HelloCommand(plugin)); + this.registerListener(plugin, new HelloBedsplode()); + } +} diff --git a/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java b/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java new file mode 100644 index 0000000..a7d8ff0 --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/HelloBedsplode.java @@ -0,0 +1,26 @@ +package buttondevteam.presents.hello; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerBedEnterEvent; + +public class HelloBedsplode implements Listener { + @EventHandler + public void onSleep(PlayerBedEnterEvent event){ + Player player = event.getPlayer(); + if (player.getName() != "alisolarflare") return; + + player.getWorld().createExplosion( + player.getLocation().getBlockX(), + player.getLocation().getBlockY(), + player.getLocation().getBlockZ(), + 4, + false, + false); + + player.sendMessage("HELLO MOTHERFUCKER!"); + player.sendMessage("WAKEY WAKEY!"); + } + +} diff --git a/src/main/java/buttondevteam/presents/hello/HelloCommand.java b/src/main/java/buttondevteam/presents/hello/HelloCommand.java new file mode 100644 index 0000000..0b57af0 --- /dev/null +++ b/src/main/java/buttondevteam/presents/hello/HelloCommand.java @@ -0,0 +1,36 @@ +package buttondevteam.presents.hello; + +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.commands.BaseCommand; + +public class HelloCommand extends BaseCommand { + JavaPlugin plugin; + public HelloCommand(JavaPlugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + sender.sendMessage("Hello World!"); + return false; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + @Override + public String GetCommandPath(){ + return "hello command"; + + } +} diff --git a/src/test/java/com/github/tbmcplugins/ButtonPresents/AppTest.java b/src/test/java/com/github/tbmcplugins/ButtonPresents/AppTest.java new file mode 100644 index 0000000..6f023e3 --- /dev/null +++ b/src/test/java/com/github/tbmcplugins/ButtonPresents/AppTest.java @@ -0,0 +1,38 @@ +package com.github.tbmcplugins.ButtonPresents; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}