This commit is contained in:
Paul Reilly
2023-06-02 17:07:14 -05:00
parent a632eb778c
commit 9481f88afd
20 changed files with 792 additions and 205 deletions

View File

@ -2,6 +2,8 @@ package me.totalfreedom.base;
import me.totalfreedom.event.EventBus;
import me.totalfreedom.service.FreedomExecutor;
import me.totalfreedom.service.SubscriptionProvider;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class CommonsBase extends JavaPlugin
@ -18,21 +20,23 @@ public class CommonsBase extends JavaPlugin
@Override
public void onDisable()
{
Bukkit.getScheduler().runTaskLater(this, () -> getRegistrations()
.getServiceRegistry()
.stopAllServices(), 1L);
getRegistrations().getServiceRegistry()
.stopAll();
getRegistrations().getServiceRegistry()
.unregister(EventBus.class, eventBus);
.unregisterService(EventBus.class);
}
@Override
public void onEnable()
{
getRegistrations().getServiceRegistry()
.register(this, eventBus);
.registerService(SubscriptionProvider.asyncService(this, eventBus));
getExecutor().getSync()
.execute(() -> getRegistrations()
.getServiceRegistry()
.startAll());
.startAllServices());
}
public FreedomExecutor getExecutor()

View File

@ -4,14 +4,14 @@ import me.totalfreedom.data.ConfigRegistry;
import me.totalfreedom.data.EventRegistry;
import me.totalfreedom.data.GroupRegistry;
import me.totalfreedom.data.ModuleRegistry;
import me.totalfreedom.data.ServiceRegistry;
import me.totalfreedom.data.ServiceTaskRegistry;
import me.totalfreedom.data.UserRegistry;
public class Registration
{
private final EventRegistry eventRegistry;
private final UserRegistry userRegistry;
private final ServiceRegistry serviceRegistry;
private final ServiceTaskRegistry serviceTaskRegistry;
private final ModuleRegistry moduleRegistry;
private final GroupRegistry groupRegistry;
private final ConfigRegistry configRegistry;
@ -20,7 +20,7 @@ public class Registration
{
this.eventRegistry = new EventRegistry();
this.userRegistry = new UserRegistry();
this.serviceRegistry = new ServiceRegistry();
this.serviceTaskRegistry = new ServiceTaskRegistry();
this.moduleRegistry = new ModuleRegistry();
this.groupRegistry = new GroupRegistry();
this.configRegistry = new ConfigRegistry();
@ -41,9 +41,9 @@ public class Registration
return userRegistry;
}
public ServiceRegistry getServiceRegistry()
public ServiceTaskRegistry getServiceRegistry()
{
return serviceRegistry;
return serviceTaskRegistry;
}
public GroupRegistry getGroupRegistry()