diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/AddonLoader.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/AddonLoader.java index 9c599a7..2dbc44b 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/AddonLoader.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/AddonLoader.java @@ -1,23 +1,11 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.addon; +import dev.unlegitdqrk.unlegitlibrary.addon.events.AddonLoadedEvent; import dev.unlegitdqrk.unlegitlibrary.addon.impl.Addon; import dev.unlegitdqrk.unlegitlibrary.event.EventListener; +import dev.unlegitdqrk.unlegitlibrary.event.EventManager; import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider; import java.io.File; @@ -31,13 +19,15 @@ import java.util.List; import java.util.Map; import java.util.jar.JarFile; -public class AddonLoader extends DefaultMethodsOverrider { +public final class AddonLoader extends DefaultMethodsOverrider { private final List addons; private final Map> loadedClasses; + private final EventManager eventManager; - public AddonLoader() { + public AddonLoader(EventManager eventManager) { this.addons = new ArrayList<>(); this.loadedClasses = new HashMap<>(); + this.eventManager = eventManager; } public final void loadAddonsFromDirectory(File addonFolder) throws IOException { @@ -66,6 +56,7 @@ public class AddonLoader extends DefaultMethodsOverrider { if (Addon.class.isAssignableFrom(clazz)) { Addon addon = (Addon) clazz.getDeclaredConstructor().newInstance(); addons.add(addon); + eventManager.executeEvent(new AddonLoadedEvent(addon)); } } catch (Exception exception) { exception.printStackTrace(); @@ -93,12 +84,12 @@ public class AddonLoader extends DefaultMethodsOverrider { addons.forEach(this::disableAddon); } - public final void registerEventListener(Addon addon, EventListener eventListener) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { + public final void registerEventListener(Addon addon, Class eventListener) throws Exception { if (!addons.contains(addon)) return; addon.registerEventListener(eventListener); } - public final void unregisterEventListener(Addon addon, EventListener eventListener) { + public final void unregisterEventListener(Addon addon, Class eventListener) { if (!addons.contains(addon)) return; addon.unregisterEventListener(eventListener); } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonDisabledEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonDisabledEvent.java index 4259851..17d7d8d 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonDisabledEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonDisabledEvent.java @@ -1,32 +1,22 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.addon.events; import dev.unlegitdqrk.unlegitlibrary.addon.impl.Addon; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; -public class AddonDisabledEvent extends Event { +public final class AddonDisabledEvent extends Event { - public final Addon addon; + private final Addon addon; public AddonDisabledEvent(Addon addon) { this.addon = addon; } + public Addon getAddon() { + return addon; + } + @Override protected final Object clone() throws CloneNotSupportedException { return super.clone(); diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonEnabledEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonEnabledEvent.java index 56adb9c..457a75a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonEnabledEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonEnabledEvent.java @@ -1,32 +1,22 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.addon.events; import dev.unlegitdqrk.unlegitlibrary.addon.impl.Addon; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; -public class AddonEnabledEvent extends Event { +public final class AddonEnabledEvent extends Event { - public final Addon addon; + private final Addon addon; public AddonEnabledEvent(Addon addon) { this.addon = addon; } + public Addon getAddon() { + return addon; + } + @Override protected final Object clone() throws CloneNotSupportedException { return super.clone(); diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonLoadedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonLoadedEvent.java new file mode 100644 index 0000000..df4a58a --- /dev/null +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/events/AddonLoadedEvent.java @@ -0,0 +1,37 @@ +package dev.unlegitdqrk.unlegitlibrary.addon.events; + +import dev.unlegitdqrk.unlegitlibrary.addon.impl.Addon; +import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; + +public final class AddonLoadedEvent extends Event { + + private final Addon addon; + + public AddonLoadedEvent(Addon addon) { + this.addon = addon; + } + + public Addon getAddon() { + return addon; + } + + @Override + protected final Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + @Override + public final boolean equals(Object obj) { + return super.equals(obj); + } + + @Override + public final String toString() { + return super.toString(); + } + + @Override + public final int hashCode() { + return super.hashCode(); + } +} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/Addon.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/Addon.java index 60f18b1..dfa3741 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/Addon.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/Addon.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.addon.impl; @@ -27,12 +13,10 @@ import java.lang.reflect.InvocationTargetException; public abstract class Addon { private final AddonInfo addonInfo; - private final EventManager eventManager; private boolean isEnabled = false; public Addon(AddonInfo addonInfo) { this.addonInfo = addonInfo; - this.eventManager = new EventManager(); } public final boolean isEnabled() { @@ -45,15 +29,15 @@ public abstract class Addon { public void executeEvent(Event event) { if (!isEnabled) return; - eventManager.executeEvent(event); + addonInfo.getEventManager().executeEvent(event); } - public final void registerEventListener(EventListener eventListener) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { - eventManager.registerListener(eventListener); + public final void registerEventListener(Class eventListener) throws Exception { + addonInfo.getEventManager().registerListener(eventListener); } - public final void unregisterEventListener(EventListener eventListener) { - eventManager.unregisterListener(eventListener); + public final void unregisterEventListener(Class eventListener) { + addonInfo.getEventManager().unregisterListener(eventListener); } public abstract void onEnable(); @@ -65,7 +49,7 @@ public abstract class Addon { isEnabled = true; onEnable(); - eventManager.executeEvent(new AddonEnabledEvent(this)); + addonInfo.getEventManager().executeEvent(new AddonEnabledEvent(this)); } public final void disable() { @@ -73,6 +57,6 @@ public abstract class Addon { isEnabled = false; onDisable(); - eventManager.executeEvent(new AddonDisabledEvent(this)); + addonInfo.getEventManager().executeEvent(new AddonDisabledEvent(this)); } } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/AddonInfo.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/AddonInfo.java index 84598a0..fa5b988 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/AddonInfo.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/addon/impl/AddonInfo.java @@ -1,31 +1,21 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.addon.impl; +import dev.unlegitdqrk.unlegitlibrary.event.EventManager; + public class AddonInfo { private final String name; private final String version; private final String author; + private final EventManager eventManager; - public AddonInfo(String name, String version, String author) { + public AddonInfo(String name, String version, String author, EventManager eventManager) { this.name = name; this.version = version; this.author = author; + this.eventManager = eventManager; } public final String getAuthor() { @@ -40,9 +30,13 @@ public class AddonInfo { return version; } + public final EventManager getEventManager() { + return eventManager; + } + @Override protected AddonInfo clone() throws CloneNotSupportedException { - return new AddonInfo(name, version, author); + return new AddonInfo(name, version, author, eventManager); } @Override diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/Command.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/Command.java index b837add..a8594ac 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/Command.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/Command.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command; @@ -22,10 +8,10 @@ import java.util.List; public abstract class Command { - public final CommandManager commandManager; - public final String name; - public final String description; - public final String usage; + private final CommandManager commandManager; + private final String name; + private final String description; + private final String usage; private final List permissions; private final List aliases; @@ -42,6 +28,22 @@ public abstract class Command { if (exists) throw new InstanceAlreadyExistsException("Command with this name or some alias alreadx exists!"); } + public final String getName() { + return name; + } + + public final CommandManager getCommandManager() { + return commandManager; + } + + public final String getDescription() { + return description; + } + + public final String getUsage() { + return usage; + } + public final List getPermissions() { return new ArrayList<>(permissions); } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandExecutor.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandExecutor.java index 212f9e8..10fa966 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandExecutor.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandExecutor.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command; @@ -23,7 +9,7 @@ import java.util.List; public abstract class CommandExecutor { - public final String name; + private final String name; private final List permissions; public CommandExecutor(String name, CommandPermission... permissions) { @@ -33,15 +19,19 @@ public abstract class CommandExecutor { this.permissions.addAll(Arrays.asList(permissions)); } - public List getPermissions() { + public final String getName() { + return name; + } + + public final List getPermissions() { return new ArrayList<>(permissions); } - public boolean hasPermission(CommandPermission permission) { + public final boolean hasPermission(CommandPermission permission) { return permissions.contains(permission); } - public boolean hasPermissions(List permissions) { + public final boolean hasPermissions(List permissions) { return new HashSet<>(this.permissions).containsAll(permissions); } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandManager.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandManager.java index 30242d1..efff3f4 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandManager.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandManager.java @@ -1,107 +1,94 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - package dev.unlegitdqrk.unlegitlibrary.command; import dev.unlegitdqrk.unlegitlibrary.command.events.*; import dev.unlegitdqrk.unlegitlibrary.event.EventManager; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.lang.reflect.InvocationTargetException; +import java.util.*; -public class CommandManager { +public final class CommandManager { - private final List commands; + private final Map, Command> commandInstances = new HashMap<>(); private final EventManager eventManager; public CommandManager(EventManager eventManager) { - this.commands = new ArrayList<>(); this.eventManager = eventManager; } - public final void registerCommand(Command command) { - if (this.commands.contains(command)) return; - this.commands.add(command); + // Registriere die Klasse, instanziiere sie einmalig + public final void registerCommand(Class commandClass) { + if (commandInstances.containsKey(commandClass)) return; + + try { + Command instance = commandClass.getDeclaredConstructor().newInstance(); + commandInstances.put(commandClass, instance); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); // Oder Logger verwenden + } } - public final void unregisterCommand(Command command) { - if (!this.commands.contains(command)) return; - this.commands.remove(command); + public final void unregisterCommand(Class commandClass) { + commandInstances.remove(commandClass); } public List getCommands() { - return new ArrayList<>(commands); + return new ArrayList<>(commandInstances.values()); } public Command getCommandByName(String name) { - for (Command command : commands) if (command.name.equals(name)) return command; - return null; - } - - public Command getCommandByAliases(List aliases) { - for (String alias : aliases) { - for (Command command : commands) { - List aliasesCommand = new ArrayList<>(); - for (String registeredAlias : command.getAliases()) aliasesCommand.add(registeredAlias.toLowerCase()); - if (aliasesCommand.contains(alias.toLowerCase())) return command; - } + for (Command cmd : commandInstances.values()) { + if (cmd.getName().equalsIgnoreCase(name)) return cmd; } - return null; } public Command getCommandByAlias(String alias) { - for (Command command : commands) { - List aliasesCommand = new ArrayList<>(); - for (String registeredAlias : command.getAliases()) aliasesCommand.add(registeredAlias.toLowerCase()); - if (aliasesCommand.contains(alias.toLowerCase())) return command; + for (Command cmd : commandInstances.values()) { + for (String a : cmd.getAliases()) { + if (a.equalsIgnoreCase(alias)) return cmd; + } } - return null; } public Command getCommand(String input) { - if (getCommandByName(input) != null) return getCommandByName(input); - if (getCommandByAlias(input) != null) return getCommandByAlias(input); - return null; + Command cmd = getCommandByName(input); + return (cmd != null) ? cmd : getCommandByAlias(input); } - public void execute(CommandExecutor commandExecutor, String line) { - String[] split = line.split(" "); - String command = split[0]; + public void execute(CommandExecutor executor, String line) { + String[] split = line.trim().split("\\s+"); + if (split.length == 0) return; + String commandLabel = split[0]; String[] args = Arrays.copyOfRange(split, 1, split.length); - if (getCommand(command) != null) { - Command cmd = getCommand(command); - PreCommandExecuteEvent preEvent = new PreCommandExecuteEvent(this, commandExecutor, cmd); - eventManager.executeEvent(preEvent); + Command command = getCommand(commandLabel); + if (command == null) { + eventManager.executeEvent(new CommandNotFoundEvent(this, executor, commandLabel, args)); + return; + } - if (preEvent.isCancelled()) return; + // Pre-execute event + PreCommandExecuteEvent preEvent = new PreCommandExecuteEvent(this, executor, command); + eventManager.executeEvent(preEvent); + if (preEvent.isCancelled()) return; - if (commandExecutor.hasPermissions(cmd.getPermissions())) { - CommandExecuteEvent event = new CommandExecuteEvent(this, commandExecutor, cmd); - eventManager.executeEvent(event); + // Check permissions + if (!executor.hasPermissions(command.getPermissions())) { + eventManager.executeEvent(new CommandExecutorMissingPermissionEvent(this, executor, command)); + return; + } - if (event.isCancelled()) return; + // Execute event + CommandExecuteEvent execEvent = new CommandExecuteEvent(this, executor, command); + eventManager.executeEvent(execEvent); + if (execEvent.isCancelled()) return; - cmd.execute(commandExecutor, command, args); - eventManager.executeEvent(new CommandExecutedEvent(this, commandExecutor, cmd)); - } else eventManager.executeEvent(new CommandExecutorMissingPermissionEvent(this, commandExecutor, cmd)); - } else eventManager.executeEvent(new CommandNotFoundEvent(this, commandExecutor, command, args)); + // Execute command + command.execute(executor, commandLabel, args); + + // Post-execute event + eventManager.executeEvent(new CommandExecutedEvent(this, executor, command)); } } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandPermission.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandPermission.java index 61a543f..051ed1b 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandPermission.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/CommandPermission.java @@ -1,28 +1,7 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command; -public class CommandPermission { +public final record CommandPermission(String name, int level) { - public final String name; - public final int level; - - public CommandPermission(String name, int level) { - this.name = name; - this.level = level; - } } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecuteEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecuteEvent.java index eb7f6d7..364bc8a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecuteEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecuteEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command.events; @@ -21,10 +7,22 @@ import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.event.impl.CancellableEvent; -public class CommandExecuteEvent extends CancellableEvent { - public final CommandManager commandManager; - public final CommandExecutor commandExecutor; - public final Command command; +public final class CommandExecuteEvent extends CancellableEvent { + private final CommandManager commandManager; + private final CommandExecutor commandExecutor; + private final Command command; + + public CommandManager getCommandManager() { + return commandManager; + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public Command getCommand() { + return command; + } public CommandExecuteEvent(CommandManager commandManager, CommandExecutor commandExecutor, Command command) { this.commandManager = commandManager; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutedEvent.java index 6ed9b18..d92e9f2 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command.events; @@ -21,10 +7,22 @@ import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; -public class CommandExecutedEvent extends Event { - public final CommandManager commandManager; - public final CommandExecutor commandExecutor; - public final Command command; +public final class CommandExecutedEvent extends Event { + private final CommandManager commandManager; + private final CommandExecutor commandExecutor; + private final Command command; + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public CommandManager getCommandManager() { + return commandManager; + } + + public Command getCommand() { + return command; + } public CommandExecutedEvent(CommandManager commandManager, CommandExecutor commandExecutor, Command command) { this.commandManager = commandManager; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutorMissingPermissionEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutorMissingPermissionEvent.java index 3de5301..3c4425b 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutorMissingPermissionEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandExecutorMissingPermissionEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command.events; @@ -21,10 +7,22 @@ import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; -public class CommandExecutorMissingPermissionEvent extends Event { - public final CommandManager commandManager; - public final CommandExecutor commandExecutor; - public final Command command; +public final class CommandExecutorMissingPermissionEvent extends Event { + private final CommandManager commandManager; + private final CommandExecutor commandExecutor; + private final Command command; + + public CommandManager getCommandManager() { + return commandManager; + } + + public Command getCommand() { + return command; + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } public CommandExecutorMissingPermissionEvent(CommandManager commandManager, CommandExecutor commandExecutor, Command command) { this.commandManager = commandManager; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandNotFoundEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandNotFoundEvent.java index 93c54af..8b91059 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandNotFoundEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/CommandNotFoundEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command.events; @@ -20,11 +6,27 @@ import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; -public class CommandNotFoundEvent extends Event { - public final CommandManager commandManager; - public final CommandExecutor commandExecutor; - public final String name; - public final String[] args; +public final class CommandNotFoundEvent extends Event { + private final CommandManager commandManager; + private final CommandExecutor commandExecutor; + private final String name; + private final String[] args; + + public CommandManager getCommandManager() { + return commandManager; + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public String getName() { + return name; + } + + public String[] getArgs() { + return args; + } public CommandNotFoundEvent(CommandManager commandManager, CommandExecutor commandExecutor, String name, String[] args) { this.commandManager = commandManager; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/PreCommandExecuteEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/PreCommandExecuteEvent.java index 9f7b717..bbe32ea 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/PreCommandExecuteEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/command/events/PreCommandExecuteEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.command.events; @@ -21,10 +7,22 @@ import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.event.impl.CancellableEvent; -public class PreCommandExecuteEvent extends CancellableEvent { - public final CommandManager commandManager; - public final CommandExecutor commandExecutor; - public final Command command; +public final class PreCommandExecuteEvent extends CancellableEvent { + private final CommandManager commandManager; + private final CommandExecutor commandExecutor; + private final Command command; + + public Command getCommand() { + return command; + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public CommandManager getCommandManager() { + return commandManager; + } public PreCommandExecuteEvent(CommandManager commandManager, CommandExecutor commandExecutor, Command command) { this.commandManager = commandManager; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventListener.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventListener.java index 0d9b714..0ecbc46 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventListener.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventListener.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.event; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventManager.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventManager.java index f4f3eac..89c07a0 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventManager.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventManager.java @@ -1,19 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - package dev.unlegitdqrk.unlegitlibrary.event; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; @@ -21,141 +5,78 @@ import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; -public class EventManager extends DefaultMethodsOverrider { +public final class EventManager extends DefaultMethodsOverrider { - private final HashMap, HashMap>> registeredListener = new HashMap<>(); - private final HashMap eventListeners = new HashMap<>(); + private final Map, Map>> registeredListener = new HashMap<>(); + private final Map, Object> eventListeners = new HashMap<>(); - public final void registerListener(EventListener listenerClass) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + public final void registerListener(Class listenerClass) throws Exception { if (isListenerRegistered(listenerClass)) return; - for (Method method : listenerClass.getClass().getDeclaredMethods()) { - Listener listener = method.getAnnotation(Listener.class); + Object instance = listenerClass.getDeclaredConstructor().newInstance(); - if (listener == null) continue; + for (Method method : listenerClass.getDeclaredMethods()) { + Listener listenerAnnotation = method.getAnnotation(Listener.class); - if (method.getParameterCount() == 1) { - Class eventClass = (Class) method.getParameterTypes()[0]; + if (listenerAnnotation == null || method.getParameterCount() != 1) continue; - HashMap> list = registeredListener.getOrDefault(eventClass, new HashMap<>()); - HashMap set = list.getOrDefault(listener.priority(), new HashMap<>()); + Class paramType = method.getParameterTypes()[0]; + if (!Event.class.isAssignableFrom(paramType)) continue; - set.put(listenerClass, method); - list.put(listener.priority(), set); - registeredListener.put(eventClass, list); - } + @SuppressWarnings("unchecked") + Class eventClass = (Class) paramType; + + registeredListener + .computeIfAbsent(eventClass, k -> new EnumMap<>(EventPriority.class)) + .computeIfAbsent(listenerAnnotation.priority(), k -> new HashMap<>()) + .put(instance, method); } - eventListeners.put(listenerClass, listenerClass); + eventListeners.put(listenerClass, instance); } - public synchronized final void unregisterListener(EventListener listenerClass) { + public synchronized final void unregisterListener(Class listenerClass) { if (!isListenerRegistered(listenerClass)) return; - Object clazz = eventListeners.get(listenerClass); + Object instance = eventListeners.get(listenerClass); - synchronized (registeredListener) { - List> eventsToRemove = new ArrayList<>(); - - for (Map.Entry, HashMap>> entry : registeredListener.entrySet()) { - Class eventClass = entry.getKey(); - HashMap> priorityMap = entry.getValue(); - - if (priorityMap != null) { - synchronized (priorityMap) { - List prioritiesToRemove = new ArrayList<>(); - - for (Map.Entry> priorityEntry : priorityMap.entrySet()) { - EventPriority priority = priorityEntry.getKey(); - HashMap listeners = priorityEntry.getValue(); - - if (listeners != null) { - listeners.remove(clazz); - if (listeners.isEmpty()) { - prioritiesToRemove.add(priority); - } - } - } - - for (EventPriority priority : prioritiesToRemove) { - priorityMap.remove(priority); - } - - if (priorityMap.isEmpty()) { - eventsToRemove.add(eventClass); - } - } - } - } - - for (Class eventClass : eventsToRemove) { - registeredListener.remove(eventClass); + for (Map> priorityMap : registeredListener.values()) { + for (Map listeners : priorityMap.values()) { + listeners.remove(instance); } } + // Clean up empty entries + registeredListener.entrySet().removeIf(e -> + e.getValue().values().stream().allMatch(Map::isEmpty)); + eventListeners.remove(listenerClass); } - public final boolean isListenerRegistered(EventListener listenerClass) { + public final boolean isListenerRegistered(Class listenerClass) { return eventListeners.containsKey(listenerClass); } public final void executeEvent(Event event) { - HashMap> list = registeredListener.getOrDefault(event.getClass(), new HashMap<>()); + Map> listenersByPriority = registeredListener.get(event.getClass()); + if (listenersByPriority == null) return; - list.getOrDefault(EventPriority.LOWEST, new HashMap<>()).forEach((k, v) -> { - if (!isListenerRegistered((EventListener) k)) return; + for (EventPriority priority : EventPriority.values()) { + Map listeners = listenersByPriority.getOrDefault(priority, Collections.emptyMap()); - try { - v.invoke(k, event); - } catch (IllegalAccessException | InvocationTargetException exception) { - exception.printStackTrace(); + for (Map.Entry entry : listeners.entrySet()) { + Object instance = entry.getKey(); + Method method = entry.getValue(); + + try { + method.setAccessible(true); + method.invoke(instance, event); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } } - }); - - list.getOrDefault(EventPriority.LOW, new HashMap<>()).forEach((k, v) -> { - if (!isListenerRegistered((EventListener) k)) return; - - try { - v.invoke(k, event); - } catch (IllegalAccessException | InvocationTargetException exception) { - exception.printStackTrace(); - } - }); - - list.getOrDefault(EventPriority.NORMAL, new HashMap<>()).forEach((k, v) -> { - if (!isListenerRegistered((EventListener) k)) return; - - try { - v.invoke(k, event); - } catch (IllegalAccessException | InvocationTargetException exception) { - exception.printStackTrace(); - } - }); - - list.getOrDefault(EventPriority.HIGH, new HashMap<>()).forEach((k, v) -> { - if (!isListenerRegistered((EventListener) k)) return; - - try { - v.invoke(k, event); - } catch (IllegalAccessException | InvocationTargetException exception) { - exception.printStackTrace(); - } - }); - - list.getOrDefault(EventPriority.HIGHEST, new HashMap<>()).forEach((k, v) -> { - if (!isListenerRegistered((EventListener) k)) return; - - try { - v.invoke(k, event); - } catch (IllegalAccessException | InvocationTargetException exception) { - exception.printStackTrace(); - } - }); + } } -} \ No newline at end of file +} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventPriority.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventPriority.java index 6eaa010..d850c1e 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventPriority.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/EventPriority.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.event; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/Listener.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/Listener.java index bc08a1c..ebdcbaa 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/Listener.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/Listener.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.event; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/CancellableEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/CancellableEvent.java index 3796602..04da13c 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/CancellableEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/CancellableEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.event.impl; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/Event.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/Event.java index 58698be..2466f78 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/Event.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/event/impl/Event.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.event.impl; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ClassDefiner.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ClassDefiner.java index c4f46cf..94d27e4 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ClassDefiner.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ClassDefiner.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.file; @@ -22,7 +8,7 @@ import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; -public class ClassDefiner extends DefaultMethodsOverrider { +public final class ClassDefiner extends DefaultMethodsOverrider { private static final Map loaders = Collections.synchronizedMap(new WeakHashMap<>()); diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ConfigurationManager.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ConfigurationManager.java index 1ce3d98..553ee6a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ConfigurationManager.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ConfigurationManager.java @@ -1,10 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.file; @@ -17,7 +10,7 @@ import java.io.IOException; import java.util.*; import java.util.stream.Collectors; -public class ConfigurationManager extends DefaultMethodsOverrider { +public final class ConfigurationManager extends DefaultMethodsOverrider { private final Properties properties = new Properties(); private final File configFile; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/FileUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/FileUtils.java index 6b483f8..47c00c3 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/FileUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/FileUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.file; @@ -31,7 +17,7 @@ import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -public class FileUtils extends DefaultMethodsOverrider { +public final class FileUtils extends DefaultMethodsOverrider { public static String getSuffix(File file) { String[] splitName = file.getName().split("\\."); diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ReflectUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ReflectUtils.java index e982673..008d1bb 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ReflectUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/file/ReflectUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.file; @@ -23,7 +9,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; -public class ReflectUtils extends DefaultMethodsOverrider { +public final class ReflectUtils extends DefaultMethodsOverrider { public static Method getMethodByArgs(final Class clazz, final Class... args) { for (Method method : clazz.getDeclaredMethods()) diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/NetworkClient.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/NetworkClient.java index befe560..50f2b40 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/NetworkClient.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/NetworkClient.java @@ -1,10 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedEvent.java index 38b6df8..e1c7624 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; -public class C_PacketReceivedEvent extends Event { - public final NetworkClient networkClient; - public final Packet packet; +public final class C_PacketReceivedEvent extends Event { + private final NetworkClient networkClient; + private final Packet packet; + + public NetworkClient getNetworkClient() { + return networkClient; + } + + public Packet getPacket() { + return packet; + } public C_PacketReceivedEvent(NetworkClient networkClient, Packet packet) { this.networkClient = networkClient; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedFailedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedFailedEvent.java index 0fabf1b..bd93cc3 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedFailedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketReceivedFailedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; -public class C_PacketReceivedFailedEvent extends Event { - public final NetworkClient networkClient; - public final Packet packet; +public final class C_PacketReceivedFailedEvent extends Event { + private final NetworkClient networkClient; + private final Packet packet; + + public NetworkClient getNetworkClient() { + return networkClient; + } + + public Packet getPacket() { + return packet; + } public C_PacketReceivedFailedEvent(NetworkClient networkClient, Packet packet) { this.networkClient = networkClient; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendEvent.java index 0f0e53b..b49f27a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; -public class C_PacketSendEvent extends Event { - public final NetworkClient networkClient; - public final Packet packet; +public final class C_PacketSendEvent extends Event { + private final NetworkClient networkClient; + private final Packet packet; + + public NetworkClient getNetworkClient() { + return networkClient; + } + + public Packet getPacket() { + return packet; + } public C_PacketSendEvent(NetworkClient networkClient, Packet packet) { this.networkClient = networkClient; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendFailedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendFailedEvent.java index dbcfc9e..b08e07f 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendFailedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_PacketSendFailedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; @@ -20,9 +6,18 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; -public class C_PacketSendFailedEvent extends Event { - public final NetworkClient networkClient; - public final Packet packet; +public final class C_PacketSendFailedEvent extends Event { + private final NetworkClient networkClient; + private final Packet packet; + + + public NetworkClient getNetworkClient() { + return networkClient; + } + + public Packet getPacket() { + return packet; + } public C_PacketSendFailedEvent(NetworkClient networkClient, Packet packet) { this.networkClient = networkClient; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_UnknownObjectReceivedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_UnknownObjectReceivedEvent.java index e79f2fa..3140422 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_UnknownObjectReceivedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/C_UnknownObjectReceivedEvent.java @@ -1,27 +1,21 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; -public class C_UnknownObjectReceivedEvent extends Event { - public final NetworkClient networkClient; - public final Object received; +public final class C_UnknownObjectReceivedEvent extends Event { + private final NetworkClient networkClient; + private final Object received; + + public NetworkClient getNetworkClient() { + return networkClient; + } + + public Object getReceived() { + return received; + } public C_UnknownObjectReceivedEvent(NetworkClient networkClient, Object received) { this.networkClient = networkClient; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientConnectedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientConnectedEvent.java index f58b689..b7f4819 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientConnectedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientConnectedEvent.java @@ -1,26 +1,17 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; -public class ClientConnectedEvent extends Event { - public final NetworkClient client; +public final class ClientConnectedEvent extends Event { + private final NetworkClient client; + + + public NetworkClient getClient() { + return client; + } public ClientConnectedEvent(NetworkClient client) { this.client = client; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientDisconnectedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientDisconnectedEvent.java index f663d16..a79994d 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientDisconnectedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/client/events/ClientDisconnectedEvent.java @@ -1,26 +1,16 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.client.events; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient; -public class ClientDisconnectedEvent extends Event { - public final NetworkClient client; +public final class ClientDisconnectedEvent extends Event { + private final NetworkClient client; + + public NetworkClient getClient() { + return client; + } public ClientDisconnectedEvent(NetworkClient client) { this.client = client; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/Packet.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/Packet.java index f71cc3e..92ed89b 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/Packet.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/Packet.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.packets; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/PacketHandler.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/PacketHandler.java index 1609fd1..d5ccb67 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/PacketHandler.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/PacketHandler.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.packets; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/impl/ClientIDPacket.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/impl/ClientIDPacket.java index 8a26002..68d9014 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/impl/ClientIDPacket.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/packets/impl/ClientIDPacket.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.packets.impl; @@ -23,7 +9,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -public class ClientIDPacket extends Packet { +public final class ClientIDPacket extends Packet { private int clientID; public ClientIDPacket() { diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/ConnectionHandler.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/ConnectionHandler.java index 487c5c4..65b816b 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/ConnectionHandler.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/ConnectionHandler.java @@ -1,10 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server; @@ -18,7 +11,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.SocketException; -public class ConnectionHandler { +public final class ConnectionHandler { private SSLSocket socket; private int clientID; private ObjectOutputStream outputStream; @@ -31,19 +24,19 @@ public class ConnectionHandler { return target.getClientID() == clientID; } - public SSLSocket getSocket() { + public final SSLSocket getSocket() { return socket; } - public ObjectOutputStream getOutputStream() { + public final ObjectOutputStream getOutputStream() { return outputStream; } - public ObjectInputStream getInputStream() { + public final ObjectInputStream getInputStream() { return inputStream; } - public NetworkServer getServer() { + public final NetworkServer getServer() { return server; } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/NetworkServer.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/NetworkServer.java index ac73752..edf6562 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/NetworkServer.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/NetworkServer.java @@ -1,10 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server; @@ -36,7 +29,7 @@ public final class NetworkServer { private final List connectionHandlers = new ArrayList<>(); private final Thread incomingThread = new Thread(this::incomingConnections); - public List getConnectionHandlers() { + public final List getConnectionHandlers() { return connectionHandlers; } @@ -51,7 +44,7 @@ public final class NetworkServer { return super.equals(obj); } - public int getPort() { + public final int getPort() { return port; } diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerConnectedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerConnectedEvent.java index ec968a5..0f290b6 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerConnectedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerConnectedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,7 +6,11 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; public final class ConnectionHandlerConnectedEvent extends Event { - public final ConnectionHandler connectionHandler; + private final ConnectionHandler connectionHandler; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } public ConnectionHandlerConnectedEvent(ConnectionHandler connectionHandler) { this.connectionHandler = connectionHandler; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerDisconnectedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerDisconnectedEvent.java index 2b2aaf8..d7d6019 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerDisconnectedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/ConnectionHandlerDisconnectedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,7 +6,12 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; public final class ConnectionHandlerDisconnectedEvent extends Event { - public final ConnectionHandler connectionHandler; + private final ConnectionHandler connectionHandler; + + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } public ConnectionHandlerDisconnectedEvent(ConnectionHandler connectionHandler) { this.connectionHandler = connectionHandler; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/IncomingConnectionEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/IncomingConnectionEvent.java index 414adab..60bb316 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/IncomingConnectionEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/IncomingConnectionEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -21,9 +7,17 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.server.NetworkServer; import javax.net.ssl.SSLSocket; -public class IncomingConnectionEvent extends CancellableEvent { - public final NetworkServer server; - public final SSLSocket socket; +public final class IncomingConnectionEvent extends CancellableEvent { + private final NetworkServer server; + private final SSLSocket socket; + + public SSLSocket getSocket() { + return socket; + } + + public NetworkServer getServer() { + return server; + } public IncomingConnectionEvent(NetworkServer server, SSLSocket socket) { this.server = server; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedEvent.java index fc116a0..3923633 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; -public class S_PacketReceivedEvent extends Event { - public final ConnectionHandler connectionHandler; - public final Packet packet; +public final class S_PacketReceivedEvent extends Event { + private final ConnectionHandler connectionHandler; + private final Packet packet; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } + + public Packet getPacket() { + return packet; + } public S_PacketReceivedEvent(ConnectionHandler connectionHandler, Packet packet) { this.connectionHandler = connectionHandler; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedFailedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedFailedEvent.java index 2750f55..623326f 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedFailedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketReceivedFailedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; -public class S_PacketReceivedFailedEvent extends Event { - public final ConnectionHandler connectionHandler; - public final Packet packet; +public final class S_PacketReceivedFailedEvent extends Event { + private final ConnectionHandler connectionHandler; + private final Packet packet; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } + + public Packet getPacket() { + return packet; + } public S_PacketReceivedFailedEvent(ConnectionHandler connectionHandler, Packet packet) { this.connectionHandler = connectionHandler; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendEvent.java index 6a4a134..a99ae83 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; -public class S_PacketSendEvent extends Event { - public final Packet packet; - public final ConnectionHandler connectionHandler; +public final class S_PacketSendEvent extends Event { + private final Packet packet; + private final ConnectionHandler connectionHandler; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } + + public Packet getPacket() { + return packet; + } public S_PacketSendEvent(Packet packet, ConnectionHandler connectionHandler) { this.packet = packet; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendFailedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendFailedEvent.java index c275f9c..c3f981a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendFailedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_PacketSendFailedEvent.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; @@ -20,9 +6,17 @@ import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; -public class S_PacketSendFailedEvent extends Event { - public final Packet packet; - public final ConnectionHandler connectionHandler; +public final class S_PacketSendFailedEvent extends Event { + private final Packet packet; + private final ConnectionHandler connectionHandler; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } + + public Packet getPacket() { + return packet; + } public S_PacketSendFailedEvent(Packet packet, ConnectionHandler connectionHandler) { this.packet = packet; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_UnknownObjectReceivedEvent.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_UnknownObjectReceivedEvent.java index 10137f4..a622e07 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_UnknownObjectReceivedEvent.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/system/server/events/S_UnknownObjectReceivedEvent.java @@ -1,28 +1,22 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.system.server.events; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler; -public class S_UnknownObjectReceivedEvent extends Event { +public final class S_UnknownObjectReceivedEvent extends Event { - public final Object received; - public final ConnectionHandler connectionHandler; + private final Object received; + private final ConnectionHandler connectionHandler; + + public ConnectionHandler getConnectionHandler() { + return connectionHandler; + } + + public Object getReceived() { + return received; + } public S_UnknownObjectReceivedEvent(Object received, ConnectionHandler connectionHandler) { this.received = received; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/InputStreamUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/InputStreamUtils.java index b2c090d..0398806 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/InputStreamUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/InputStreamUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/NetworkUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/NetworkUtils.java index c496699..584c660 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/NetworkUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/NetworkUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/PemUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/PemUtils.java index 041710c..0859dc0 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/PemUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/PemUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/WebUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/WebUtils.java index 607fbd4..d25beb8 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/WebUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/network/utils/WebUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.network.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Axis.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Axis.java deleted file mode 100644 index df37a7a..0000000 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Axis.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -package dev.unlegitdqrk.unlegitlibrary.number; - -public enum Axis { - X, Y, Z -} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/ByteUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/ByteUtils.java index a1076fc..3384220 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/ByteUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/ByteUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Modulo.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Modulo.java deleted file mode 100644 index 705dddc..0000000 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Modulo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -package dev.unlegitdqrk.unlegitlibrary.number; - -import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider; - -public class Modulo extends DefaultMethodsOverrider { - - public static int calculate(int number, int dividedBy) { - return number % dividedBy; - } - - public static float calculate(float number, float dividedBy) { - return number % dividedBy; - } - - public static double calculate(double number, double dividedBy) { - return number % dividedBy; - } - - public static long calculate(long number, long dividedBy) { - return number % dividedBy; - } - -} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberConversions.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberConversions.java index 6d7ced3..dc6faa2 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberConversions.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberConversions.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberUtils.java index d8892da..504d873 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/NumberUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/RandomNumber.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/RandomNumber.java index 579eb4f..0cafed5 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/RandomNumber.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/RandomNumber.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArray.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArray.java index d1439a2..c4fea69 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArray.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArray.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number.bit; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArrayVersion.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArrayVersion.java index 0531313..eea1833 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArrayVersion.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/BitArrayVersion.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number.bit; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/PaddedBitArray.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/PaddedBitArray.java index e194b10..7cac930 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/PaddedBitArray.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/PaddedBitArray.java @@ -1,22 +1,8 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number.bit; -import dev.unlegitdqrk.unlegitlibrary.number.MathHelper; +import dev.unlegitdqrk.unlegitlibrary.number.math.MathHelper; import java.util.Arrays; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/Pow2BitArray.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/Pow2BitArray.java index 3a4c575..02ef713 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/Pow2BitArray.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/bit/Pow2BitArray.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.number.bit; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/MathHelper.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/MathHelper.java similarity index 92% rename from src/main/java/dev/unlegitdqrk/unlegitlibrary/number/MathHelper.java rename to src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/MathHelper.java index d553a3a..f49aa9a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/MathHelper.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/MathHelper.java @@ -1,20 +1,8 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -package dev.unlegitdqrk.unlegitlibrary.number; + + +package dev.unlegitdqrk.unlegitlibrary.number.math; import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Modulo.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Modulo.java new file mode 100644 index 0000000..746517a --- /dev/null +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Modulo.java @@ -0,0 +1,27 @@ + + + + +package dev.unlegitdqrk.unlegitlibrary.number.math; + +import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider; + +public class Modulo extends DefaultMethodsOverrider { + + public static int calculate(int number, int dividedBy) { + return number % dividedBy; + } + + public static float calculate(float number, float dividedBy) { + return number % dividedBy; + } + + public static double calculate(double number, double dividedBy) { + return number % dividedBy; + } + + public static long calculate(long number, long dividedBy) { + return number % dividedBy; + } + +} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Quaternion.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Quaternion.java similarity index 78% rename from src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Quaternion.java rename to src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Quaternion.java index f56431a..009e172 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/Quaternion.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/Quaternion.java @@ -1,23 +1,11 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -package dev.unlegitdqrk.unlegitlibrary.number; -import dev.unlegitdqrk.unlegitlibrary.number.vector.Vector2; -import dev.unlegitdqrk.unlegitlibrary.number.vector.Vector3; + +package dev.unlegitdqrk.unlegitlibrary.number.math; + +import dev.unlegitdqrk.unlegitlibrary.number.math.vector.Vector2; +import dev.unlegitdqrk.unlegitlibrary.number.math.vector.Vector3; public class Quaternion { diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularAdd.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularAdd.java new file mode 100644 index 0000000..5762dbd --- /dev/null +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularAdd.java @@ -0,0 +1,15 @@ + + +package dev.unlegitdqrk.unlegitlibrary.number.math.molecular; + +public class MolecularAdd { + + /** + * @param k is the start number + * @param n is the end number + **/ + public static int useFormula(int k, int n) { + return ((n - k + 1) * (n + k)) / 2; + } + +} \ No newline at end of file diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularSubtract.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularSubtract.java new file mode 100644 index 0000000..2be3437 --- /dev/null +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/molecular/MolecularSubtract.java @@ -0,0 +1,18 @@ + + +package dev.unlegitdqrk.unlegitlibrary.number.math.molecular; + +import dev.unlegitdqrk.unlegitlibrary.number.math.MathHelper; + +public class MolecularSubtract { + + + /** + * @param k is the start number + * @param n is the end number + **/ + public static int useFormula(int k, int n) { + if (!MathHelper.isNegative(n)) n = -(n); + return ((-n - k + 1) * (-n + k) / 2) + k; + } +} \ No newline at end of file diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Axis.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Axis.java new file mode 100644 index 0000000..0e37494 --- /dev/null +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Axis.java @@ -0,0 +1,9 @@ + + + + +package dev.unlegitdqrk.unlegitlibrary.number.math.vector; + +public enum Axis { + X, Y, Z +} diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector2.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector2.java similarity index 81% rename from src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector2.java rename to src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector2.java index 446d481..1756d51 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector2.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector2.java @@ -1,20 +1,6 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -package dev.unlegitdqrk.unlegitlibrary.number.vector; +package dev.unlegitdqrk.unlegitlibrary.number.math.vector; public class Vector2 { diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector3.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector3.java similarity index 84% rename from src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector3.java rename to src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector3.java index bb2668c..75692e7 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/vector/Vector3.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/math/vector/Vector3.java @@ -1,22 +1,8 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -package dev.unlegitdqrk.unlegitlibrary.number.vector; +package dev.unlegitdqrk.unlegitlibrary.number.math.vector; -import dev.unlegitdqrk.unlegitlibrary.number.Quaternion; +import dev.unlegitdqrk.unlegitlibrary.number.math.Quaternion; public class Vector3 { public float x; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularAdd.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularAdd.java deleted file mode 100644 index 5caae43..0000000 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularAdd.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -package dev.unlegitdqrk.unlegitlibrary.number.molecular; - -public class MolecularAdd { - - /** - * @param k is the start number - * @param n is the end number - **/ - public static int useFormula(int k, int n) { - return ((n - k + 1) * (n + k)) / 2; - } - -} \ No newline at end of file diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularSubtract.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularSubtract.java deleted file mode 100644 index 552fbec..0000000 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/number/molecular/MolecularSubtract.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ - -package dev.unlegitdqrk.unlegitlibrary.number.molecular; - -import dev.unlegitdqrk.unlegitlibrary.number.MathHelper; - -public class MolecularSubtract { - - - /** - * @param k is the start number - * @param n is the end number - **/ - public static int useFormula(int k, int n) { - if (!MathHelper.isNegative(n)) n = -(n); - return ((-n - k + 1) * (-n + k) / 2) + k; - } -} \ No newline at end of file diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/RandomString.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/RandomString.java index da449f6..485a198 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/RandomString.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/RandomString.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.string; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/SimpleEncoderDecoder.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/SimpleEncoderDecoder.java index 15c5bfe..928e4a6 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/SimpleEncoderDecoder.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/SimpleEncoderDecoder.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.string; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/StringUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/StringUtils.java index 69a64ca..c9cf871 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/StringUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/StringUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.string; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/ConsoleColor.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/ConsoleColor.java index 49cbbb8..788d803 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/ConsoleColor.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/ConsoleColor.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.string.color; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/MinecraftColorUtils.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/MinecraftColorUtils.java index 585a199..192f5de 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/MinecraftColorUtils.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/string/color/MinecraftColorUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.string.color; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Color.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Color.java index 1dbef5e..0b58157 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Color.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Color.java @@ -1,14 +1,7 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.utils; -import dev.unlegitdqrk.unlegitlibrary.number.MathHelper; +import dev.unlegitdqrk.unlegitlibrary.number.math.MathHelper; public class Color { diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Converter.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Converter.java index 4a5204f..a9e9e89 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Converter.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Converter.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/DefaultMethodsOverrider.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/DefaultMethodsOverrider.java index 53d4952..1092856 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/DefaultMethodsOverrider.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/DefaultMethodsOverrider.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.utils; diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Logger.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Logger.java index 3ce20be..cfcbc9a 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Logger.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Logger.java @@ -1,10 +1,3 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.utils; @@ -210,4 +203,16 @@ public final class Logger { exception.printStackTrace(); } } + + public final boolean isInitialized() { + return isInitialized; + } + + public final File getLatestLogFile() { + return latestLogFile; + } + + public final File getLogFolder() { + return logFolder; + } } \ No newline at end of file diff --git a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Tuple.java b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Tuple.java index 4318a1f..f078762 100644 --- a/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Tuple.java +++ b/src/main/java/dev/unlegitdqrk/unlegitlibrary/utils/Tuple.java @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2025 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ -/* - * Copyright (C) 2024 UnlegitDqrk - All Rights Reserved - * - * You are unauthorized to remove this copyright. - * You have to give Credits to the Author in your project and link this GitHub site: https://github.com/UnlegitDqrk - * See LICENSE-File if exists - */ package dev.unlegitdqrk.unlegitlibrary.utils;