mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-06-27 11:56:40 +00:00
Datura - Data Manager
This commit is contained in:
@ -9,6 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class CommonsBase extends JavaPlugin
|
||||
{
|
||||
private final EventBus eventBus = new EventBus(this);
|
||||
private final Registration registration = new Registration();
|
||||
|
||||
public static CommonsBase getInstance()
|
||||
{
|
||||
@ -34,4 +35,8 @@ public class CommonsBase extends JavaPlugin
|
||||
{
|
||||
return Bukkit.getServicesManager().getRegistration(EventBus.class);
|
||||
}
|
||||
|
||||
public Registration getRegistrations() {
|
||||
return registration;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package me.totalfreedom.base;
|
||||
|
||||
import me.totalfreedom.data.CommandRegistry;
|
||||
import me.totalfreedom.data.EventRegistry;
|
||||
import me.totalfreedom.data.ServiceRegistry;
|
||||
import me.totalfreedom.data.UserRegistry;
|
||||
import me.totalfreedom.data.*;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
@ -11,6 +8,7 @@ public class Registration
|
||||
private final EventRegistry eventRegistry;
|
||||
private final UserRegistry userRegistry;
|
||||
private final ServiceRegistry serviceRegistry;
|
||||
private final ModuleRegistry moduleRegistry;
|
||||
|
||||
public Registration()
|
||||
{
|
||||
@ -18,6 +16,12 @@ public class Registration
|
||||
this.eventRegistry = new EventRegistry();
|
||||
this.userRegistry = new UserRegistry();
|
||||
this.serviceRegistry = new ServiceRegistry();
|
||||
this.moduleRegistry = new ModuleRegistry();
|
||||
}
|
||||
|
||||
public ModuleRegistry getModuleRegistry()
|
||||
{
|
||||
return moduleRegistry;
|
||||
}
|
||||
|
||||
public CommandRegistry getCommandRegistry()
|
||||
|
@ -7,17 +7,17 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
public interface Node
|
||||
{
|
||||
String getKey();
|
||||
String key();
|
||||
|
||||
boolean getValue();
|
||||
boolean value();
|
||||
|
||||
Permission bukkit();
|
||||
|
||||
NodeType getType();
|
||||
NodeType type();
|
||||
|
||||
boolean compare(Node node);
|
||||
|
||||
long getExpiry();
|
||||
long expiry();
|
||||
|
||||
boolean isExpired();
|
||||
|
||||
@ -25,7 +25,7 @@ public interface Node
|
||||
|
||||
boolean isTemporary();
|
||||
|
||||
boolean isWildcard();
|
||||
boolean wildcard();
|
||||
|
||||
boolean isNegated();
|
||||
boolean negated();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -8,11 +9,13 @@ public interface SQL
|
||||
{
|
||||
CompletableFuture<Connection> getConnection(String url);
|
||||
|
||||
CompletableFuture<PreparedStatement> prepareStatement(String query, Object... args);
|
||||
|
||||
CompletableFuture<ResultSet> executeQuery(String query, Object... args);
|
||||
|
||||
CompletableFuture<Boolean> executeUpdate(String query, Object... args);
|
||||
CompletableFuture<Integer> executeUpdate(String query, Object... args);
|
||||
|
||||
CompletableFuture<Void> execute(String query, Object... args);
|
||||
CompletableFuture<Boolean> execute(String query, Object... args);
|
||||
|
||||
CompletableFuture<Boolean> createTable(String table, String... columns);
|
||||
}
|
||||
|
131
Commons/src/main/java/me/totalfreedom/utils/FreedomLogger.java
Normal file
131
Commons/src/main/java/me/totalfreedom/utils/FreedomLogger.java
Normal file
@ -0,0 +1,131 @@
|
||||
package me.totalfreedom.utils;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FreedomLogger
|
||||
{
|
||||
private final Logger logger;
|
||||
private boolean debug = false;
|
||||
|
||||
private FreedomLogger(String moduleName)
|
||||
{
|
||||
this.logger = LoggerFactory.getLogger("FreedomNetworkSuite::" + moduleName);
|
||||
}
|
||||
|
||||
public static FreedomLogger getLogger(String moduleName)
|
||||
{
|
||||
return new FreedomLogger(moduleName);
|
||||
}
|
||||
|
||||
public void setDebugMode(boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log a message to the console.
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void info(String message)
|
||||
{
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log a message to the console,
|
||||
* while also returning a Component that could be used to
|
||||
* message a player.
|
||||
*
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component info(Supplier<String> message)
|
||||
{
|
||||
logger.info(message.get());
|
||||
return Component.text(message.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log a warning to the console.
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void warn(String message)
|
||||
{
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method logs an error message to the console.
|
||||
* It is highly recommended to deconstruct the stack trace and pass it
|
||||
* in a more readable format to this method.
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void error(String message)
|
||||
{
|
||||
logger.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log an exception directly to the console.
|
||||
*
|
||||
* @param th The exception to log.
|
||||
*/
|
||||
public void error(Throwable th)
|
||||
{
|
||||
logger.error("An error occurred:\n", th);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log an error message to the console,
|
||||
* while also returning a Component that could be used to
|
||||
* message a player. It is highly recommended that you deconstruct and limit
|
||||
* the stack trace before passing it to this method, if you are intending to
|
||||
* use it for player communication.
|
||||
*
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component error(Supplier<String> message)
|
||||
{
|
||||
logger.error(message.get());
|
||||
return Component.text(message.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log a debug message to the console.
|
||||
* This method will only log if debug mode is enabled.
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void debug(String message)
|
||||
{
|
||||
if (debug)
|
||||
logger.debug(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows you to log a debug message to the console,
|
||||
* while also returning a Component that could be used to
|
||||
* message a player. This method will only log if debug mode is enabled.
|
||||
* If debug mode is not enabled, this method will return an empty component.
|
||||
*
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component debug(Supplier<String> message)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
logger.debug(message.get());
|
||||
return Component.text(message.get());
|
||||
}
|
||||
return Component.empty();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user