Start using components (PR to dev) #53

Merged
NorbiPeti merged 5 commits from redesign into dev 2018-11-20 19:44:23 +00:00
8 changed files with 43 additions and 21 deletions
Showing only changes of commit 81cb364ddc - Show all commits

1
ButtonCore/lombok.config Normal file
View file

@ -0,0 +1 @@
lombok.var.flagUsage = ALLOW

View file

@ -72,6 +72,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
</configuration>
</plugin>
</plugins>
</build>
<repositories>

View file

@ -1,16 +1,15 @@
package buttondevteam.component.commands;
import buttondevteam.lib.architecture.Component;
import org.bukkit.plugin.java.JavaPlugin;
public class CommandComponent extends Component { //TODO: Do we just move everything here?
@Override
public void register(JavaPlugin plugin) {
public void enable() {
}
@Override
public void unregister(JavaPlugin plugin) {
public void disable() {
}
}

View file

@ -4,18 +4,17 @@ import buttondevteam.core.PrimeRestartCommand;
import buttondevteam.core.ScheduledRestartCommand;
import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.chat.TBMCChatAPI;
import org.bukkit.plugin.java.JavaPlugin;
public class RestartComponent extends Component {
@Override
public void register(JavaPlugin plugin) {
//TODO: Separately (dis)allow commands
TBMCChatAPI.AddCommand(plugin, ScheduledRestartCommand.class);
TBMCChatAPI.AddCommand(plugin, PrimeRestartCommand.class);
public void enable() {
//TODO: Permissions for the commands
TBMCChatAPI.AddCommand(getPlugin(), ScheduledRestartCommand.class);
TBMCChatAPI.AddCommand(getPlugin(), PrimeRestartCommand.class);
}
@Override
public void unregister(JavaPlugin plugin) {
public void disable() {
}
}

View file

@ -2,16 +2,15 @@ package buttondevteam.component.updater;
import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.chat.TBMCChatAPI;
import org.bukkit.plugin.java.JavaPlugin;
public class PluginUpdaterComponent extends Component {
@Override
public void register(JavaPlugin plugin) {
TBMCChatAPI.AddCommand(plugin, UpdatePluginCommand.class);
public void enable() {
TBMCChatAPI.AddCommand(getPlugin(), UpdatePluginCommand.class);
}
@Override
public void unregister(JavaPlugin plugin) {
public void disable() { //TODO: Unregister commands and such
}
}

View file

@ -1,7 +1,10 @@
package buttondevteam.core;
import buttondevteam.component.restart.RestartComponent;
import buttondevteam.component.updater.PluginUpdater;
import buttondevteam.component.updater.PluginUpdaterComponent;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.ChatRoom;
import buttondevteam.lib.chat.Color;
@ -40,6 +43,8 @@ public class MainPlugin extends JavaPlugin {
setupPermissions();
Test = getConfig().getBoolean("test", true);
saveConfig();
Component.registerComponent(this, new PluginUpdaterComponent());
Component.registerComponent(this, new RestartComponent());
ComponentManager.enableComponents();
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);

View file

@ -144,20 +144,23 @@ public abstract class Component {
}
/**
* Registers the module, when called by the JavaPlugin class. Call
* registerCommand() and registerListener() within this method.
* Registers the module, when called by the JavaPlugin class.
* This gets fired when the plugin is enabled. Use {@link #enable()} to register commands and such.
*
* @param plugin Plugin class called to register commands and listeners
* @param plugin Plugin object
*/
protected abstract void register(JavaPlugin plugin);
protected void register(JavaPlugin plugin) {
}
/**
* Unregisters the module, when called by the JavaPlugin class. Do
* any cleanups needed within this method.
* Unregisters the module, when called by the JavaPlugin class.
* This gets fired when the plugin is disabled.
* Do any cleanups needed within this method.
*
* @param plugin Plugin class called to register commands and listeners
* @param plugin Plugin object
*/
protected abstract void unregister(JavaPlugin plugin);
protected void unregister(JavaPlugin plugin) {
}
/**
* Enables the module, when called by the JavaPlugin class. Call

View file

@ -23,6 +23,14 @@
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
</configuration>
</plugin>
</plugins>
</build>