mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-06-26 19:44:27 +00:00
Adjust to better align with code specs
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
package me.totalfreedom.base;
|
||||
|
||||
import me.totalfreedom.data.*;
|
||||
import me.totalfreedom.data.GroupRegistry;
|
||||
import me.totalfreedom.data.BanRegistry;
|
||||
import me.totalfreedom.data.ConfigRegistry;
|
||||
import me.totalfreedom.data.ModuleRegistry;
|
||||
import me.totalfreedom.data.ServiceRegistry;
|
||||
import me.totalfreedom.data.UserRegistry;
|
||||
import me.totalfreedom.data.EventRegistry;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
@ -9,6 +15,8 @@ public class Registration
|
||||
private final ServiceRegistry serviceRegistry;
|
||||
private final ModuleRegistry moduleRegistry;
|
||||
private final GroupRegistry groupRegistry;
|
||||
private final BanRegistry banRegistry;
|
||||
private final ConfigRegistry configRegistry;
|
||||
|
||||
public Registration()
|
||||
{
|
||||
@ -17,6 +25,8 @@ public class Registration
|
||||
this.serviceRegistry = new ServiceRegistry();
|
||||
this.moduleRegistry = new ModuleRegistry();
|
||||
this.groupRegistry = new GroupRegistry();
|
||||
this.banRegistry = new BanRegistry();
|
||||
this.configRegistry = new ConfigRegistry();
|
||||
}
|
||||
|
||||
public ModuleRegistry getModuleRegistry()
|
||||
@ -43,4 +53,14 @@ public class Registration
|
||||
{
|
||||
return groupRegistry;
|
||||
}
|
||||
|
||||
public BanRegistry getBanRegistry()
|
||||
{
|
||||
return banRegistry;
|
||||
}
|
||||
|
||||
public ConfigRegistry getConfigRegistry()
|
||||
{
|
||||
return configRegistry;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.command;
|
||||
|
||||
import jdk.jshell.MethodSnippet;
|
||||
import me.totalfreedom.api.Context;
|
||||
import me.totalfreedom.command.annotation.Subcommand;
|
||||
import me.totalfreedom.provider.ContextProvider;
|
||||
@ -14,11 +13,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitDelegator extends Command implements PluginIdentifiableCommand
|
||||
@ -41,7 +36,9 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args)
|
||||
public boolean execute(@NotNull final CommandSender sender,
|
||||
@NotNull final String commandLabel,
|
||||
@NotNull final String[] args)
|
||||
{
|
||||
if (commandLabel.isEmpty() || !commandLabel.equalsIgnoreCase(getName()))
|
||||
return false;
|
||||
@ -63,23 +60,26 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
ContextProvider provider = new ContextProvider();
|
||||
Set<Subcommand> nodes = command.getSubcommands().keySet();
|
||||
for (Subcommand node : nodes) {
|
||||
Class<?>[] argTypes = node.args();
|
||||
final ContextProvider provider = new ContextProvider();
|
||||
final Set<Subcommand> nodes = command.getSubcommands().keySet();
|
||||
for (final Subcommand node : nodes)
|
||||
{
|
||||
final Class<?>[] argTypes = node.args();
|
||||
if (argTypes.length != args.length)
|
||||
continue;
|
||||
|
||||
Object[] objects = new Object[0];
|
||||
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
Class<?> argType = argTypes[i];
|
||||
String arg = args[i];
|
||||
for (int i = 0; i < argTypes.length; i++)
|
||||
{
|
||||
final Class<?> argType = argTypes[i];
|
||||
final String arg = args[i];
|
||||
if (argType == String.class)
|
||||
continue;
|
||||
|
||||
Context<?> context = () -> provider.fromString(arg);
|
||||
if (!argType.isInstance(context.get())) {
|
||||
final Context<?> context = () -> provider.fromString(arg);
|
||||
if (!argType.isInstance(context.get()))
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
objects = Arrays.copyOf(objects, objects.length + 1);
|
||||
@ -98,7 +98,8 @@ public class BukkitDelegator extends Command implements PluginIdentifiableComman
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.getBaseMethodPair() != null) {
|
||||
if (command.getBaseMethodPair() != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
command.getBaseMethodPair().getValue().invoke(command, sender);
|
||||
|
@ -29,7 +29,7 @@ public abstract class CommandBase
|
||||
|
||||
if (this.getClass().isAnnotationPresent(Base.class))
|
||||
{
|
||||
Method method = Stream.of(this.getClass().getDeclaredMethods())
|
||||
final Method method = Stream.of(this.getClass().getDeclaredMethods())
|
||||
.filter(m -> m.isAnnotationPresent(Base.class))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("Base annotation present but no method found."));
|
||||
|
@ -1,14 +1,13 @@
|
||||
package me.totalfreedom.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CommandHandler
|
||||
{
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public CommandHandler(JavaPlugin plugin)
|
||||
public CommandHandler(final JavaPlugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -17,8 +16,9 @@ public class CommandHandler
|
||||
// We need to find a way to resolve PluginCommands so we can
|
||||
// set the executor and tab completer as necessary.
|
||||
// OR we need to find an alternative way to process tab completions.
|
||||
public <T extends CommandBase> void registerCommand(T command) {
|
||||
BukkitDelegator delegate = new BukkitDelegator(plugin, command);
|
||||
public <T extends CommandBase> void registerCommand(final T command)
|
||||
{
|
||||
final BukkitDelegator delegate = new BukkitDelegator(plugin, command);
|
||||
|
||||
Bukkit.getCommandMap().register(plugin.getName(), delegate);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.data;
|
||||
|
||||
import me.totalfreedom.security.ban.Ban;
|
||||
import me.totalfreedom.security.ban.BanID;
|
||||
import me.totalfreedom.sql.SQL;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -12,18 +11,18 @@ public class BanRegistry
|
||||
{
|
||||
private final List<Ban> bansList = new ArrayList<>();
|
||||
|
||||
public boolean addBan(Ban ban) {
|
||||
public boolean addBan(final Ban ban) {
|
||||
return bansList.add(ban);
|
||||
}
|
||||
|
||||
public boolean removeBan(Ban ban) {
|
||||
public boolean removeBan(final Ban ban) {
|
||||
return bansList.remove(ban);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Ban getBan(BanID banID)
|
||||
public Ban getBan(final BanID banID)
|
||||
{
|
||||
for (Ban ban : bansList)
|
||||
for (final Ban ban : bansList)
|
||||
{
|
||||
if (ban.getBanID().matches(banID))
|
||||
{
|
||||
|
@ -9,17 +9,17 @@ public class ConfigRegistry
|
||||
{
|
||||
private final Map<String, Configuration> configurationList = new HashMap<>();
|
||||
|
||||
public void register(String name, Configuration configuration)
|
||||
public void register(final String name, final Configuration configuration)
|
||||
{
|
||||
configurationList.put(name, configuration);
|
||||
}
|
||||
|
||||
public void unregister(String name)
|
||||
public void unregister(final String name)
|
||||
{
|
||||
configurationList.remove(name);
|
||||
}
|
||||
|
||||
public Configuration getConfiguration(String name)
|
||||
public Configuration getConfiguration(final String name)
|
||||
{
|
||||
return configurationList.get(name);
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ public class GroupRegistry
|
||||
this.groups = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean registerGroup(Group group) {
|
||||
public boolean registerGroup(final Group group) {
|
||||
return groups.add(group);
|
||||
}
|
||||
|
||||
public boolean unregisterGroup(Group group) {
|
||||
public boolean unregisterGroup(final Group group) {
|
||||
return groups.remove(group);
|
||||
}
|
||||
|
||||
public Group getGroup(String name) {
|
||||
PlainTextComponentSerializer s = PlainTextComponentSerializer.plainText();
|
||||
for (Group group : groups) {
|
||||
String n = s.serialize(group.getName());
|
||||
public Group getGroup(final String name) {
|
||||
final PlainTextComponentSerializer s = PlainTextComponentSerializer.plainText();
|
||||
for (final Group group : groups) {
|
||||
final String n = s.serialize(group.getName());
|
||||
if (n.equalsIgnoreCase(name)) {
|
||||
return group;
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ public class ModuleRegistry
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends JavaPlugin> ModuleProvider<T> getModule(Class<T> clazz)
|
||||
public <T extends JavaPlugin> ModuleProvider<T> getModule(final Class<T> clazz)
|
||||
{
|
||||
for (JavaPlugin plugin : plugins)
|
||||
for (final JavaPlugin plugin : plugins)
|
||||
{
|
||||
if (clazz.isInstance(plugin))
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public class ServiceRegistry
|
||||
|
||||
public void startAll()
|
||||
{
|
||||
for (Service service : this.services)
|
||||
for (final Service service : this.services)
|
||||
{
|
||||
service.start();
|
||||
}
|
||||
@ -28,7 +28,7 @@ public class ServiceRegistry
|
||||
|
||||
public void stopAll()
|
||||
{
|
||||
for (Service service : this.services)
|
||||
for (final Service service : this.services)
|
||||
{
|
||||
service.stop();
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class ServiceRegistry
|
||||
// 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)
|
||||
public <T extends Service> void register(final Plugin plugin, final T service)
|
||||
{
|
||||
this.services.add(service);
|
||||
if (!service.getClass().isInstance(service))
|
||||
@ -57,12 +57,12 @@ public class ServiceRegistry
|
||||
ServicePriority.Normal);
|
||||
}
|
||||
|
||||
public <T extends Service> RegisteredServiceProvider<T> getService(Class<T> clazz)
|
||||
public <T extends Service> RegisteredServiceProvider<T> getService(final Class<T> clazz)
|
||||
{
|
||||
return Bukkit.getServicesManager().getRegistration(clazz);
|
||||
}
|
||||
|
||||
public void unregister(Class<? extends Service> clazz, Service service)
|
||||
public void unregister(final Class<? extends Service> clazz, final Service service)
|
||||
{
|
||||
this.services.remove(service);
|
||||
Bukkit.getServicesManager().unregister(clazz, service);
|
||||
|
@ -15,17 +15,17 @@ public class UserRegistry
|
||||
this.userDataMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public UserData getUserData(User user)
|
||||
public UserData getUserData(final User user)
|
||||
{
|
||||
return userDataMap.get(user);
|
||||
}
|
||||
|
||||
public void registerUserData(User user, UserData userData)
|
||||
public void registerUserData(final User user, final UserData userData)
|
||||
{
|
||||
userDataMap.put(user, userData);
|
||||
}
|
||||
|
||||
public void unregisterUserData(User user)
|
||||
public void unregisterUserData(final User user)
|
||||
{
|
||||
userDataMap.remove(user);
|
||||
}
|
||||
|
@ -13,20 +13,20 @@ public class EventBus extends Service
|
||||
private final Set<FEvent> eventSet = new HashSet<>();
|
||||
private final SubscriptionBox<?> runningSubscriptions = new SubscriptionBox<>();
|
||||
|
||||
public EventBus(CommonsBase plugin)
|
||||
public EventBus(final CommonsBase plugin)
|
||||
{
|
||||
super("event_bus");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addEvent(FEvent event)
|
||||
public void addEvent(final FEvent event)
|
||||
{
|
||||
eventSet.add(event);
|
||||
}
|
||||
|
||||
public <T extends FEvent> T getEvent(Class<T> eventClass)
|
||||
public <T extends FEvent> T getEvent(final Class<T> eventClass)
|
||||
{
|
||||
FEvent e = eventSet.stream()
|
||||
final FEvent e = eventSet.stream()
|
||||
.filter(event -> event.getEventClass().equals(eventClass))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
@ -34,9 +34,9 @@ public class EventBus extends Service
|
||||
return eventClass.cast(e);
|
||||
}
|
||||
|
||||
public <T extends FEvent> EventSubscription<T> subscribe(Class<T> eventClass, Callback<T> callback)
|
||||
public <T extends FEvent> EventSubscription<T> subscribe(final Class<T> eventClass, final Callback<T> callback)
|
||||
{
|
||||
Context<T> eventContext = () -> eventSet.stream()
|
||||
final Context<T> eventContext = () -> eventSet.stream()
|
||||
.filter(event -> event.getEventClass().equals(eventClass))
|
||||
.findFirst()
|
||||
.map(eventClass::cast)
|
||||
@ -50,7 +50,7 @@ public class EventBus extends Service
|
||||
return new EventSubscription<>(eventContext.get(), callback);
|
||||
}
|
||||
|
||||
public void unsubscribe(EventSubscription<?> subscription)
|
||||
public void unsubscribe(final EventSubscription<?> subscription)
|
||||
{
|
||||
runningSubscriptions.removeSubscription(subscription);
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.totalfreedom.event;
|
||||
|
||||
import com.sun.source.tree.ContinueTree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -13,11 +11,11 @@ class SubscriptionBox<T extends FEvent>
|
||||
this.subscriptions = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addSubscription(EventSubscription<T> subscription) {
|
||||
public void addSubscription(final EventSubscription<T> subscription) {
|
||||
subscriptions.add(subscription);
|
||||
}
|
||||
|
||||
public void removeSubscription(EventSubscription<?> subscription) {
|
||||
public void removeSubscription(final EventSubscription<?> subscription) {
|
||||
subscriptions.remove(subscription);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public class ContextProvider
|
||||
{
|
||||
public Object fromString(String string)
|
||||
public Object fromString(final String string)
|
||||
{
|
||||
return Stream.of(toBoolean(string),
|
||||
toDouble(string),
|
||||
@ -31,7 +31,7 @@ public class ContextProvider
|
||||
.orElse(string);
|
||||
}
|
||||
|
||||
private @Nullable Boolean toBoolean(String string)
|
||||
private @Nullable Boolean toBoolean(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -42,7 +42,7 @@ public class ContextProvider
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Double toDouble(String string)
|
||||
private @Nullable Double toDouble(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -53,7 +53,7 @@ public class ContextProvider
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Integer toInt(String string)
|
||||
private @Nullable Integer toInt(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -64,7 +64,7 @@ public class ContextProvider
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Long toLong(String string)
|
||||
private @Nullable Long toLong(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -75,7 +75,7 @@ public class ContextProvider
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Float toFloat(String string)
|
||||
private @Nullable Float toFloat(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -86,12 +86,12 @@ public class ContextProvider
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Player toPlayer(String string)
|
||||
private @Nullable Player toPlayer(final String string)
|
||||
{
|
||||
return Bukkit.getPlayer(string);
|
||||
}
|
||||
|
||||
private @Nullable CommandSender toCommandSender(String string)
|
||||
private @Nullable CommandSender toCommandSender(final String string)
|
||||
{
|
||||
if (toPlayer(string) == null) return null;
|
||||
|
||||
@ -103,9 +103,9 @@ public class ContextProvider
|
||||
return Bukkit.getWorld(string);
|
||||
}
|
||||
|
||||
private @Nullable Location toLocation(String string)
|
||||
private @Nullable Location toLocation(final String string)
|
||||
{
|
||||
String[] split = string.split(",");
|
||||
final String[] split = string.split(",");
|
||||
if (split.length != 4 || toWorld(split[0]) == null) return null;
|
||||
if (toDouble(split[1]) == null
|
||||
|| toDouble(split[2]) == null
|
||||
@ -114,7 +114,7 @@ public class ContextProvider
|
||||
return new Location(toWorld(split[0]), toDouble(split[1]), toDouble(split[2]), toDouble(split[3]));
|
||||
}
|
||||
|
||||
private @NotNull Component toComponent(String string)
|
||||
private @NotNull Component toComponent(final String string)
|
||||
{
|
||||
return Component.text(string);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.service;
|
||||
|
||||
import me.totalfreedom.base.CommonsBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@ -26,7 +27,7 @@ public class FreedomExecutor
|
||||
return asyncExecutor;
|
||||
}
|
||||
|
||||
public Executor scheduled(long delay, long period)
|
||||
public Executor scheduled(final long delay, final long period)
|
||||
{
|
||||
return r -> Bukkit.getScheduler()
|
||||
.runTaskTimer(
|
||||
@ -36,7 +37,7 @@ public class FreedomExecutor
|
||||
period);
|
||||
}
|
||||
|
||||
public Executor scheduledAsync(long delay, long period)
|
||||
public Executor scheduledAsync(final long delay, final long period)
|
||||
{
|
||||
return r -> Bukkit.getScheduler()
|
||||
.runTaskTimerAsynchronously(
|
||||
@ -46,12 +47,12 @@ public class FreedomExecutor
|
||||
period);
|
||||
}
|
||||
|
||||
public void runSync(Task task)
|
||||
public void runSync(@NotNull final Task task)
|
||||
{
|
||||
getSync().execute(task);
|
||||
}
|
||||
|
||||
public void runAsync(Task task)
|
||||
public void runAsync(@NotNull final Task task)
|
||||
{
|
||||
getAsync().execute(task);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public abstract class Service
|
||||
private final String name;
|
||||
private boolean isActive = false;
|
||||
|
||||
protected Service(String name)
|
||||
protected Service(final String name)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
|
@ -7,15 +7,15 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface SQL
|
||||
{
|
||||
CompletableFuture<Connection> getConnection(String url);
|
||||
CompletableFuture<Connection> getConnection(final String url);
|
||||
|
||||
CompletableFuture<PreparedStatement> prepareStatement(String query, Object... args);
|
||||
CompletableFuture<PreparedStatement> prepareStatement(final String query, final Object... args);
|
||||
|
||||
CompletableFuture<ResultSet> executeQuery(String query, Object... args);
|
||||
CompletableFuture<ResultSet> executeQuery(final String query, final Object... args);
|
||||
|
||||
CompletableFuture<Integer> executeUpdate(String query, Object... args);
|
||||
CompletableFuture<Integer> executeUpdate(final String query, final Object... args);
|
||||
|
||||
CompletableFuture<Boolean> execute(String query, Object... args);
|
||||
CompletableFuture<Boolean> execute(final String query, final Object... args);
|
||||
|
||||
CompletableFuture<Boolean> createTable(String table, String... columns);
|
||||
CompletableFuture<Boolean> createTable(final String table, final String... columns);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public interface SQLProperties
|
||||
|
||||
default Properties getDefaultProperties()
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
final Properties properties = new Properties();
|
||||
properties.setProperty("driver", "sqlite");
|
||||
properties.setProperty("host", "localhost");
|
||||
properties.setProperty("port", "3306");
|
||||
|
@ -11,17 +11,17 @@ public class FreedomLogger
|
||||
private final Logger logger;
|
||||
private boolean debug = false;
|
||||
|
||||
private FreedomLogger(String moduleName)
|
||||
private FreedomLogger(final String moduleName)
|
||||
{
|
||||
this.logger = LoggerFactory.getLogger("FreedomNetworkSuite::" + moduleName);
|
||||
}
|
||||
|
||||
public static FreedomLogger getLogger(String moduleName)
|
||||
public static FreedomLogger getLogger(final String moduleName)
|
||||
{
|
||||
return new FreedomLogger(moduleName);
|
||||
}
|
||||
|
||||
public void setDebugMode(boolean debug)
|
||||
public void setDebugMode(final boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class FreedomLogger
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void info(String message)
|
||||
public void info(final String message)
|
||||
{
|
||||
logger.info(message);
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class FreedomLogger
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component info(Supplier<String> message)
|
||||
public Component info(final Supplier<String> message)
|
||||
{
|
||||
logger.info(message.get());
|
||||
return Component.text(message.get());
|
||||
@ -55,7 +55,7 @@ public class FreedomLogger
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void warn(String message)
|
||||
public void warn(final String message)
|
||||
{
|
||||
logger.warn(message);
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class FreedomLogger
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void error(String message)
|
||||
public void error(final String message)
|
||||
{
|
||||
logger.error(message);
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class FreedomLogger
|
||||
*
|
||||
* @param th The exception to log.
|
||||
*/
|
||||
public void error(Throwable th)
|
||||
public void error(final Throwable th)
|
||||
{
|
||||
logger.error("An error occurred:\n", th);
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class FreedomLogger
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component error(Supplier<String> message)
|
||||
public Component error(final Supplier<String> message)
|
||||
{
|
||||
logger.error(message.get());
|
||||
return Component.text(message.get());
|
||||
@ -104,7 +104,7 @@ public class FreedomLogger
|
||||
*
|
||||
* @param message The message to send.
|
||||
*/
|
||||
public void debug(String message)
|
||||
public void debug(final String message)
|
||||
{
|
||||
if (debug)
|
||||
logger.debug(message);
|
||||
@ -119,7 +119,7 @@ public class FreedomLogger
|
||||
* @param message The message to send.
|
||||
* @return A component representation of the message.
|
||||
*/
|
||||
public Component debug(Supplier<String> message)
|
||||
public Component debug(final Supplier<String> message)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ public class Identity
|
||||
|
||||
private final UUID id;
|
||||
|
||||
public Identity(String key)
|
||||
public Identity(final String key)
|
||||
{
|
||||
this.key = key;
|
||||
this.id = UUID.nameUUIDFromBytes(key.getBytes());
|
||||
|
@ -1,14 +0,0 @@
|
||||
package me.totalfreedom.utils;
|
||||
|
||||
public class MICheck
|
||||
{
|
||||
public double maintainabilityIndex(double fileLength, double vocabulary, double cyclomaticComplexity, double linesOfCode) {
|
||||
double halsteadVolume = fileLength * (Math.log(vocabulary) / Math.log(2));
|
||||
double maintainabilityIndexUnbounded = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(linesOfCode);
|
||||
return Math.max(0, maintainabilityIndexUnbounded * 100 / 171);
|
||||
}
|
||||
|
||||
public double complexity(double decisionPoints) {
|
||||
return decisionPoints + 1;
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ public class Pair<K, V>
|
||||
private final K key;
|
||||
private final V value;
|
||||
|
||||
public Pair(K key, V value) {
|
||||
public Pair(final K key, final V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -13,24 +13,24 @@ public class Shaper
|
||||
private final double end;
|
||||
private final World world;
|
||||
|
||||
public Shaper(World world, double start, double end)
|
||||
public Shaper(final World world, final double start, final double end)
|
||||
{
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public List<Location> generate(int count, DoubleUnaryOperator x, DoubleUnaryOperator y, DoubleUnaryOperator z)
|
||||
public List<Location> generate(final int count, final DoubleUnaryOperator x, final DoubleUnaryOperator y, final DoubleUnaryOperator z)
|
||||
{
|
||||
double step = (start - end) / (count - 1);
|
||||
LinkedList<Location> lset = new LinkedList<>();
|
||||
final double step = (start - end) / (count - 1);
|
||||
final LinkedList<Location> lset = new LinkedList<>();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
double t = start + i * step;
|
||||
double xp = x.applyAsDouble(t);
|
||||
double yp = y.applyAsDouble(t);
|
||||
double zp = z.applyAsDouble(t);
|
||||
final double t = start + i * step;
|
||||
final double xp = x.applyAsDouble(t);
|
||||
final double yp = y.applyAsDouble(t);
|
||||
final double zp = z.applyAsDouble(t);
|
||||
|
||||
lset.add(new Location(world, xp, yp, zp));
|
||||
}
|
||||
|
Reference in New Issue
Block a user