mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2024-11-13 04:33:33 +00:00
Update content
This commit is contained in:
parent
c41b8dc084
commit
98d7ffafe3
12
.gitignore
vendored
12
.gitignore
vendored
@ -42,4 +42,14 @@ bin/
|
||||
.DS_Store
|
||||
|
||||
.idea
|
||||
/gradle
|
||||
/gradle
|
||||
.idea/codeStyles/codeStyleConfig.xml
|
||||
.idea/codeStyles/Project.xml
|
||||
.idea/dbnavigator.xml
|
||||
.idea/gradle.xml
|
||||
.idea/inspectionProfiles/Project_Default.xml
|
||||
.idea/misc.xml
|
||||
.idea/sonarlint/issuestore/index.pb
|
||||
.idea/sonarlint/securityhotspotstore/index.pb
|
||||
.idea/uiDesigner.xml
|
||||
.idea/vcs.xml
|
||||
|
@ -1,27 +0,0 @@
|
||||
package me.totalfreedom.admin;
|
||||
|
||||
import me.totalfreedom.permission.Group;
|
||||
import me.totalfreedom.permission.Node;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface AdminManager
|
||||
{
|
||||
Map<UUID, Administrator> getAdminMap();
|
||||
|
||||
Administrator getAdmin(UUID uuid);
|
||||
|
||||
Administrator getAdmin(String name);
|
||||
|
||||
Set<Administrator> getAdminsWithPermissions(Node... nodes);
|
||||
|
||||
void addAdmin(Administrator admin);
|
||||
|
||||
void removeAdmin(Administrator admin);
|
||||
|
||||
CompletableFuture<Void> saveAdmin(Administrator admin, Consumer<Administrator> callback);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.totalfreedom.admin;
|
||||
|
||||
import me.totalfreedom.permission.Group;
|
||||
import me.totalfreedom.permission.PermissionHolder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Administrator extends Group
|
||||
{
|
||||
boolean isActive();
|
||||
|
||||
void setActive(boolean active);
|
||||
|
||||
void setWeight(int weight);
|
||||
|
||||
Component getLoginMessage();
|
||||
|
||||
void setLoginMessage(Component loginMessage);
|
||||
}
|
@ -16,78 +16,106 @@ public interface Context<T>
|
||||
{
|
||||
T get();
|
||||
|
||||
default @Nullable Player asPlayer() {
|
||||
if (get() instanceof Player player) {
|
||||
default @Nullable Player asPlayer()
|
||||
{
|
||||
if (get() instanceof Player player)
|
||||
{
|
||||
return player;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable CommandSender asCommandSender() {
|
||||
if (get() instanceof CommandSender commandSender) {
|
||||
default @Nullable CommandSender asCommandSender()
|
||||
{
|
||||
if (get() instanceof CommandSender commandSender)
|
||||
{
|
||||
return commandSender;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @NotNull String asLiteral() {
|
||||
default @NotNull String asLiteral()
|
||||
{
|
||||
return get().toString();
|
||||
}
|
||||
|
||||
default @Nullable World asWorld() {
|
||||
if (get() instanceof World world) {
|
||||
default @Nullable World asWorld()
|
||||
{
|
||||
if (get() instanceof World world)
|
||||
{
|
||||
return world;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable Location asLocation() {
|
||||
if (get() instanceof Location location) {
|
||||
default @Nullable Location asLocation()
|
||||
{
|
||||
if (get() instanceof Location location)
|
||||
{
|
||||
return location;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable LivingEntity asLivingEntity() {
|
||||
if (get() instanceof LivingEntity livingEntity) {
|
||||
default @Nullable LivingEntity asLivingEntity()
|
||||
{
|
||||
if (get() instanceof LivingEntity livingEntity)
|
||||
{
|
||||
return livingEntity;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable Component asComponent() {
|
||||
if (get() instanceof Component component) {
|
||||
default @Nullable Component asComponent()
|
||||
{
|
||||
if (get() instanceof Component component)
|
||||
{
|
||||
return component;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable Projectile asProjectile() {
|
||||
if (get() instanceof Projectile projectile) {
|
||||
default @Nullable Projectile asProjectile()
|
||||
{
|
||||
if (get() instanceof Projectile projectile)
|
||||
{
|
||||
return projectile;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default @Nullable Action asAction() {
|
||||
if (get() instanceof Action action) {
|
||||
default @Nullable Action asAction()
|
||||
{
|
||||
if (get() instanceof Action action)
|
||||
{
|
||||
return action;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default <U> @Nullable U asCustom(Class<U> clazz) {
|
||||
if (clazz.isInstance(get())) {
|
||||
default <U> @Nullable U asCustom(Class<U> clazz)
|
||||
{
|
||||
if (clazz.isInstance(get()))
|
||||
{
|
||||
return clazz.cast(get());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
package me.totalfreedom.api;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface Interruptable
|
||||
{
|
||||
boolean canInterrupt();
|
||||
|
||||
void interrupt(Consumer<Throwable> callback);
|
||||
}
|
15
Commons/src/main/java/me/totalfreedom/api/Serializable.java
Normal file
15
Commons/src/main/java/me/totalfreedom/api/Serializable.java
Normal file
@ -0,0 +1,15 @@
|
||||
package me.totalfreedom.api;
|
||||
|
||||
public interface Serializable<T>
|
||||
{
|
||||
/**
|
||||
* Serialize an object to a string.
|
||||
* Ideally, this should serialize to an SQL query for easy data transfer.
|
||||
*
|
||||
* @param object The object to serialize
|
||||
* @return The serialized object
|
||||
*/
|
||||
String serialize(T object);
|
||||
|
||||
T deserialize(Context<?>... contexts);
|
||||
}
|
@ -1,52 +1,37 @@
|
||||
package me.totalfreedom.base;
|
||||
|
||||
import me.totalfreedom.event.EventBus;
|
||||
import me.totalfreedom.module.Module;
|
||||
import me.totalfreedom.utils.Identity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CommonsBase implements Module<CommonsBase>
|
||||
public class CommonsBase extends JavaPlugin
|
||||
{
|
||||
private final EventBus eventBus = new EventBus(this);
|
||||
|
||||
public static CommonsBase getInstance()
|
||||
{
|
||||
return JavaPlugin.getPlugin(CommonsBase.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
public void onEnable()
|
||||
{
|
||||
Bukkit.getServicesManager().register(EventBus.class,
|
||||
eventBus,
|
||||
JavaPlugin.getPlugin(CommonsJavaPlugin.class),
|
||||
this,
|
||||
ServicePriority.High);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
public void onDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identity getIdentity()
|
||||
public RegisteredServiceProvider<EventBus> getEventBus()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CommonsBase> getRuntimeClass()
|
||||
{
|
||||
return CommonsBase.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonsBase getRuntimeInstance()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public RegisteredServiceProvider<EventBus> getEventBus() {
|
||||
return Bukkit.getServicesManager().getRegistration(EventBus.class);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
package me.totalfreedom.base;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommonsJavaPlugin extends JavaPlugin
|
||||
{
|
||||
private final File moduleFolder = new File(getDataFolder(), "modules");
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Registration.getInstance()
|
||||
.getModuleRegistry()
|
||||
.unloadModules(moduleFolder);
|
||||
}
|
||||
}
|
@ -1,32 +1,23 @@
|
||||
package me.totalfreedom.base;
|
||||
|
||||
import me.totalfreedom.data.*;
|
||||
import me.totalfreedom.data.CommandRegistry;
|
||||
import me.totalfreedom.data.EventRegistry;
|
||||
import me.totalfreedom.data.ServiceRegistry;
|
||||
import me.totalfreedom.data.UserRegistry;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
private static final Registration INSTANCE = new Registration();
|
||||
private final ModuleRegistry moduleRegistry;
|
||||
private final CommandRegistry commandRegistry;
|
||||
private final EventRegistry eventRegistry;
|
||||
private final UserRegistry userRegistry;
|
||||
private final ServiceRegistry serviceRegistry;
|
||||
|
||||
private Registration() {
|
||||
public Registration()
|
||||
{
|
||||
this.commandRegistry = new CommandRegistry();
|
||||
this.eventRegistry = new EventRegistry();
|
||||
this.userRegistry = new UserRegistry();
|
||||
this.serviceRegistry = new ServiceRegistry();
|
||||
this.moduleRegistry = new ModuleRegistry();
|
||||
}
|
||||
|
||||
public static Registration getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public ModuleRegistry getModuleRegistry()
|
||||
{
|
||||
return moduleRegistry;
|
||||
}
|
||||
|
||||
public CommandRegistry getCommandRegistry()
|
||||
@ -48,8 +39,4 @@ public class Registration
|
||||
{
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
public CommonsBase getCommonsBase() {
|
||||
return getModuleRegistry().getModule(CommonsBase.class);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package me.totalfreedom.data;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import me.totalfreedom.base.CommonsJavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
|
||||
public class CommandRegistry
|
||||
{
|
||||
@ -16,7 +15,7 @@ public class CommandRegistry
|
||||
|
||||
public CommandRegistry()
|
||||
{
|
||||
this.manager = new PaperCommandManager(JavaPlugin.getPlugin(CommonsJavaPlugin.class));
|
||||
this.manager = new PaperCommandManager(CommonsBase.getInstance());
|
||||
this.contexts = new PaperCommandContexts(manager);
|
||||
this.completions = new PaperCommandCompletions(manager);
|
||||
this.replacements = manager.getCommandReplacements();
|
||||
@ -50,11 +49,13 @@ public class CommandRegistry
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public void register(BaseCommand cmd) {
|
||||
public void register(BaseCommand cmd)
|
||||
{
|
||||
manager.registerCommand(cmd);
|
||||
}
|
||||
|
||||
public void unregister(BaseCommand cmd) {
|
||||
public void unregister(BaseCommand cmd)
|
||||
{
|
||||
manager.unregisterCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,39 @@
|
||||
package me.totalfreedom.data;
|
||||
|
||||
import me.totalfreedom.event.FEvent;
|
||||
import me.totalfreedom.provider.EventProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EventRegistry
|
||||
{
|
||||
private final List<FEvent> events;
|
||||
|
||||
public EventRegistry()
|
||||
{
|
||||
this.events = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void register(final FEvent event)
|
||||
{
|
||||
this.events.add(event);
|
||||
}
|
||||
|
||||
public void unregister(final FEvent event)
|
||||
{
|
||||
this.events.remove(event);
|
||||
}
|
||||
|
||||
public <T extends FEvent> EventProvider<T> getEvent(final Class<T> clazz)
|
||||
{
|
||||
for (final FEvent event : this.events)
|
||||
{
|
||||
if (clazz.isInstance(event))
|
||||
{
|
||||
return () -> (T) event;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,89 +1,40 @@
|
||||
package me.totalfreedom.data;
|
||||
|
||||
import me.totalfreedom.module.Module;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import me.totalfreedom.provider.ModuleProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleRegistry
|
||||
{
|
||||
private final Set<Module<?>> moduleSet;
|
||||
private final List<JavaPlugin> plugins;
|
||||
|
||||
public ModuleRegistry()
|
||||
{
|
||||
this.moduleSet = new HashSet<>();
|
||||
this.plugins = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Set<? extends Module<?>> getModuleSet()
|
||||
public void addModule(final JavaPlugin plugin)
|
||||
{
|
||||
return moduleSet;
|
||||
}
|
||||
|
||||
public void addModule(Module<?> module)
|
||||
{
|
||||
moduleSet.add(module);
|
||||
}
|
||||
|
||||
public void removeModule(Module<?> module)
|
||||
{
|
||||
moduleSet.remove(module);
|
||||
if (this.plugins.contains(plugin))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.plugins.add(plugin);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getModule(Class<T> clazz)
|
||||
public <T extends JavaPlugin> ModuleProvider<T> getModule(Class<T> clazz)
|
||||
{
|
||||
for (Module<?> module : moduleSet)
|
||||
for (JavaPlugin plugin : plugins)
|
||||
{
|
||||
if (module.getRuntimeClass().equals(clazz))
|
||||
if (clazz.isInstance(plugin))
|
||||
{
|
||||
// We know that because the runtime class matches,
|
||||
// we can safely infer the type.
|
||||
return (T) module.getRuntimeInstance();
|
||||
return () -> (T) plugin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void enableModules()
|
||||
{
|
||||
for (Module<?> module : moduleSet)
|
||||
{
|
||||
module.enable();
|
||||
}
|
||||
}
|
||||
|
||||
public void disableModules()
|
||||
{
|
||||
for (Module<?> module : moduleSet)
|
||||
{
|
||||
module.disable();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLoaded(Class<Module<?>> module)
|
||||
{
|
||||
return moduleSet.stream()
|
||||
.anyMatch(m ->
|
||||
m.getRuntimeClass().equals(module));
|
||||
}
|
||||
|
||||
public void unloadModules(File dataFolder)
|
||||
{
|
||||
if (dataFolder.mkdirs()) return;
|
||||
for (Module<?> module : moduleSet)
|
||||
{
|
||||
module.disable();
|
||||
moduleSet.remove(module);
|
||||
}
|
||||
return () -> null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,64 @@
|
||||
package me.totalfreedom.data;
|
||||
|
||||
import me.totalfreedom.service.Service;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceRegistry
|
||||
{
|
||||
private final List<Service> services;
|
||||
|
||||
public ServiceRegistry()
|
||||
{
|
||||
this.services = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void startAll()
|
||||
{
|
||||
for (Service service : this.services)
|
||||
{
|
||||
service.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAll()
|
||||
{
|
||||
for (Service service : this.services)
|
||||
{
|
||||
service.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// Suppressing is fine here; we know that the service is of type T extends Service,
|
||||
// and calling getClass() on this object would effectively be Class<T>, though we may lose
|
||||
// the identity of the code signature in the process.
|
||||
// In this case, that is fine.
|
||||
public <T extends Service> void register(Plugin plugin, final T service)
|
||||
{
|
||||
this.services.add(service);
|
||||
if (!service.getClass().isInstance(service))
|
||||
{
|
||||
throw new UnknownError("""
|
||||
A critical issue has been encountered:
|
||||
The service %s is not an instance of itself.
|
||||
This is a critical issue and should be reported immediately.
|
||||
""".formatted(service.getClass().getName()));
|
||||
}
|
||||
Bukkit.getServicesManager().register(
|
||||
(Class<T>) service.getClass(),
|
||||
service,
|
||||
plugin,
|
||||
ServicePriority.Normal);
|
||||
}
|
||||
|
||||
public <T extends Service> RegisteredServiceProvider<T> getService(Class<T> clazz)
|
||||
{
|
||||
return Bukkit.getServicesManager().getRegistration(clazz);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
package me.totalfreedom.event;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import me.totalfreedom.base.CommonsJavaPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -18,11 +13,13 @@ public class EventBus
|
||||
private final Map<Listener, Set<FEvent>> listenerEventMap = new HashMap<>();
|
||||
private final CommonsBase plugin;
|
||||
|
||||
public EventBus(CommonsBase plugin) {
|
||||
public EventBus(CommonsBase plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
void registerListener(Listener listener) {
|
||||
void registerListener(Listener listener)
|
||||
{
|
||||
Set<FEvent> eventSet = Arrays.stream(listener.getClass().getDeclaredMethods())
|
||||
.filter(m -> m.isAnnotationPresent(Handler.class))
|
||||
.map(Executable::getParameters)
|
||||
@ -33,7 +30,8 @@ public class EventBus
|
||||
try
|
||||
{
|
||||
return (FEvent) p[0].getType().getDeclaredConstructor().newInstance();
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -44,19 +42,33 @@ public class EventBus
|
||||
listenerEventMap.put(listener, eventSet);
|
||||
}
|
||||
|
||||
void unregisterListener(Listener listener) {
|
||||
void unregisterListener(Listener listener)
|
||||
{
|
||||
listenerEventMap.remove(listener);
|
||||
}
|
||||
|
||||
public void startListening() {
|
||||
public void startListening()
|
||||
{
|
||||
listenerSet().forEach(this::registerListener);
|
||||
}
|
||||
|
||||
public void stopListening() {
|
||||
public void stopListening()
|
||||
{
|
||||
listenerSet().forEach(this::unregisterListener);
|
||||
}
|
||||
|
||||
public Set<Listener> listenerSet() {
|
||||
public Set<Listener> listenerSet()
|
||||
{
|
||||
return listenerSet;
|
||||
}
|
||||
|
||||
public Map<Listener, Set<FEvent>> listenerEventMap()
|
||||
{
|
||||
return listenerEventMap;
|
||||
}
|
||||
|
||||
public CommonsBase getCommonsBase()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package me.totalfreedom.event;
|
||||
|
||||
import me.totalfreedom.api.Context;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public interface FEvent
|
||||
public abstract class FEvent
|
||||
{
|
||||
void call(Context<?>... contexts);
|
||||
protected FEvent()
|
||||
{
|
||||
}
|
||||
|
||||
void cancel();
|
||||
public abstract void call(Context<?>... contexts);
|
||||
|
||||
public abstract void cancel();
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package me.totalfreedom.module;
|
||||
|
||||
import me.totalfreedom.utils.Identity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Module<T extends Module<?>>
|
||||
{
|
||||
Identity getIdentity();
|
||||
|
||||
Class<T> getRuntimeClass();
|
||||
|
||||
T getRuntimeInstance();
|
||||
|
||||
default void enable()
|
||||
{
|
||||
}
|
||||
|
||||
default void disable()
|
||||
{
|
||||
}
|
||||
|
||||
default Set<String> dependencies()
|
||||
{
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package me.totalfreedom.provider;
|
||||
|
||||
import me.totalfreedom.event.FEvent;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface EventProvider<T extends FEvent>
|
||||
{
|
||||
T getEvent();
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package me.totalfreedom.provider;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ModuleProvider<T extends JavaPlugin>
|
||||
{
|
||||
T getModule();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package me.totalfreedom.provider;
|
||||
|
||||
import me.totalfreedom.service.Service;
|
||||
|
||||
public interface ServiceProvider<T extends Service>
|
||||
{
|
||||
T getService();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.totalfreedom.permission;
|
||||
package me.totalfreedom.security;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.permission;
|
||||
package me.totalfreedom.security;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@ -12,7 +11,7 @@ public interface Node
|
||||
|
||||
boolean getValue();
|
||||
|
||||
Permission spigot();
|
||||
Permission bukkit();
|
||||
|
||||
NodeType getType();
|
||||
|
||||
@ -29,6 +28,4 @@ public interface Node
|
||||
boolean isWildcard();
|
||||
|
||||
boolean isNegated();
|
||||
|
||||
NodeBuilder builder();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.totalfreedom.permission;
|
||||
package me.totalfreedom.security;
|
||||
|
||||
public interface NodeBuilder
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package me.totalfreedom.permission;
|
||||
package me.totalfreedom.security;
|
||||
|
||||
public enum NodeType
|
||||
{
|
@ -1,16 +1,13 @@
|
||||
package me.totalfreedom.permission;
|
||||
package me.totalfreedom.security;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface PermissionHolder extends Permissible
|
||||
{
|
||||
PermissionHolder fromPlayer(Player player);
|
||||
|
||||
UUID getUniqueId();
|
||||
|
||||
Set<Node> permissions();
|
@ -1,12 +0,0 @@
|
||||
package me.totalfreedom.security;
|
||||
|
||||
public interface Verification
|
||||
{
|
||||
public boolean verify(String input);
|
||||
|
||||
public String getVerificationMessage();
|
||||
|
||||
public String getVerificationFailedMessage();
|
||||
|
||||
public String generateVerificationCode();
|
||||
}
|
16
Commons/src/main/java/me/totalfreedom/service/Service.java
Normal file
16
Commons/src/main/java/me/totalfreedom/service/Service.java
Normal file
@ -0,0 +1,16 @@
|
||||
package me.totalfreedom.service;
|
||||
|
||||
public abstract class Service
|
||||
{
|
||||
private final String name;
|
||||
|
||||
protected Service(String name)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
public abstract void start();
|
||||
|
||||
public abstract void stop();
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.service;
|
||||
|
||||
public interface FreedomService
|
||||
public interface Task extends Runnable
|
||||
{
|
||||
void start();
|
||||
|
@ -8,16 +8,10 @@ public interface SQL
|
||||
{
|
||||
CompletableFuture<Connection> getConnection(String url);
|
||||
|
||||
CompletableFuture<ResultSet> executeQuery(String query);
|
||||
|
||||
CompletableFuture<ResultSet> executeQuery(String query, Object... args);
|
||||
|
||||
CompletableFuture<Boolean> executeUpdate(String query);
|
||||
|
||||
CompletableFuture<Boolean> executeUpdate(String query, Object... args);
|
||||
|
||||
CompletableFuture<Void> execute(String query);
|
||||
|
||||
CompletableFuture<Void> execute(String query, Object... args);
|
||||
|
||||
CompletableFuture<Boolean> createTable(String table, String... columns);
|
||||
|
@ -7,7 +7,8 @@ public interface SQLProperties
|
||||
{
|
||||
Properties getProperties(File propertiesFile);
|
||||
|
||||
default Properties getDefaultProperties() {
|
||||
default Properties getDefaultProperties()
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("driver", "sqlite");
|
||||
properties.setProperty("host", "localhost");
|
||||
@ -30,7 +31,8 @@ public interface SQLProperties
|
||||
|
||||
String getPassword();
|
||||
|
||||
default String toURLPlain() {
|
||||
default String toURLPlain()
|
||||
{
|
||||
return String.format("jdbc:%s://%s:%s/%s",
|
||||
this.getDriver(),
|
||||
this.getHost(),
|
||||
@ -38,7 +40,8 @@ public interface SQLProperties
|
||||
this.getDatabase());
|
||||
}
|
||||
|
||||
default String toURLWithLogin() {
|
||||
default String toURLWithLogin()
|
||||
{
|
||||
return String.format("jdbc:%s://%s:%s/%s?user=%s&password=%s",
|
||||
this.getDriver(),
|
||||
this.getHost(),
|
||||
|
@ -1,10 +1,8 @@
|
||||
package me.totalfreedom.user;
|
||||
|
||||
import me.totalfreedom.permission.PermissionHolder;
|
||||
import me.totalfreedom.security.PermissionHolder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface User extends PermissionHolder
|
||||
{
|
||||
Component getDisplayName();
|
||||
|
Loading…
Reference in New Issue
Block a user