Merge branch 'AtlasMediaGroup:Implementations' into Implementations

This commit is contained in:
EnZaXD 2023-08-11 20:16:20 +02:00 committed by GitHub
commit 31d52af6bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 113 additions and 158 deletions

View File

@ -1,6 +1,7 @@
package fns.corvo; package fns.corvo;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class Corvo extends JavaPlugin public class Corvo extends JavaPlugin
@ -8,18 +9,14 @@ public class Corvo extends JavaPlugin
@Override @Override
public void onDisable() public void onDisable()
{ {
Patchwork.getInstance() Registration.getModuleRegistry()
.getRegistrations()
.getModuleRegistry()
.removeModule(this); .removeModule(this);
} }
@Override @Override
public void onEnable() public void onEnable()
{ {
Patchwork.getInstance() Registration.getModuleRegistry()
.getRegistrations()
.getModuleRegistry()
.addModule(this); .addModule(this);
} }
} }

View File

@ -1,5 +1,6 @@
name: Corvo name: Corvo
main: me.totalfreedom.corvo.Corvo main: fns.corvo.Corvo
api-version: 1.20
version: 1.0.0 version: 1.0.0
author: TotalFreedom author: TotalFreedom
description: Services and Listeners for the Freedom Network Suite description: Services and Listeners for the Freedom Network Suite

View File

@ -6,7 +6,7 @@ import fns.datura.punishment.Cager;
import fns.datura.punishment.Halter; import fns.datura.punishment.Halter;
import fns.datura.punishment.Locker; import fns.datura.punishment.Locker;
import fns.datura.sql.MySQL; import fns.datura.sql.MySQL;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Registration;
import fns.patchwork.service.SubscriptionProvider; import fns.patchwork.service.SubscriptionProvider;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -18,7 +18,7 @@ public class Datura extends JavaPlugin
// Punishment // Punishment
private final Halter halter = new Halter(); private final Halter halter = new Halter();
private final Locker locker = new Locker(); private final Locker locker = new Locker();
private final Cager cager = new Cager(); private Cager cager;
// Features // Features
private final CommandSpy commandSpy = new CommandSpy(); private final CommandSpy commandSpy = new CommandSpy();
@ -27,28 +27,22 @@ public class Datura extends JavaPlugin
@Override @Override
public void onEnable() public void onEnable()
{ {
Patchwork.getInstance() cager = new Cager(this);
.getRegistrations()
.getModuleRegistry()
.addModule(this);
Patchwork.getInstance() Registration.getServiceTaskRegistry()
.getRegistrations()
.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, locker)); .registerService(SubscriptionProvider.syncService(this, locker));
Patchwork.getInstance() Registration.getServiceTaskRegistry()
.getRegistrations()
.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, cager)); .registerService(SubscriptionProvider.syncService(this, cager));
Patchwork.getInstance() Registration.getServiceTaskRegistry()
.getRegistrations()
.getServiceTaskRegistry()
.registerService(SubscriptionProvider.syncService(this, fuckoff)); .registerService(SubscriptionProvider.syncService(this, fuckoff));
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(halter, this); .registerEvents(halter, this);
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(commandSpy, this); .registerEvents(commandSpy, this);
Registration.getModuleRegistry()
.addModule(this);
} }
public MySQL getSQL() public MySQL getSQL()

View File

@ -1,6 +1,7 @@
package fns.datura.cmd; package fns.datura.cmd;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.command.Commander; import fns.patchwork.command.Commander;
import fns.patchwork.command.annotation.Base; import fns.patchwork.command.annotation.Base;
import fns.patchwork.command.annotation.Info; import fns.patchwork.command.annotation.Info;
@ -38,11 +39,11 @@ public class AdminChatCommand extends Commander
final Player player = (Player) sender; final Player player = (Player) sender;
Patchwork.getInstance() Shortcuts.provideModule(Patchwork.class)
.getAdminChatDisplay() .getAdminChatDisplay()
.toggleChat(player); .toggleChat(player);
final boolean toggled = Patchwork.getInstance() final boolean toggled = Shortcuts.provideModule(Patchwork.class)
.getAdminChatDisplay() .getAdminChatDisplay()
.isToggled(player); .isToggled(player);
@ -57,7 +58,7 @@ public class AdminChatCommand extends Commander
@Subcommand(permission = "patchwork.adminchat", args = {String.class}) @Subcommand(permission = "patchwork.adminchat", args = {String.class})
public void sendMessage(final CommandSender sender, final String message) public void sendMessage(final CommandSender sender, final String message)
{ {
Patchwork.getInstance() Shortcuts.provideModule(Patchwork.class)
.getAdminChatDisplay() .getAdminChatDisplay()
.adminChatMessage(sender, Component.text(message)); .adminChatMessage(sender, Component.text(message));
} }

View File

@ -51,7 +51,7 @@ public class ClearDropsCommand extends Commander
} }
final Player player = (Player) sender; final Player player = (Player) sender;
Patchwork.getInstance() Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L) .delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
.execute(() -> .execute(() ->
@ -73,7 +73,7 @@ public class ClearDropsCommand extends Commander
@Subcommand(permission = "datura.cleardrops", args = {World.class}) @Subcommand(permission = "datura.cleardrops", args = {World.class})
public void clearDrops(final CommandSender sender, final World world) public void clearDrops(final CommandSender sender, final World world)
{ {
Patchwork.getInstance() Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L) .delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
.execute(() -> .execute(() ->

View File

@ -7,30 +7,26 @@ public class DefaultNodes
{ {
public static final Node OP = new PermissionNodeBuilder() public static final Node OP = new PermissionNodeBuilder()
.key("freedom.master_key") .key("freedom.master_key")
.value(true) .expiry(-1)
.type(NodeType.PERMISSION) .type(NodeType.PERMISSION)
.negated(false)
.wildcard(true) .wildcard(true)
.build(); .build();
public static final Node NON_OP = new PermissionNodeBuilder() public static final Node NON_OP = new PermissionNodeBuilder()
.key("freedom.default") .key("freedom.default")
.value(true) .expiry(-1)
.type(NodeType.PERMISSION) .type(NodeType.PERMISSION)
.negated(false)
.wildcard(false) .wildcard(false)
.build(); .build();
public static final Node ALL = new PermissionNodeBuilder() public static final Node ALL = new PermissionNodeBuilder()
.key("*") .key("*")
.value(true) .expiry(-1)
.type(NodeType.PERMISSION) .type(NodeType.PERMISSION)
.negated(false)
.wildcard(true) .wildcard(true)
.build(); .build();
public static final Node NONE = new PermissionNodeBuilder() public static final Node NONE = new PermissionNodeBuilder()
.key("freedom.none") .key("freedom.none")
.value(true) .expiry(-1)
.type(NodeType.PERMISSION) .type(NodeType.PERMISSION)
.negated(false)
.wildcard(false) .wildcard(false)
.build(); .build();

View File

@ -1,6 +1,7 @@
package fns.datura.perms; package fns.datura.perms;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.security.Group; import fns.patchwork.security.Group;
import fns.patchwork.security.Node; import fns.patchwork.security.Node;
import java.util.HashSet; import java.util.HashSet;
@ -40,7 +41,7 @@ public class FreedomGroup implements Group
this.isDefault = isDefault; this.isDefault = isDefault;
this.isHidden = isHidden; this.isHidden = isHidden;
this.permissions = new HashSet<>(); this.permissions = new HashSet<>();
this.attachment = new PermissionAttachment(Patchwork.getInstance(), this); this.attachment = new PermissionAttachment(Shortcuts.provideModule(Patchwork.class), this);
} }
@Override @Override

View File

@ -3,6 +3,8 @@ package fns.datura.perms;
import fns.datura.Datura; import fns.datura.Datura;
import fns.datura.user.SimpleUserData; import fns.datura.user.SimpleUserData;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.security.Node; import fns.patchwork.security.Node;
import fns.patchwork.user.User; import fns.patchwork.user.User;
import fns.patchwork.user.UserData; import fns.patchwork.user.UserData;
@ -41,11 +43,7 @@ public class FreedomUser implements User
this.permissions = new HashSet<>(); this.permissions = new HashSet<>();
this.displayName = player.displayName(); this.displayName = player.displayName();
final Datura datura = Patchwork.getInstance() final Datura datura = Shortcuts.provideModule(Datura.class);
.getRegistrations()
.getModuleRegistry()
.getProvider(Datura.class)
.getModule();
UserData data = SimpleUserData.fromSQL(datura.getSQL(), uuid.toString()); UserData data = SimpleUserData.fromSQL(datura.getSQL(), uuid.toString());
@ -56,8 +54,7 @@ public class FreedomUser implements User
this.userData = data; this.userData = data;
Patchwork.getInstance() Registration
.getRegistrations()
.getUserRegistry() .getUserRegistry()
.registerUserData(this, userData); .registerUserData(this, userData);
} }
@ -96,7 +93,7 @@ public class FreedomUser implements User
public boolean addPermission(final Node node) public boolean addPermission(final Node node)
{ {
final boolean value = !node.isTemporary() || node.isExpired(); final boolean value = !node.isTemporary() || node.isExpired();
final PermissionAttachment attachment = addAttachment(Patchwork.getInstance(), node.key(), value); final PermissionAttachment attachment = addAttachment(Shortcuts.provideModule(Patchwork.class), node.key(), value);
bukkitAttachments.put(node, attachment); bukkitAttachments.put(node, attachment);
return permissions().add(node); return permissions().add(node);
} }

View File

@ -1,5 +1,6 @@
package fns.datura.punishment; package fns.datura.punishment;
import fns.datura.Datura;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.service.Service; import fns.patchwork.service.Service;
import fns.patchwork.utils.ShapeUtils; import fns.patchwork.utils.ShapeUtils;
@ -20,18 +21,20 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import javax.sound.midi.Patch;
public class Cager extends Service public class Cager extends Service
{ {
private final Set<UUID> cagedPlayers; private final Set<UUID> cagedPlayers;
private final Map<UUID, Location> cageLocations; private final Map<UUID, Location> cageLocations;
public Cager() public Cager(final Datura datura)
{ {
super("cager-service"); super("cager-service");
this.cagedPlayers = new HashSet<>(); this.cagedPlayers = new HashSet<>();
this.cageLocations = new HashMap<>(); this.cageLocations = new HashMap<>();
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(new CageListener(), Patchwork.getInstance()); .registerEvents(new CageListener(), datura);
} }
/** /**

View File

@ -1,6 +1,7 @@
package fns.datura.punishment; package fns.datura.punishment;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.service.Service; import fns.patchwork.service.Service;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -34,7 +35,7 @@ public class Locker extends Service
@Override @Override
public void tick() public void tick()
{ {
lockedPlayers.removeIf(uuid -> !Patchwork.getInstance() lockedPlayers.removeIf(uuid -> !Shortcuts.provideModule(Patchwork.class)
.getServer() .getServer()
.getOfflinePlayer(uuid) .getOfflinePlayer(uuid)
.isOnline()); .isOnline());

View File

@ -1,6 +1,7 @@
package fns.datura.sql; package fns.datura.sql;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.sql.SQL; import fns.patchwork.sql.SQL;
import fns.patchwork.utils.container.Identity; import fns.patchwork.utils.container.Identity;
import java.sql.Connection; import java.sql.Connection;
@ -74,7 +75,7 @@ public class MySQL implements SQL
throw new CompletionException("Failed to prepare statement: " throw new CompletionException("Failed to prepare statement: "
+ query + "\n", ex); + query + "\n", ex);
} }
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -91,7 +92,7 @@ public class MySQL implements SQL
throw new CompletionException("Failed to connect to the database: " throw new CompletionException("Failed to connect to the database: "
+ url.toString() + "\n", ex); + url.toString() + "\n", ex);
} }
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -111,7 +112,7 @@ public class MySQL implements SQL
"Failed to retrieve a result set from query: " "Failed to retrieve a result set from query: "
+ query + "\n", ex); + query + "\n", ex);
} }
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -130,7 +131,7 @@ public class MySQL implements SQL
throw new CompletionException("Failed to execute update: " throw new CompletionException("Failed to execute update: "
+ query + "\n", ex); + query + "\n", ex);
} }
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -149,7 +150,7 @@ public class MySQL implements SQL
throw new CompletionException("Failed to execute statement: " throw new CompletionException("Failed to execute statement: "
+ query + "\n", ex); + query + "\n", ex);
} }
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -193,7 +194,7 @@ public class MySQL implements SQL
ex); ex);
} }
return null; return null;
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -202,7 +203,7 @@ public class MySQL implements SQL
final String key, final Identity identity) final String key, final Identity identity)
{ {
return executeUpdate("UPDATE ? SET ? = ? WHERE ? = ?", table, column, value, key, identity.getId()) return executeUpdate("UPDATE ? SET ? = ? WHERE ? = ?", table, column, value, key, identity.getId())
.thenApplyAsync(result -> result > 0, Patchwork.getInstance() .thenApplyAsync(result -> result > 0, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }
@ -210,7 +211,7 @@ public class MySQL implements SQL
public CompletableFuture<Boolean> deleteRow(final String table, final String key, final Identity identity) public CompletableFuture<Boolean> deleteRow(final String table, final String key, final Identity identity)
{ {
return executeUpdate("DELETE FROM ? WHERE ? = ?", table, key, identity.getId()) return executeUpdate("DELETE FROM ? WHERE ? = ?", table, key, identity.getId())
.thenApplyAsync(result -> result > 0, Patchwork.getInstance() .thenApplyAsync(result -> result > 0, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()); .getAsync());
} }

View File

@ -3,6 +3,8 @@ package fns.datura.user;
import fns.datura.event.UserDataUpdateEvent; import fns.datura.event.UserDataUpdateEvent;
import fns.datura.perms.FreedomUser; import fns.datura.perms.FreedomUser;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.display.adminchat.AdminChatFormat; import fns.patchwork.display.adminchat.AdminChatFormat;
import fns.patchwork.security.Group; import fns.patchwork.security.Group;
import fns.patchwork.sql.SQL; import fns.patchwork.sql.SQL;
@ -38,7 +40,7 @@ public class SimpleUserData implements UserData
this.username = player.getName(); this.username = player.getName();
this.user = new FreedomUser(player); this.user = new FreedomUser(player);
Patchwork.getInstance() Shortcuts.provideModule(Patchwork.class)
.getEventBus() .getEventBus()
.addEvent(event); .addEvent(event);
} }
@ -84,8 +86,7 @@ public class SimpleUserData implements UserData
throw new IllegalStateException("Player should be online but they are not!"); throw new IllegalStateException("Player should be online but they are not!");
final User user = new FreedomUser(player); final User user = new FreedomUser(player);
final Group group = Patchwork.getInstance() final Group group = Registration
.getRegistrations()
.getGroupRegistry() .getGroupRegistry()
.getGroup(g); .getGroup(g);
@ -116,7 +117,7 @@ public class SimpleUserData implements UserData
if (player == null) throw new IllegalStateException("Player should be online but they are not!"); if (player == null) throw new IllegalStateException("Player should be online but they are not!");
return new SimpleUserData(player); return new SimpleUserData(player);
}, Patchwork.getInstance() }, Shortcuts.provideModule(Patchwork.class)
.getExecutor() .getExecutor()
.getAsync()) .getAsync())
.join(); .join();

View File

@ -1,5 +1,6 @@
name: Datura name: Datura
main: me.totalfreedom.datura.Datura main: fns.datura.Datura
api-version: 1.20
version: 1.0.0 version: 1.0.0
author: TotalFreedom author: TotalFreedom
description: Data Manager for the Freedom Network Suite description: Data Manager for the Freedom Network Suite

View File

@ -1,7 +1,6 @@
package fns.fossil; package fns.fossil;
import fns.fossil.trail.Trailer; import fns.fossil.trail.Trailer;
import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration; import fns.patchwork.base.Registration;
import fns.patchwork.service.SubscriptionProvider; import fns.patchwork.service.SubscriptionProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -9,17 +8,14 @@ import org.bukkit.plugin.java.JavaPlugin;
public class Fossil extends JavaPlugin public class Fossil extends JavaPlugin
{ {
private final Trailer trailer = new Trailer(); private final Trailer trailer = new Trailer();
private final Registration registration = Patchwork.getInstance()
.getRegistrations();
@Override @Override
public void onEnable() public void onEnable()
{ {
registration.getModuleRegistry() Registration.getServiceTaskRegistry()
.addModule(this);
registration.getServiceTaskRegistry()
.registerService( .registerService(
SubscriptionProvider.syncService(this, trailer)); SubscriptionProvider.syncService(this, trailer));
Registration.getModuleRegistry()
.addModule(this);
} }
} }

View File

@ -1,11 +1,12 @@
package fns.fossil.bouncypads; package fns.fossil.bouncypads;
import fns.fossil.Fossil; import fns.fossil.Fossil;
import fns.patchwork.base.Patchwork;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Stream; import java.util.stream.Stream;
import fns.patchwork.base.Shortcuts;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Tag; import org.bukkit.Tag;
@ -32,12 +33,7 @@ public class PadHolder implements Listener
public PadHolder() public PadHolder()
{ {
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(this, Patchwork .registerEvents(this, Shortcuts.provideModule(Fossil.class));
.getInstance()
.getRegistrations()
.getModuleRegistry()
.getProvider(Fossil.class)
.getModule());
} }
/** /**

View File

@ -1,6 +1,7 @@
name: Fossil name: Fossil
version: 1.0 version: 1.0
main: me.totalfreedom.fossil.Fossil main: fns.fossil.Fossil
api-version: 1.20
author: TotalFreedom author: TotalFreedom
description: The Fun Module for the Freedom Network. description: The Fun Module for the Freedom Network.
depend: depend:

View File

@ -15,52 +15,45 @@ public class Patchwork extends JavaPlugin
/** /**
* The {@link EventBus} for this plugin. * The {@link EventBus} for this plugin.
*/ */
private final EventBus eventBus = new EventBus(this); private EventBus eventBus;
/**
* The {@link Registration} object for this plugin.
*/
private final Registration registration = new Registration();
/** /**
* The {@link FreedomExecutor} for this plugin. * The {@link FreedomExecutor} for this plugin.
*/ */
private final FreedomExecutor executor = new FreedomExecutor(); private FreedomExecutor executor;
/** /**
* The {@link AdminChatDisplay} for this plugin. * The {@link AdminChatDisplay} for this plugin.
*/ */
private final AdminChatDisplay acdisplay = new AdminChatDisplay(); private AdminChatDisplay acdisplay;
/**
* Provides this plugin instance through a safe static method. This is effectively the same thing as using
* {@link JavaPlugin#getPlugin(Class)}
*
* @return the plugin instance
*/
public static Patchwork getInstance()
{
return JavaPlugin.getPlugin(Patchwork.class);
}
@Override @Override
public void onDisable() public void onDisable()
{ {
Bukkit.getScheduler() Bukkit.getScheduler()
.runTaskLater(this, () -> getRegistrations() .runTaskLater(this, () -> Registration
.getServiceTaskRegistry() .getServiceTaskRegistry()
.stopAllServices(), 1L); .stopAllServices(), 1L);
getRegistrations().getServiceTaskRegistry() Registration.getServiceTaskRegistry()
.unregisterService(EventBus.class); .unregisterService(EventBus.class);
} }
@Override @Override
public void onEnable() public void onEnable()
{ {
getRegistrations().getServiceTaskRegistry() eventBus = new EventBus(this);
executor = new FreedomExecutor(this);
acdisplay = new AdminChatDisplay(this);
Registration.getServiceTaskRegistry()
.registerService(SubscriptionProvider.asyncService(this, eventBus)); .registerService(SubscriptionProvider.asyncService(this, eventBus));
getExecutor().getSync() getExecutor().getSync()
.execute(() -> getRegistrations() .execute(() -> Registration
.getServiceTaskRegistry() .getServiceTaskRegistry()
.startAllServices()); .startAllServices());
Registration.getModuleRegistry().addModule(this);
} }
/** /**
@ -73,17 +66,6 @@ public class Patchwork extends JavaPlugin
return executor; return executor;
} }
/**
* Get's the Registration object for this plugin. This object contains every registry class for the various features
* provided by this plugin.
*
* @return the Registration object
*/
public Registration getRegistrations()
{
return registration;
}
/** /**
* Gets the {@link EventBus} for this plugin. The EventBus is used to register and listen to custom events provided * Gets the {@link EventBus} for this plugin. The EventBus is used to register and listen to custom events provided
* by Freedom Network Suite. * by Freedom Network Suite.

View File

@ -11,53 +11,44 @@ import fns.patchwork.data.UserRegistry;
* This class is a holder for each registry in the data package. * This class is a holder for each registry in the data package.
* <br> * <br>
* Registries such as {@link ModuleRegistry} and {@link ServiceTaskRegistry} can be found as final objects in this * Registries such as {@link ModuleRegistry} and {@link ServiceTaskRegistry} can be found as final objects in this
* class. These registries should only ever be accessed through the single Registration object in CommonsBase using * class.
* {@link Patchwork#getRegistrations()}
*/ */
public class Registration public class Registration
{ {
/** /**
* The {@link EventRegistry} * The {@link EventRegistry}
*/ */
private final EventRegistry eventRegistry; private static final EventRegistry eventRegistry = new EventRegistry();
/** /**
* The {@link UserRegistry} * The {@link UserRegistry}
*/ */
private final UserRegistry userRegistry; private static final UserRegistry userRegistry = new UserRegistry();
/** /**
* The {@link ServiceTaskRegistry} * The {@link ServiceTaskRegistry}
*/ */
private final ServiceTaskRegistry serviceTaskRegistry; private static final ServiceTaskRegistry serviceTaskRegistry = new ServiceTaskRegistry();
/** /**
* The {@link ModuleRegistry} * The {@link ModuleRegistry}
*/ */
private final ModuleRegistry moduleRegistry; private static final ModuleRegistry moduleRegistry = new ModuleRegistry();
/** /**
* The {@link GroupRegistry} * The {@link GroupRegistry}
*/ */
private final GroupRegistry groupRegistry; private static final GroupRegistry groupRegistry = new GroupRegistry();
/** /**
* The {@link ConfigRegistry} * The {@link ConfigRegistry}
*/ */
private final ConfigRegistry configRegistry; private static final ConfigRegistry configRegistry = new ConfigRegistry();
/** private Registration()
* Constructs a new Registration object and initializes all registries.
*/
Registration()
{ {
this.eventRegistry = new EventRegistry(); throw new AssertionError();
this.userRegistry = new UserRegistry();
this.serviceTaskRegistry = new ServiceTaskRegistry();
this.moduleRegistry = new ModuleRegistry();
this.groupRegistry = new GroupRegistry();
this.configRegistry = new ConfigRegistry();
} }
/** /**
* @return The {@link ModuleRegistry} * @return The {@link ModuleRegistry}
*/ */
public ModuleRegistry getModuleRegistry() public static ModuleRegistry getModuleRegistry()
{ {
return moduleRegistry; return moduleRegistry;
} }
@ -65,7 +56,7 @@ public class Registration
/** /**
* @return The {@link EventRegistry} * @return The {@link EventRegistry}
*/ */
public EventRegistry getEventRegistry() public static EventRegistry getEventRegistry()
{ {
return eventRegistry; return eventRegistry;
} }
@ -73,7 +64,7 @@ public class Registration
/** /**
* @return The {@link UserRegistry} * @return The {@link UserRegistry}
*/ */
public UserRegistry getUserRegistry() public static UserRegistry getUserRegistry()
{ {
return userRegistry; return userRegistry;
} }
@ -81,7 +72,7 @@ public class Registration
/** /**
* @return The {@link ServiceTaskRegistry} * @return The {@link ServiceTaskRegistry}
*/ */
public ServiceTaskRegistry getServiceTaskRegistry() public static ServiceTaskRegistry getServiceTaskRegistry()
{ {
return serviceTaskRegistry; return serviceTaskRegistry;
} }
@ -89,7 +80,7 @@ public class Registration
/** /**
* @return The {@link GroupRegistry} * @return The {@link GroupRegistry}
*/ */
public GroupRegistry getGroupRegistry() public static GroupRegistry getGroupRegistry()
{ {
return groupRegistry; return groupRegistry;
} }
@ -97,8 +88,8 @@ public class Registration
/** /**
* @return The {@link ConfigRegistry} * @return The {@link ConfigRegistry}
*/ */
public ConfigRegistry getConfigRegistry() public static ConfigRegistry getConfigRegistry()
{ {
return configRegistry; return configRegistry;
} }
} }

View File

@ -13,18 +13,14 @@ public final class Shortcuts
public static <T extends JavaPlugin> T provideModule(final Class<T> pluginClass) public static <T extends JavaPlugin> T provideModule(final Class<T> pluginClass)
{ {
return Patchwork.getInstance() return Registration.getModuleRegistry()
.getRegistrations() .getProvider(pluginClass)
.getModuleRegistry() .getModule();
.getProvider(pluginClass)
.getModule();
} }
public static User getUser(final Player player) public static User getUser(final Player player)
{ {
return Patchwork.getInstance() return Registration.getUserRegistry()
.getRegistrations()
.getUserRegistry()
.getUser(player); .getUser(player);
} }
} }

View File

@ -1,6 +1,7 @@
package fns.patchwork.display.adminchat; package fns.patchwork.display.adminchat;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration;
import fns.patchwork.base.Shortcuts; import fns.patchwork.base.Shortcuts;
import fns.patchwork.security.Groups; import fns.patchwork.security.Groups;
import fns.patchwork.user.UserData; import fns.patchwork.user.UserData;
@ -24,9 +25,9 @@ public class AdminChatDisplay
private final Map<UUID, AdminChatFormat> adminChatFormat = new HashMap<>(); private final Map<UUID, AdminChatFormat> adminChatFormat = new HashMap<>();
private final Set<UUID> toggledChat = new HashSet<>(); private final Set<UUID> toggledChat = new HashSet<>();
public AdminChatDisplay() public AdminChatDisplay(final Patchwork patchwork)
{ {
new ACListener(this); new ACListener(this, patchwork);
} }
public void addPlayer(final Player player, final AdminChatFormat format) public void addPlayer(final Player player, final AdminChatFormat format)
@ -101,11 +102,11 @@ public class AdminChatDisplay
{ {
private final AdminChatDisplay display; private final AdminChatDisplay display;
public ACListener(final AdminChatDisplay display) public ACListener(final AdminChatDisplay display, final Patchwork patchwork)
{ {
this.display = display; this.display = display;
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(this, Shortcuts.provideModule(Patchwork.class)); .registerEvents(this, patchwork);
} }
@EventHandler @EventHandler
@ -124,9 +125,7 @@ public class AdminChatDisplay
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (player.hasPermission(ACPERM)) if (player.hasPermission(ACPERM))
{ {
final UserData data = Patchwork.getInstance() final UserData data = Registration.getUserRegistry()
.getRegistrations()
.getUserRegistry()
.fromPlayer(player); .fromPlayer(player);
if (data.hasCustomACFormat()) if (data.hasCustomACFormat())
{ {

View File

@ -160,7 +160,6 @@ public class ContextProvider
* *
* @param string The string to parse * @param string The string to parse
* @return A location object if xyz is valid * @return A location object if xyz is valid
* @see BukkitDelegate#processSubCommands(String[], CommandSender, ContextProvider, Subcommand)
*/ */
private @Nullable Location toLocation(final String string, final Class<?> clazz) private @Nullable Location toLocation(final String string, final Class<?> clazz)
{ {

View File

@ -25,12 +25,12 @@ public class FreedomExecutor
/** /**
* Creates a new {@link FreedomExecutor} instance. * Creates a new {@link FreedomExecutor} instance.
*/ */
public FreedomExecutor() public FreedomExecutor(final Patchwork patchwork)
{ {
syncExecutor = r -> Bukkit.getScheduler() syncExecutor = r -> Bukkit.getScheduler()
.runTask(Patchwork.getInstance(), r); .runTask(patchwork, r);
asyncExecutor = r -> Bukkit.getScheduler() asyncExecutor = r -> Bukkit.getScheduler()
.runTaskAsynchronously(Patchwork.getInstance(), r); .runTaskAsynchronously(patchwork, r);
} }
/** /**

View File

@ -1,6 +1,8 @@
package fns.patchwork.shop; package fns.patchwork.shop;
import fns.patchwork.base.Patchwork; import fns.patchwork.base.Patchwork;
import fns.patchwork.base.Registration;
import fns.patchwork.base.Shortcuts;
import fns.patchwork.display.BossBarDisplay; import fns.patchwork.display.BossBarDisplay;
import fns.patchwork.display.BossBarTimer; import fns.patchwork.display.BossBarTimer;
import fns.patchwork.economy.EconomicEntity; import fns.patchwork.economy.EconomicEntity;
@ -36,7 +38,7 @@ public class ReactionTask extends Task implements Listener
} }
final BossBarTimer timer = new BossBarTimer(bossBarDisplay, reaction.getReactionDuration()); final BossBarTimer timer = new BossBarTimer(bossBarDisplay, reaction.getReactionDuration());
timer.runTaskTimer(Patchwork.getInstance(), 0L, timer.getInterval()); timer.runTaskTimer(Shortcuts.provideModule(Patchwork.class), 0L, timer.getInterval());
} }
@EventHandler @EventHandler
@ -45,9 +47,7 @@ public class ReactionTask extends Task implements Listener
if (event.message() if (event.message()
.equals(reaction.getReactionMessage())) .equals(reaction.getReactionMessage()))
{ {
final EconomicEntity entity = Patchwork.getInstance() final EconomicEntity entity = Registration.getUserRegistry()
.getRegistrations()
.getUserRegistry()
.getUser(event.getPlayer()); .getUser(event.getPlayer());
reaction.onReact(entity); reaction.onReact(entity);

View File

@ -1,5 +1,6 @@
name: Patchwork name: Patchwork
main: me.totalfreedom.base.CommonsBase main: fns.patchwork.base.Patchwork
api-version: 1.20
version: 1.0.0 version: 1.0.0
author: TotalFreedom author: TotalFreedom
description: The Core of Freedom Network Suite description: The Core of Freedom Network Suite