It's about time...
PRESENTS ARE BACK BABY
This commit is contained in:
parent
2ea7bc81ff
commit
0487d5af80
17 changed files with 417 additions and 0 deletions
26
.classpath
Normal file
26
.classpath
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
23
.project
Normal file
23
.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ButtonPresents</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
4
.settings/org.eclipse.core.resources.prefs
Normal file
4
.settings/org.eclipse.core.resources.prefs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/main/java=UTF-8
|
||||||
|
encoding//src/test/java=UTF-8
|
||||||
|
encoding/<project>=UTF-8
|
5
.settings/org.eclipse.jdt.core.prefs
Normal file
5
.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -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
|
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
7
plugin.yml
Normal file
7
plugin.yml
Normal file
|
@ -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
|
49
pom.xml
Normal file
49
pom.xml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.github.tbmcplugins</groupId>
|
||||||
|
<artifactId>ButtonPresents</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>ButtonPresents</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository> <!-- This repo fixes issues with transitive dependencies -->
|
||||||
|
<id>jcenter</id>
|
||||||
|
<url>http://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.11-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||||
|
<artifactId>ButtonCore</artifactId>
|
||||||
|
<version>master-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
17
src/main/java/buttondevteam/presents/Main.java
Normal file
17
src/main/java/buttondevteam/presents/Main.java
Normal file
|
@ -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()+ ").");
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
src/main/java/buttondevteam/presents/hello/Hello.java
Normal file
14
src/main/java/buttondevteam/presents/hello/Hello.java
Normal file
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/main/java/buttondevteam/presents/hello/HelloCommand.java
Normal file
36
src/main/java/buttondevteam/presents/hello/HelloCommand.java
Normal file
|
@ -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";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue