mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2024-11-13 04:33:33 +00:00
Overhaul of Patchwork and Registration system, fix-up for all plugin.yml files and removal of .negates(0 and .value() from DefaultNodes in turn for the .expiry() system removing the redundancies. (#21)
Co-authored-by: eva <66324759+evax64@users.noreply.github.com>
This commit is contained in:
parent
368f3cae12
commit
3e8c63221d
@ -1,6 +1,7 @@
|
||||
package fns.corvo;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Corvo extends JavaPlugin
|
||||
@ -8,18 +9,14 @@ public class Corvo extends JavaPlugin
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
Registration.getModuleRegistry()
|
||||
.removeModule(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
Registration.getModuleRegistry()
|
||||
.addModule(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
name: Corvo
|
||||
main: me.totalfreedom.corvo.Corvo
|
||||
main: fns.corvo.Corvo
|
||||
api-version: 1.20
|
||||
version: 1.0.0
|
||||
author: TotalFreedom
|
||||
description: Services and Listeners for the Freedom Network Suite
|
||||
|
@ -6,7 +6,7 @@ import fns.datura.punishment.Cager;
|
||||
import fns.datura.punishment.Halter;
|
||||
import fns.datura.punishment.Locker;
|
||||
import fns.datura.sql.MySQL;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.service.SubscriptionProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -18,7 +18,7 @@ public class Datura extends JavaPlugin
|
||||
// Punishment
|
||||
private final Halter halter = new Halter();
|
||||
private final Locker locker = new Locker();
|
||||
private final Cager cager = new Cager();
|
||||
private Cager cager;
|
||||
|
||||
// Features
|
||||
private final CommandSpy commandSpy = new CommandSpy();
|
||||
@ -27,28 +27,22 @@ public class Datura extends JavaPlugin
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.addModule(this);
|
||||
cager = new Cager(this);
|
||||
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
Registration.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, locker));
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
Registration.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, cager));
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getServiceTaskRegistry()
|
||||
Registration.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.syncService(this, fuckoff));
|
||||
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(halter, this);
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(commandSpy, this);
|
||||
|
||||
Registration.getModuleRegistry()
|
||||
.addModule(this);
|
||||
}
|
||||
|
||||
public MySQL getSQL()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fns.datura.cmd;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.command.Commander;
|
||||
import fns.patchwork.command.annotation.Base;
|
||||
import fns.patchwork.command.annotation.Info;
|
||||
@ -38,11 +39,11 @@ public class AdminChatCommand extends Commander
|
||||
|
||||
final Player player = (Player) sender;
|
||||
|
||||
Patchwork.getInstance()
|
||||
Shortcuts.provideModule(Patchwork.class)
|
||||
.getAdminChatDisplay()
|
||||
.toggleChat(player);
|
||||
|
||||
final boolean toggled = Patchwork.getInstance()
|
||||
final boolean toggled = Shortcuts.provideModule(Patchwork.class)
|
||||
.getAdminChatDisplay()
|
||||
.isToggled(player);
|
||||
|
||||
@ -57,7 +58,7 @@ public class AdminChatCommand extends Commander
|
||||
@Subcommand(permission = "patchwork.adminchat", args = {String.class})
|
||||
public void sendMessage(final CommandSender sender, final String message)
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
Shortcuts.provideModule(Patchwork.class)
|
||||
.getAdminChatDisplay()
|
||||
.adminChatMessage(sender, Component.text(message));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class ClearDropsCommand extends Commander
|
||||
}
|
||||
|
||||
final Player player = (Player) sender;
|
||||
Patchwork.getInstance()
|
||||
Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
|
||||
.execute(() ->
|
||||
@ -73,7 +73,7 @@ public class ClearDropsCommand extends Commander
|
||||
@Subcommand(permission = "datura.cleardrops", args = {World.class})
|
||||
public void clearDrops(final CommandSender sender, final World world)
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
|
||||
.execute(() ->
|
||||
|
@ -7,30 +7,26 @@ public class DefaultNodes
|
||||
{
|
||||
public static final Node OP = new PermissionNodeBuilder()
|
||||
.key("freedom.master_key")
|
||||
.value(true)
|
||||
.expiry(-1)
|
||||
.type(NodeType.PERMISSION)
|
||||
.negated(false)
|
||||
.wildcard(true)
|
||||
.build();
|
||||
public static final Node NON_OP = new PermissionNodeBuilder()
|
||||
.key("freedom.default")
|
||||
.value(true)
|
||||
.expiry(-1)
|
||||
.type(NodeType.PERMISSION)
|
||||
.negated(false)
|
||||
.wildcard(false)
|
||||
.build();
|
||||
public static final Node ALL = new PermissionNodeBuilder()
|
||||
.key("*")
|
||||
.value(true)
|
||||
.expiry(-1)
|
||||
.type(NodeType.PERMISSION)
|
||||
.negated(false)
|
||||
.wildcard(true)
|
||||
.build();
|
||||
public static final Node NONE = new PermissionNodeBuilder()
|
||||
.key("freedom.none")
|
||||
.value(true)
|
||||
.expiry(-1)
|
||||
.type(NodeType.PERMISSION)
|
||||
.negated(false)
|
||||
.wildcard(false)
|
||||
.build();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fns.datura.perms;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.security.Group;
|
||||
import fns.patchwork.security.Node;
|
||||
import java.util.HashSet;
|
||||
@ -40,7 +41,7 @@ public class FreedomGroup implements Group
|
||||
this.isDefault = isDefault;
|
||||
this.isHidden = isHidden;
|
||||
this.permissions = new HashSet<>();
|
||||
this.attachment = new PermissionAttachment(Patchwork.getInstance(), this);
|
||||
this.attachment = new PermissionAttachment(Shortcuts.provideModule(Patchwork.class), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,8 @@ package fns.datura.perms;
|
||||
import fns.datura.Datura;
|
||||
import fns.datura.user.SimpleUserData;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.security.Node;
|
||||
import fns.patchwork.user.User;
|
||||
import fns.patchwork.user.UserData;
|
||||
@ -41,11 +43,7 @@ public class FreedomUser implements User
|
||||
this.permissions = new HashSet<>();
|
||||
this.displayName = player.displayName();
|
||||
|
||||
final Datura datura = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.getProvider(Datura.class)
|
||||
.getModule();
|
||||
final Datura datura = Shortcuts.provideModule(Datura.class);
|
||||
|
||||
UserData data = SimpleUserData.fromSQL(datura.getSQL(), uuid.toString());
|
||||
|
||||
@ -56,8 +54,7 @@ public class FreedomUser implements User
|
||||
|
||||
this.userData = data;
|
||||
|
||||
Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
Registration
|
||||
.getUserRegistry()
|
||||
.registerUserData(this, userData);
|
||||
}
|
||||
@ -96,7 +93,7 @@ public class FreedomUser implements User
|
||||
public boolean addPermission(final Node node)
|
||||
{
|
||||
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);
|
||||
return permissions().add(node);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fns.datura.punishment;
|
||||
|
||||
import fns.datura.Datura;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.service.Service;
|
||||
import fns.patchwork.utils.ShapeUtils;
|
||||
@ -20,18 +21,20 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import javax.sound.midi.Patch;
|
||||
|
||||
public class Cager extends Service
|
||||
{
|
||||
private final Set<UUID> cagedPlayers;
|
||||
private final Map<UUID, Location> cageLocations;
|
||||
|
||||
public Cager()
|
||||
public Cager(final Datura datura)
|
||||
{
|
||||
super("cager-service");
|
||||
this.cagedPlayers = new HashSet<>();
|
||||
this.cageLocations = new HashMap<>();
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(new CageListener(), Patchwork.getInstance());
|
||||
.registerEvents(new CageListener(), datura);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fns.datura.punishment;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.service.Service;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -34,7 +35,7 @@ public class Locker extends Service
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
lockedPlayers.removeIf(uuid -> !Patchwork.getInstance()
|
||||
lockedPlayers.removeIf(uuid -> !Shortcuts.provideModule(Patchwork.class)
|
||||
.getServer()
|
||||
.getOfflinePlayer(uuid)
|
||||
.isOnline());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fns.datura.sql;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.sql.SQL;
|
||||
import fns.patchwork.utils.container.Identity;
|
||||
import java.sql.Connection;
|
||||
@ -74,7 +75,7 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to prepare statement: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -91,7 +92,7 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to connect to the database: "
|
||||
+ url.toString() + "\n", ex);
|
||||
}
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -111,7 +112,7 @@ public class MySQL implements SQL
|
||||
"Failed to retrieve a result set from query: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -130,7 +131,7 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to execute update: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -149,7 +150,7 @@ public class MySQL implements SQL
|
||||
throw new CompletionException("Failed to execute statement: "
|
||||
+ query + "\n", ex);
|
||||
}
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -193,7 +194,7 @@ public class MySQL implements SQL
|
||||
ex);
|
||||
}
|
||||
return null;
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
@ -202,7 +203,7 @@ public class MySQL implements SQL
|
||||
final String key, final Identity identity)
|
||||
{
|
||||
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()
|
||||
.getAsync());
|
||||
}
|
||||
@ -210,7 +211,7 @@ public class MySQL implements SQL
|
||||
public CompletableFuture<Boolean> deleteRow(final String table, final String key, final Identity identity)
|
||||
{
|
||||
return executeUpdate("DELETE FROM ? WHERE ? = ?", table, key, identity.getId())
|
||||
.thenApplyAsync(result -> result > 0, Patchwork.getInstance()
|
||||
.thenApplyAsync(result -> result > 0, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync());
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package fns.datura.user;
|
||||
import fns.datura.event.UserDataUpdateEvent;
|
||||
import fns.datura.perms.FreedomUser;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.display.adminchat.AdminChatFormat;
|
||||
import fns.patchwork.security.Group;
|
||||
import fns.patchwork.sql.SQL;
|
||||
@ -38,7 +40,7 @@ public class SimpleUserData implements UserData
|
||||
this.username = player.getName();
|
||||
this.user = new FreedomUser(player);
|
||||
|
||||
Patchwork.getInstance()
|
||||
Shortcuts.provideModule(Patchwork.class)
|
||||
.getEventBus()
|
||||
.addEvent(event);
|
||||
}
|
||||
@ -84,8 +86,7 @@ public class SimpleUserData implements UserData
|
||||
throw new IllegalStateException("Player should be online but they are not!");
|
||||
|
||||
final User user = new FreedomUser(player);
|
||||
final Group group = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
final Group group = Registration
|
||||
.getGroupRegistry()
|
||||
.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!");
|
||||
|
||||
return new SimpleUserData(player);
|
||||
}, Patchwork.getInstance()
|
||||
}, Shortcuts.provideModule(Patchwork.class)
|
||||
.getExecutor()
|
||||
.getAsync())
|
||||
.join();
|
||||
|
@ -1,5 +1,6 @@
|
||||
name: Datura
|
||||
main: me.totalfreedom.datura.Datura
|
||||
main: fns.datura.Datura
|
||||
api-version: 1.20
|
||||
version: 1.0.0
|
||||
author: TotalFreedom
|
||||
description: Data Manager for the Freedom Network Suite
|
||||
|
@ -1,7 +1,6 @@
|
||||
package fns.fossil;
|
||||
|
||||
import fns.fossil.trail.Trailer;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.service.SubscriptionProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -9,17 +8,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class Fossil extends JavaPlugin
|
||||
{
|
||||
private final Trailer trailer = new Trailer();
|
||||
private final Registration registration = Patchwork.getInstance()
|
||||
.getRegistrations();
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
registration.getModuleRegistry()
|
||||
.addModule(this);
|
||||
|
||||
registration.getServiceTaskRegistry()
|
||||
Registration.getServiceTaskRegistry()
|
||||
.registerService(
|
||||
SubscriptionProvider.syncService(this, trailer));
|
||||
|
||||
Registration.getModuleRegistry()
|
||||
.addModule(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package fns.fossil.bouncypads;
|
||||
|
||||
import fns.fossil.Fossil;
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Tag;
|
||||
@ -32,12 +33,7 @@ public class PadHolder implements Listener
|
||||
public PadHolder()
|
||||
{
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(this, Patchwork
|
||||
.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.getProvider(Fossil.class)
|
||||
.getModule());
|
||||
.registerEvents(this, Shortcuts.provideModule(Fossil.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
name: Fossil
|
||||
version: 1.0
|
||||
main: me.totalfreedom.fossil.Fossil
|
||||
main: fns.fossil.Fossil
|
||||
api-version: 1.20
|
||||
author: TotalFreedom
|
||||
description: The Fun Module for the Freedom Network.
|
||||
depend:
|
||||
|
@ -15,52 +15,45 @@ public class Patchwork extends JavaPlugin
|
||||
/**
|
||||
* The {@link EventBus} for this plugin.
|
||||
*/
|
||||
private final EventBus eventBus = new EventBus(this);
|
||||
/**
|
||||
* The {@link Registration} object for this plugin.
|
||||
*/
|
||||
private final Registration registration = new Registration();
|
||||
private EventBus eventBus;
|
||||
/**
|
||||
* The {@link FreedomExecutor} for this plugin.
|
||||
*/
|
||||
private final FreedomExecutor executor = new FreedomExecutor();
|
||||
private FreedomExecutor executor;
|
||||
/**
|
||||
* The {@link AdminChatDisplay} for this plugin.
|
||||
*/
|
||||
private final AdminChatDisplay acdisplay = new AdminChatDisplay();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
private AdminChatDisplay acdisplay;
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Bukkit.getScheduler()
|
||||
.runTaskLater(this, () -> getRegistrations()
|
||||
.runTaskLater(this, () -> Registration
|
||||
.getServiceTaskRegistry()
|
||||
.stopAllServices(), 1L);
|
||||
|
||||
getRegistrations().getServiceTaskRegistry()
|
||||
Registration.getServiceTaskRegistry()
|
||||
.unregisterService(EventBus.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
getRegistrations().getServiceTaskRegistry()
|
||||
eventBus = new EventBus(this);
|
||||
executor = new FreedomExecutor(this);
|
||||
acdisplay = new AdminChatDisplay(this);
|
||||
|
||||
|
||||
Registration.getServiceTaskRegistry()
|
||||
.registerService(SubscriptionProvider.asyncService(this, eventBus));
|
||||
|
||||
getExecutor().getSync()
|
||||
.execute(() -> getRegistrations()
|
||||
.execute(() -> Registration
|
||||
.getServiceTaskRegistry()
|
||||
.startAllServices());
|
||||
|
||||
Registration.getModuleRegistry().addModule(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,17 +66,6 @@ public class Patchwork extends JavaPlugin
|
||||
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
|
||||
* by Freedom Network Suite.
|
||||
|
@ -11,53 +11,44 @@ import fns.patchwork.data.UserRegistry;
|
||||
* This class is a holder for each registry in the data package.
|
||||
* <br>
|
||||
* 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
|
||||
* {@link Patchwork#getRegistrations()}
|
||||
* class.
|
||||
*/
|
||||
public class Registration
|
||||
{
|
||||
/**
|
||||
* The {@link EventRegistry}
|
||||
*/
|
||||
private final EventRegistry eventRegistry;
|
||||
private static final EventRegistry eventRegistry = new EventRegistry();
|
||||
/**
|
||||
* The {@link UserRegistry}
|
||||
*/
|
||||
private final UserRegistry userRegistry;
|
||||
private static final UserRegistry userRegistry = new UserRegistry();
|
||||
/**
|
||||
* The {@link ServiceTaskRegistry}
|
||||
*/
|
||||
private final ServiceTaskRegistry serviceTaskRegistry;
|
||||
private static final ServiceTaskRegistry serviceTaskRegistry = new ServiceTaskRegistry();
|
||||
/**
|
||||
* The {@link ModuleRegistry}
|
||||
*/
|
||||
private final ModuleRegistry moduleRegistry;
|
||||
private static final ModuleRegistry moduleRegistry = new ModuleRegistry();
|
||||
/**
|
||||
* The {@link GroupRegistry}
|
||||
*/
|
||||
private final GroupRegistry groupRegistry;
|
||||
private static final GroupRegistry groupRegistry = new GroupRegistry();
|
||||
/**
|
||||
* The {@link ConfigRegistry}
|
||||
*/
|
||||
private final ConfigRegistry configRegistry;
|
||||
private static final ConfigRegistry configRegistry = new ConfigRegistry();
|
||||
|
||||
/**
|
||||
* Constructs a new Registration object and initializes all registries.
|
||||
*/
|
||||
Registration()
|
||||
private Registration()
|
||||
{
|
||||
this.eventRegistry = new EventRegistry();
|
||||
this.userRegistry = new UserRegistry();
|
||||
this.serviceTaskRegistry = new ServiceTaskRegistry();
|
||||
this.moduleRegistry = new ModuleRegistry();
|
||||
this.groupRegistry = new GroupRegistry();
|
||||
this.configRegistry = new ConfigRegistry();
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link ModuleRegistry}
|
||||
*/
|
||||
public ModuleRegistry getModuleRegistry()
|
||||
public static ModuleRegistry getModuleRegistry()
|
||||
{
|
||||
return moduleRegistry;
|
||||
}
|
||||
@ -65,7 +56,7 @@ public class Registration
|
||||
/**
|
||||
* @return The {@link EventRegistry}
|
||||
*/
|
||||
public EventRegistry getEventRegistry()
|
||||
public static EventRegistry getEventRegistry()
|
||||
{
|
||||
return eventRegistry;
|
||||
}
|
||||
@ -73,7 +64,7 @@ public class Registration
|
||||
/**
|
||||
* @return The {@link UserRegistry}
|
||||
*/
|
||||
public UserRegistry getUserRegistry()
|
||||
public static UserRegistry getUserRegistry()
|
||||
{
|
||||
return userRegistry;
|
||||
}
|
||||
@ -81,7 +72,7 @@ public class Registration
|
||||
/**
|
||||
* @return The {@link ServiceTaskRegistry}
|
||||
*/
|
||||
public ServiceTaskRegistry getServiceTaskRegistry()
|
||||
public static ServiceTaskRegistry getServiceTaskRegistry()
|
||||
{
|
||||
return serviceTaskRegistry;
|
||||
}
|
||||
@ -89,7 +80,7 @@ public class Registration
|
||||
/**
|
||||
* @return The {@link GroupRegistry}
|
||||
*/
|
||||
public GroupRegistry getGroupRegistry()
|
||||
public static GroupRegistry getGroupRegistry()
|
||||
{
|
||||
return groupRegistry;
|
||||
}
|
||||
@ -97,8 +88,8 @@ public class Registration
|
||||
/**
|
||||
* @return The {@link ConfigRegistry}
|
||||
*/
|
||||
public ConfigRegistry getConfigRegistry()
|
||||
public static ConfigRegistry getConfigRegistry()
|
||||
{
|
||||
return configRegistry;
|
||||
}
|
||||
}
|
||||
}
|
@ -13,18 +13,14 @@ public final class Shortcuts
|
||||
|
||||
public static <T extends JavaPlugin> T provideModule(final Class<T> pluginClass)
|
||||
{
|
||||
return Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getModuleRegistry()
|
||||
.getProvider(pluginClass)
|
||||
.getModule();
|
||||
return Registration.getModuleRegistry()
|
||||
.getProvider(pluginClass)
|
||||
.getModule();
|
||||
}
|
||||
|
||||
public static User getUser(final Player player)
|
||||
{
|
||||
return Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getUserRegistry()
|
||||
return Registration.getUserRegistry()
|
||||
.getUser(player);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fns.patchwork.display.adminchat;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.security.Groups;
|
||||
import fns.patchwork.user.UserData;
|
||||
@ -24,9 +25,9 @@ public class AdminChatDisplay
|
||||
private final Map<UUID, AdminChatFormat> adminChatFormat = new HashMap<>();
|
||||
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)
|
||||
@ -101,11 +102,11 @@ public class AdminChatDisplay
|
||||
{
|
||||
private final AdminChatDisplay display;
|
||||
|
||||
public ACListener(final AdminChatDisplay display)
|
||||
public ACListener(final AdminChatDisplay display, final Patchwork patchwork)
|
||||
{
|
||||
this.display = display;
|
||||
Bukkit.getPluginManager()
|
||||
.registerEvents(this, Shortcuts.provideModule(Patchwork.class));
|
||||
.registerEvents(this, patchwork);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -124,9 +125,7 @@ public class AdminChatDisplay
|
||||
final Player player = event.getPlayer();
|
||||
if (player.hasPermission(ACPERM))
|
||||
{
|
||||
final UserData data = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getUserRegistry()
|
||||
final UserData data = Registration.getUserRegistry()
|
||||
.fromPlayer(player);
|
||||
if (data.hasCustomACFormat())
|
||||
{
|
||||
|
@ -160,7 +160,6 @@ public class ContextProvider
|
||||
*
|
||||
* @param string The string to parse
|
||||
* @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)
|
||||
{
|
||||
|
@ -25,12 +25,12 @@ public class FreedomExecutor
|
||||
/**
|
||||
* Creates a new {@link FreedomExecutor} instance.
|
||||
*/
|
||||
public FreedomExecutor()
|
||||
public FreedomExecutor(final Patchwork patchwork)
|
||||
{
|
||||
syncExecutor = r -> Bukkit.getScheduler()
|
||||
.runTask(Patchwork.getInstance(), r);
|
||||
.runTask(patchwork, r);
|
||||
asyncExecutor = r -> Bukkit.getScheduler()
|
||||
.runTaskAsynchronously(Patchwork.getInstance(), r);
|
||||
.runTaskAsynchronously(patchwork, r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,8 @@
|
||||
package fns.patchwork.shop;
|
||||
|
||||
import fns.patchwork.base.Patchwork;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.display.BossBarDisplay;
|
||||
import fns.patchwork.display.BossBarTimer;
|
||||
import fns.patchwork.economy.EconomicEntity;
|
||||
@ -36,7 +38,7 @@ public class ReactionTask extends Task implements Listener
|
||||
}
|
||||
|
||||
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
|
||||
@ -45,9 +47,7 @@ public class ReactionTask extends Task implements Listener
|
||||
if (event.message()
|
||||
.equals(reaction.getReactionMessage()))
|
||||
{
|
||||
final EconomicEntity entity = Patchwork.getInstance()
|
||||
.getRegistrations()
|
||||
.getUserRegistry()
|
||||
final EconomicEntity entity = Registration.getUserRegistry()
|
||||
.getUser(event.getPlayer());
|
||||
|
||||
reaction.onReact(entity);
|
||||
|
@ -1,5 +1,6 @@
|
||||
name: Patchwork
|
||||
main: me.totalfreedom.base.CommonsBase
|
||||
main: fns.patchwork.base.Patchwork
|
||||
api-version: 1.20
|
||||
version: 1.0.0
|
||||
author: TotalFreedom
|
||||
description: The Core of Freedom Network Suite
|
Loading…
Reference in New Issue
Block a user