From d12fceae48098944ccc7d219536f5761d0c83d36 Mon Sep 17 00:00:00 2001
From: mnewt00 <44464407+mnewt00@users.noreply.github.com>
Date: Sun, 27 Mar 2022 21:26:06 +1100
Subject: [PATCH 1/5] Kotlin it is
---
.gitattributes | 6 +
.gitignore | 3 +
BetterStaffChat-bungeecord/build.gradle | 45 --
.../bungeecord/BetterStaffChatBungeeCord.java | 180 ------
.../command/BetterStaffChatCommand.java | 55 --
.../command/MuteStaffChatCommand.java | 54 --
.../bungeecord/command/StaffChatCommand.java | 63 ---
.../command/ToggleStaffChatCommand.java | 56 --
.../bungeecord/listener/PlayerListener.java | 163 ------
.../bungeecord/util/Config.java | 98 ----
.../bungeecord/util/LuckPermsUtil.java | 56 --
.../bungeecord/util/StaffChatUtil.java | 176 ------
.../src/main/resources/bungee.yml | 4 -
BetterStaffChat-common/build.gradle | 24 -
.../BetterStaffChatDependencyProvider.java | 58 --
.../common/dependency/DependencyEngine.java | 221 --------
.../annotations/LoaderPriority.java | 45 --
.../annotations/MavenDependency.java | 94 ----
.../annotations/MavenRepository.java | 66 ---
.../dependency/annotations/Relocation.java | 92 ----
.../exception/DependencyLoadException.java | 70 ---
.../exception/InvalidDependencyException.java | 72 ---
.../dependency/generics/TypeDefinition.java | 44 --
.../common/dependency/maven/Dependency.java | 78 ---
.../dependency/maven/DependencyLoader.java | 163 ------
.../dependency/maven/MavenDependencyInfo.java | 274 ----------
.../maven/MavenDependencyLoader.java | 302 -----------
.../dependency/maven/MavenRepositoryInfo.java | 84 ---
.../maven/builder/DependencyBuilder.java | 56 --
.../maven/builder/DependencyProvider.java | 48 --
.../builder/MavenDependencyProvider.java | 76 ---
.../MavenDependencyProviderBuilder.java | 234 --------
.../relocation/IsolatedClassLoader.java | 74 ---
.../relocation/RelocatableDependency.java | 46 --
.../RelocatableDependencyLoader.java | 69 ---
.../dependency/relocation/RelocationInfo.java | 104 ----
.../dependency/relocation/Relocator.java | 178 ------
.../common/discord/DiscordWebhook.java | 406 --------------
.../common/discord/JDAImplementation.java | 66 ---
.../common/discord/MessageListener.java | 39 --
.../common/plugin/BetterStaffChatPlugin.java | 58 --
.../common/plugin/Platform.java | 5 -
.../common/util/AbstractStaffChatUtil.java | 64 ---
.../betterstaffchat/common/util/Callback.java | 23 -
.../betterstaffchat/common/util/TextUtil.java | 85 ---
.../common/util/UpdateChecker.java | 52 --
BetterStaffChat-spigot/build.gradle | 54 --
.../spigot/BetterStaffChatSpigot.java | 181 -------
.../command/BetterStaffChatCommand.java | 57 --
.../spigot/command/MuteStaffChatCommand.java | 63 ---
.../spigot/command/StaffChatCommand.java | 66 ---
.../command/ToggleStaffChatCommand.java | 65 ---
.../spigot/listener/PlayerListener.java | 105 ----
.../spigot/reflection/ReflectionUtil.java | 44 --
.../betterstaffchat/spigot/util/Config.java | 91 ----
.../spigot/util/StaffChatUtil.java | 164 ------
.../src/main/resources/plugin.yml | 4 -
build.gradle | 158 ------
build.gradle.kts | 106 ++++
bungeecord/build.gradle.kts | 11 +
.../betterstaffchat/bungeecord/BSCBungee.kt | 55 ++
.../bungeecord/commands/BSCBungeeCommand.kt | 60 ++
.../bungeecord/commands/CommandManager.kt | 33 ++
.../commands/impl/BetterStaffChatCommand.kt | 23 +
.../commands/impl/StaffChatCommand.kt | 23 +
.../commands/impl/StaffChatMuteCommand.kt | 53 ++
.../commands/impl/StaffChatToggleCommand.kt | 60 ++
.../libby/BungeeLibraryManager.java | 51 ++
.../bungeecord/listeners/PlayerListener.kt | 60 ++
.../bungeecord/util/PlayerUtil.kt | 49 ++
common/build.gradle.kts | 1 +
.../betterstaffchat/common/BSCPlugin.kt | 17 +
.../betterstaffchat/common/PlayerMeta.kt | 8 +
.../common/libraries/BSCLibraries.kt | 120 ++++
.../common/libraries/libby/Library.java | 511 ++++++++++++++++++
.../libraries/libby/LibraryManager.java | 455 ++++++++++++++++
.../common/libraries/libby/Repositories.java | 31 ++
.../classloader/IsolatedClassLoader.java | 51 ++
.../classloader/URLClassLoaderHelper.java | 233 ++++++++
.../libraries/libby/logging/LogLevel.java | 26 +
.../libraries/libby/logging/Logger.java | 196 +++++++
.../libby/logging/adapters/JDKLogAdapter.java | 77 +++
.../libby/logging/adapters/LogAdapter.java | 25 +
.../libby/relocation/Relocation.java | 184 +++++++
.../libby/relocation/RelocationHelper.java | 130 +++++
.../betterstaffchat/common/util/Config.kt | 66 +++
.../betterstaffchat/common/util/Data.kt | 46 ++
.../common/util/StaffChatUtil.kt | 65 +++
.../betterstaffchat/common/util/TextUtil.kt | 16 +
gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 59203 bytes
gradle/wrapper/gradle-wrapper.properties | 18 -
gradlew | 53 +-
gradlew.bat | 25 +-
settings.gradle | 23 -
settings.gradle.kts | 11 +
spigot/build.gradle.kts | 12 +
.../betterstaffchat/spigot/BSCSpigot.kt | 56 ++
.../spigot/commands/BSCSpigotCommand.kt | 57 ++
.../spigot/commands/CommandManager.kt | 40 ++
.../commands/impl/BetterStaffChatCommand.kt | 23 +
.../spigot/commands/impl/StaffChatCommand.kt | 29 +
.../commands/impl/StaffChatMuteCommand.kt | 57 ++
.../commands/impl/StaffChatToggleCommand.kt | 64 +++
.../spigot/libby/BukkitLibraryManager.java | 51 ++
.../spigot/listeners/PlayerListener.kt | 51 ++
.../betterstaffchat/spigot/util/PlayerUtil.kt | 35 ++
.../spigot/util/ReflectionUtil.kt | 27 +
src/main/resources/bungeecord.yml | 3 +
.../src => src}/main/resources/config.yml | 4 +-
src/main/resources/plugin.yml | 3 +
110 files changed, 3404 insertions(+), 5461 deletions(-)
create mode 100644 .gitattributes
delete mode 100644 BetterStaffChat-bungeecord/build.gradle
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/BetterStaffChatBungeeCord.java
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/BetterStaffChatCommand.java
delete mode 100644 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/MuteStaffChatCommand.java
delete mode 100644 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/StaffChatCommand.java
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/ToggleStaffChatCommand.java
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/listener/PlayerListener.java
delete mode 100644 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/Config.java
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/LuckPermsUtil.java
delete mode 100755 BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/StaffChatUtil.java
delete mode 100644 BetterStaffChat-bungeecord/src/main/resources/bungee.yml
delete mode 100644 BetterStaffChat-common/build.gradle
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/BetterStaffChatDependencyProvider.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/DependencyEngine.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/LoaderPriority.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenDependency.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenRepository.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/Relocation.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/DependencyLoadException.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/InvalidDependencyException.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/generics/TypeDefinition.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/Dependency.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/DependencyLoader.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyInfo.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyLoader.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenRepositoryInfo.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyBuilder.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyProvider.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProvider.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProviderBuilder.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/IsolatedClassLoader.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependency.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependencyLoader.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocationInfo.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/Relocator.java
delete mode 100644 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/discord/DiscordWebhook.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/discord/JDAImplementation.java
delete mode 100644 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/discord/MessageListener.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/plugin/BetterStaffChatPlugin.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/plugin/Platform.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/util/AbstractStaffChatUtil.java
delete mode 100644 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/util/Callback.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/util/TextUtil.java
delete mode 100755 BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/util/UpdateChecker.java
delete mode 100644 BetterStaffChat-spigot/build.gradle
delete mode 100755 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/BetterStaffChatSpigot.java
delete mode 100755 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/command/BetterStaffChatCommand.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/command/MuteStaffChatCommand.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/command/StaffChatCommand.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/command/ToggleStaffChatCommand.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/listener/PlayerListener.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/reflection/ReflectionUtil.java
delete mode 100644 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/util/Config.java
delete mode 100755 BetterStaffChat-spigot/src/main/java/dev/austech/betterstaffchat/spigot/util/StaffChatUtil.java
delete mode 100644 BetterStaffChat-spigot/src/main/resources/plugin.yml
delete mode 100755 build.gradle
create mode 100644 build.gradle.kts
create mode 100644 bungeecord/build.gradle.kts
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/BSCBungee.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/BSCBungeeCommand.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/CommandManager.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/impl/BetterStaffChatCommand.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/impl/StaffChatCommand.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/impl/StaffChatMuteCommand.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/commands/impl/StaffChatToggleCommand.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/libby/BungeeLibraryManager.java
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/listeners/PlayerListener.kt
create mode 100644 bungeecord/src/main/kotlin/dev/austech/betterstaffchat/bungeecord/util/PlayerUtil.kt
create mode 100644 common/build.gradle.kts
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/BSCPlugin.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/PlayerMeta.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/BSCLibraries.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/Library.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/LibraryManager.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/Repositories.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/classloader/IsolatedClassLoader.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/classloader/URLClassLoaderHelper.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/logging/LogLevel.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/logging/Logger.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/logging/adapters/JDKLogAdapter.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/logging/adapters/LogAdapter.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/relocation/Relocation.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/libraries/libby/relocation/RelocationHelper.java
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/util/Config.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/util/Data.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/util/StaffChatUtil.kt
create mode 100644 common/src/main/kotlin/dev/austech/betterstaffchat/common/util/TextUtil.kt
delete mode 100644 settings.gradle
create mode 100644 settings.gradle.kts
create mode 100644 spigot/build.gradle.kts
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/BSCSpigot.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/BSCSpigotCommand.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/CommandManager.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/impl/BetterStaffChatCommand.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/impl/StaffChatCommand.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/impl/StaffChatMuteCommand.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/commands/impl/StaffChatToggleCommand.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/libby/BukkitLibraryManager.java
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/listeners/PlayerListener.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/util/PlayerUtil.kt
create mode 100644 spigot/src/main/kotlin/dev/austech/betterstaffchat/spigot/util/ReflectionUtil.kt
create mode 100644 src/main/resources/bungeecord.yml
rename {BetterStaffChat-common/src => src}/main/resources/config.yml (98%)
mode change 100755 => 100644
create mode 100644 src/main/resources/plugin.yml
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..00a51af
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,6 @@
+#
+# https://help.github.com/articles/dealing-with-line-endings/
+#
+# These are explicitly windows files and should use crlf
+*.bat text eol=crlf
+
diff --git a/.gitignore b/.gitignore
index 2b3de74..e87d4f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -117,3 +117,6 @@ run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
+
+# Ignore Gradle build output directory
+build
diff --git a/BetterStaffChat-bungeecord/build.gradle b/BetterStaffChat-bungeecord/build.gradle
deleted file mode 100644
index 6d56e23..0000000
--- a/BetterStaffChat-bungeecord/build.gradle
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * BetterStaffChat - build.gradle
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-import org.apache.tools.ant.filters.ReplaceTokens
-
-plugins {
- id 'com.github.johnrengelman.shadow'
-}
-
-repositories {
- maven {
- name = 'sonatype'
- url = 'https://oss.sonatype.org/content/groups/public/'
- }
-}
-
-dependencies {
- compileOnly 'net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT'
- compileOnly 'net.luckperms:api:5.3'
- implementation 'org.bstats:bstats-bungeecord:2.2.1'
- implementation project(":BetterStaffChat-common")
-}
-
-processResources {
- filter ReplaceTokens, tokens: [
- "version": parent.getVersion()
- ]
-}
-
-tasks.build.dependsOn tasks.shadowJar
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/BetterStaffChatBungeeCord.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/BetterStaffChatBungeeCord.java
deleted file mode 100755
index 0679df8..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/BetterStaffChatBungeeCord.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * BetterStaffChat - BetterStaffChatBungeeCord.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord;
-
-import com.google.common.collect.Lists;
-import dev.austech.betterstaffchat.bungeecord.command.BetterStaffChatCommand;
-import dev.austech.betterstaffchat.bungeecord.command.MuteStaffChatCommand;
-import dev.austech.betterstaffchat.bungeecord.command.StaffChatCommand;
-import dev.austech.betterstaffchat.bungeecord.command.ToggleStaffChatCommand;
-import dev.austech.betterstaffchat.bungeecord.listener.PlayerListener;
-import dev.austech.betterstaffchat.bungeecord.util.Config;
-import dev.austech.betterstaffchat.bungeecord.util.LuckPermsUtil;
-import dev.austech.betterstaffchat.bungeecord.util.StaffChatUtil;
-import dev.austech.betterstaffchat.common.plugin.BetterStaffChatPlugin;
-import dev.austech.betterstaffchat.common.dependency.BetterStaffChatDependencyProvider;
-import dev.austech.betterstaffchat.common.dependency.DependencyEngine;
-import dev.austech.betterstaffchat.common.discord.JDAImplementation;
-import dev.austech.betterstaffchat.common.plugin.Platform;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import dev.austech.betterstaffchat.common.util.UpdateChecker;
-import lombok.Getter;
-import lombok.Setter;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.chat.TextComponent;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.plugin.Plugin;
-import net.md_5.bungee.config.Configuration;
-import org.bstats.bungeecord.Metrics;
-
-import javax.naming.ConfigurationException;
-import javax.security.auth.login.LoginException;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-
-public final class BetterStaffChatBungeeCord extends Plugin implements BetterStaffChatPlugin {
- @Getter private static BetterStaffChatBungeeCord instance;
- @Getter @Setter private Configuration config;
- @Getter private final ArrayList ignoreStaffChat = Lists.newArrayList();
- @Getter private final ArrayList toggledStaffChat = Lists.newArrayList();
- @Getter private JDAImplementation jda;
- @Getter boolean discordEnabled;
-
- @Override
- public void onEnable() {
- instance = this;
-
- TextUtil.init(getPlatform(), this);
- Config.load();
-
- if (getConfig().getBoolean("check-for-updates"))
- getProxy().getScheduler().runAsync(this, () -> {
- if (UpdateChecker.needsUpdate(this, getDescription().getVersion())) {
- getProxy().getScheduler().schedule(this, () -> {
- logPrefix("&eA new update for BetterStaffChat is available...");
- logPrefix("&ehttps://www.spigotmc.org/resources/91991");
- }, 3, TimeUnit.SECONDS);
- }
- });
-
- new Metrics(this, 10954);
-
- if (getConfig().getBoolean("discord.bot.enabled") && getConfig().getBoolean("discord.webhook.enabled")) {
- new ConfigurationException("Both Discord types are enabled").printStackTrace();
- return;
- }
-
- if (this.getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- LuckPermsUtil.setLuckPerms(net.luckperms.api.LuckPermsProvider.get());
- }
-
- this.discordEnabled = getConfig().getBoolean("discord.bot.enabled");
-
- DependencyEngine dependencyEngine = DependencyEngine.createNew(new File(getPluginDataFolder(), "libs").toPath());
- dependencyEngine.addDependenciesFromProvider(BetterStaffChatDependencyProvider.getDependencies());
-
- dependencyEngine.loadDependencies().thenAccept((empty) -> {
- if (!dependencyEngine.getErrors().isEmpty()) {
- Optional opt = dependencyEngine.getErrors().stream().filter(throwable -> throwable.getMessage().contains("Unable to make protected void java.net.URLClassLoader.addURL(java.net.URL) accessible: module java.base does not")).findFirst();
- if (opt.isPresent()) {
- getLogger().log(Level.SEVERE, "An error occurred whilst starting BetterStaffChat - This is due to Java 16 and up being incompatible by default.");
- getLogger().log(Level.SEVERE, "This error is fixable, please add the following flags to your startup after the \"java\":");
- getLogger().log(Level.SEVERE, "");
- getLogger().log(Level.SEVERE, "--add-opens java.base/java.net=ALL-UNNAMED");
- } else {
- dependencyEngine.getErrors().forEach(Throwable::printStackTrace);
- getLogger().log(Level.SEVERE, "Errors occurred whilst loading BSC.");
- }
- return;
- }
-
- if (discordEnabled) {
- this.getProxy().getScheduler().runAsync(this, () -> {
- try {
- this.jda = new JDAImplementation(net.dv8tion.jda.api.JDABuilder.createLight(getConfig().getString("discord.bot.token")).build(), StaffChatUtil.getInstance());
- jda.asJda().getPresence().setActivity(net.dv8tion.jda.api.entities.Activity.of(
- net.dv8tion.jda.api.entities.Activity.ActivityType.valueOf(getConfig().getString("discord.bot.activity-type").toUpperCase().replace("PLAYING", "DEFAULT")),
- getConfig().getString("discord.bot.activity")
- ));
- } catch (LoginException exception) {
- exception.printStackTrace();
- }
- });
- }
-
- this.getProxy().getPluginManager().registerListener(this, new PlayerListener());
- registerCommands();
- });
- }
-
- public File getPluginDataFolder() {
- return getDataFolder();
- }
-
- public void logPrefix(String string) {
- getProxy().getConsole().sendMessage(new TextComponent("[BetterStaffChat] " + TextUtil.colorize(string)));
- }
-
- public void logPrefixDebug(String string) {
- if (getConfig().getBoolean("debug"))
- getProxy().getConsole().sendMessage(new TextComponent("[BetterStaffChat] Debug - " + TextUtil.colorize(string)));
- }
-
- public void log(String string) {
- getProxy().getConsole().sendMessage(new TextComponent(TextUtil.colorize(string)));
- }
-
- @Override public Platform getPlatform() {
- return Platform.BUNGEECORD;
- }
-
- public boolean reloadConfig(CommandSender sender) {
- boolean discordLoaded = getConfig().getBoolean("discord.bot.enabled");
- Config.load();
-
- getProxy().getPluginManager().unregisterCommands(this);
- registerCommands();
-
- if (getConfig().getBoolean("discord.bot.enabled") != discordLoaded) {
- logPrefix("&cYou enabled the discord bot in the config. Please restart the server for changes to take effect.");
- if (sender instanceof ProxiedPlayer)
- sender.sendMessage(TextUtil.colorizeToComponent("&cYou enabled the discord bot in the config. Please restart the server for changes to take effect."));
- return true;
- }
- return false;
- }
-
- private void registerCommands() {
- this.getProxy().getScheduler().runAsync(this, () -> {
- this.getProxy().getPluginManager().registerCommand(this, new BetterStaffChatCommand());
- this.getProxy().getPluginManager().registerCommand(this, new StaffChatCommand("staffchat", "betterstaffchat.messages.send", getConfig().getStringList("commands.staffchat.aliases").toArray(new String[0])));
- this.getProxy().getPluginManager().registerCommand(this, new MuteStaffChatCommand("mutestaffchat", "betterstaffchat.mutestaffchat", getConfig().getStringList("commands.mutestaffchat.aliases").toArray(new String[0])));
- this.getProxy().getPluginManager().registerCommand(this, new ToggleStaffChatCommand("togglestaffchat", "betterstaffchat.togglestaffchat", getConfig().getStringList("commands.togglestaffchat.aliases").toArray(new String[0])));
- });
- }
-
- @Override
- public void onDisable() {
- if (isDiscordEnabled()) (getJda()).shutdown();
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/BetterStaffChatCommand.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/BetterStaffChatCommand.java
deleted file mode 100755
index a21f61a..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/BetterStaffChatCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * BetterStaffChat - BetterStaffChatCommand.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.command;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import net.dv8tion.jda.api.entities.Activity;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.plugin.Command;
-
-public class BetterStaffChatCommand extends Command {
- public BetterStaffChatCommand() {
- super("betterstaffchat", null, "bsc");
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("betterstaffchat.reload")) {
- boolean reload = BetterStaffChatBungeeCord.getInstance().reloadConfig(sender);
- if (!reload && BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("discord.bot.enabled")) {
- BetterStaffChatBungeeCord.getInstance().getJda().asJda().getPresence().setActivity(Activity.of(
- Activity.ActivityType.valueOf(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.bot.activity-type").toUpperCase().replace("PLAYING", "DEFAULT")),
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.bot.activity")
- ));
- }
-
- sender.sendMessage(TextUtil.colorizeToComponent("&8&l&m-------------------------------"));
- sender.sendMessage(TextUtil.colorizeToComponent(TextUtil.spacer(18) + "&c&l&oBetter&4&l&oStaffChat"));
- sender.sendMessage(TextUtil.colorizeToComponent(TextUtil.spacer(13) + "&7Configuration Reloaded"));
- sender.sendMessage(TextUtil.colorizeToComponent("&8&l&m-------------------------------"));
- return;
- }
-
- sender.sendMessage(TextUtil.colorizeToComponent("&8&l&m-------------------------------"));
- sender.sendMessage(TextUtil.colorizeToComponent(TextUtil.spacer(18) + "&c&l&oBetter&4&l&oStaffChat"));
- sender.sendMessage(TextUtil.colorizeToComponent(TextUtil.spacer(13) + "&7The &7&o\"better\"&r &7staff chat."));
- sender.sendMessage(TextUtil.colorizeToComponent("&8&l&m-------------------------------"));
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/MuteStaffChatCommand.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/MuteStaffChatCommand.java
deleted file mode 100644
index 965faff..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/MuteStaffChatCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * BetterStaffChat - MuteStaffChatCommand.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.command;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.plugin.Command;
-
-public class MuteStaffChatCommand extends Command {
- public MuteStaffChatCommand(String command, String permission, String... aliases) {
- super(command, permission, aliases);
- setPermissionMessage(TextUtil.colorize("&cNo permission."));
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (!(sender instanceof ProxiedPlayer)) {
- sender.sendMessage(TextUtil.colorizeToComponent("&cThis command can only be used by players."));
- return;
- }
-
- if (BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(((ProxiedPlayer) sender).getUniqueId())) {
- BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().remove(((ProxiedPlayer) sender).getUniqueId());
- } else {
- if (BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().contains(((ProxiedPlayer) sender).getUniqueId())) {
- BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().remove(((ProxiedPlayer) sender).getUniqueId());
- }
- BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().add(((ProxiedPlayer) sender).getUniqueId());
- }
-
- sender.sendMessage(TextUtil.colorizeToComponent(BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(((ProxiedPlayer) sender).getUniqueId()) ?
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.mute-on") :
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.mute-off"))
- );
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/StaffChatCommand.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/StaffChatCommand.java
deleted file mode 100644
index afb6c63..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/StaffChatCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * BetterStaffChat - StaffChatCommand.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.command;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.bungeecord.util.StaffChatUtil;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import net.md_5.bungee.api.ChatColor;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.plugin.Command;
-
-import java.util.Arrays;
-
-public class StaffChatCommand extends Command {
- public StaffChatCommand(String command, String permission, String... aliases) {
- super(command, permission, aliases);
- setPermissionMessage(TextUtil.colorize("&cNo permission."));
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (sender instanceof ProxiedPlayer && BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(((ProxiedPlayer) sender).getUniqueId())) {
- sender.sendMessage(TextUtil.colorizeToComponent("&cYour staff chat is currently disabled."));
- return;
- }
-
- if (args.length == 0) {
- sender.sendMessage(TextUtil.colorizeToComponent("&cUsage: /" + this.getName() + " "));
- return;
- }
-
- StaffChatUtil.getInstance().broadcast(StaffChatUtil.getInstance().getFormattedMessage(sender, String.join(" ", Arrays.copyOfRange(args, 0, args.length))), "betterstaffchat.messages.read");
-
- if (sender instanceof ProxiedPlayer)
- StaffChatUtil.getInstance().discord(sender, ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-format")
- .replace("%player_name%", sender.getName())
- .replace("%message%", String.join(" ", Arrays.copyOfRange(args, 0, args.length)))
- .replace("%server%", StaffChatUtil.getFormattedServerName(((ProxiedPlayer) sender).getServer().getInfo().getName())))));
- else
- StaffChatUtil.getInstance().discord(sender, ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-format")
- .replace("%player_name%", BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-replacement"))
- .replace("%message%", String.join(" ", Arrays.copyOfRange(args, 0, args.length)))
- .replace("%server%", BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-server-replacement"))
- )));
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/ToggleStaffChatCommand.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/ToggleStaffChatCommand.java
deleted file mode 100755
index 4af7f74..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/command/ToggleStaffChatCommand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * BetterStaffChat - ToggleStaffChatCommand.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.command;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.plugin.Command;
-
-public class ToggleStaffChatCommand extends Command {
- public ToggleStaffChatCommand(String command, String permission, String... aliases) {
- super(command, permission, aliases);
- setPermissionMessage(TextUtil.colorize("&cNo permission."));
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (!(sender instanceof ProxiedPlayer)) {
- sender.sendMessage(TextUtil.colorizeToComponent("&cThis command can only be used by players."));
- return;
- }
-
- if (BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(((ProxiedPlayer) sender).getUniqueId())) {
- sender.sendMessage(TextUtil.colorizeToComponent("&cYour staff chat is currently disabled."));
- return;
- }
-
- if (BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().contains(((ProxiedPlayer) sender).getUniqueId())) {
- BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().remove(((ProxiedPlayer) sender).getUniqueId());
- } else {
- BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().add(((ProxiedPlayer) sender).getUniqueId());
- }
-
- sender.sendMessage(TextUtil.colorizeToComponent(BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().contains(((ProxiedPlayer) sender).getUniqueId()) ?
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.toggle-on") :
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.toggle-off"))
- );
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/listener/PlayerListener.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/listener/PlayerListener.java
deleted file mode 100755
index 83f39ab..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/listener/PlayerListener.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * BetterStaffChat - PlayerListener.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.listener;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.bungeecord.util.LuckPermsUtil;
-import dev.austech.betterstaffchat.bungeecord.util.StaffChatUtil;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import net.md_5.bungee.api.ChatColor;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-import net.md_5.bungee.api.event.ChatEvent;
-import net.md_5.bungee.api.event.PlayerDisconnectEvent;
-import net.md_5.bungee.api.event.PostLoginEvent;
-import net.md_5.bungee.api.event.ServerSwitchEvent;
-import net.md_5.bungee.api.plugin.Listener;
-import net.md_5.bungee.api.scheduler.ScheduledTask;
-import net.md_5.bungee.event.EventHandler;
-
-import java.util.concurrent.TimeUnit;
-
-public class PlayerListener implements Listener {
- @EventHandler
- public void onPlayerChat(ChatEvent event) {
- if (event.getMessage().startsWith("/")) return;
-
- String prefix = BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.prefix");
- if (prefix.startsWith("/")) return;
-
- ProxiedPlayer player = (ProxiedPlayer) event.getSender();
-
- if (player.hasPermission("betterstaffchat.messages.send") && event.getMessage().startsWith(prefix) && event.getMessage().length() > prefix.length() && !prefix.equals("")) {
- event.setCancelled(true);
-
- if (BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(player.getUniqueId())) {
- player.sendMessage(TextUtil.colorizeToComponent("&cYour staff chat is currently disabled."));
- return;
- }
-
- StaffChatUtil.getInstance().broadcast(StaffChatUtil.getInstance().getFormattedMessage(player, event.getMessage().substring(prefix.length())), "betterstaffchat.messages.read");
- StaffChatUtil.getInstance().discord(
- player,
- ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-format")
- .replace("%player_name%", player.getName())
- .replace("%message%", event.getMessage().substring(prefix.length()))
- .replace("%server%", StaffChatUtil.getFormattedServerName(player.getServer().getInfo().getName()))
- )));
- } else if (player.hasPermission("betterstaffchat.messages.send") && BetterStaffChatBungeeCord.getInstance().getToggledStaffChat().contains(player.getUniqueId())) {
- event.setCancelled(true);
-
- StaffChatUtil.getInstance().broadcast(StaffChatUtil.getInstance().getFormattedMessage(player, event.getMessage()), "betterstaffchat.messages.read");
- StaffChatUtil.getInstance().discord(
- player,
- ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-format")
- .replace("%player_name%", player.getName())
- .replace("%message%", event.getMessage())
- .replace("%server%", StaffChatUtil.getFormattedServerName(player.getServer().getInfo().getName()))
- )));
- }
- }
-
- @EventHandler
- public void onPlayerPostLogin(PostLoginEvent event) {
- if (event.getPlayer().hasPermission("betterstaffchat.messages.join") && !BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.join").equals("")) {
- BetterStaffChatBungeeCord.getInstance().getProxy().getScheduler().schedule(BetterStaffChatBungeeCord.getInstance(), () -> {
- // This is temporarily disable so a fix can be added.
- // Although it does prevent some errors, it stops the staff-chat working in some instances.
-
- // if (event.getPlayer().getServer() == null) return;
-
-
- int timeDelay = 100;
- if (BetterStaffChatBungeeCord.getInstance().getConfig().get("join-delay")) timeDelay = BetterStaffChatBungeeCord.getInstance().getConfig().getInt("join-delay");
-
- ScheduledTask task = BetterStaffChatBungeeCord.getInstance().getProxy().getScheduler().schedule(BetterStaffChatBungeeCord.getInstance(), () -> {
-
- String message = TextUtil.colorize(
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.join")
- .replace("%player_name%", event.getPlayer().getName())
- .replace("%server%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName()))
- );
-
- if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- message = message.replace("%luckperms_prefix%", LuckPermsUtil.getPrefix(event.getPlayer())).replace("%luckperms_suffix%", LuckPermsUtil.getSuffix(event.getPlayer()));
- }
-
- message = TextUtil.colorize(message);
-
- StaffChatUtil.getInstance().broadcast(message, "betterstaffchat.messages.read");
- StaffChatUtil.getInstance().discord(event.getPlayer(), ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-join")
- .replace("%player_name%", event.getPlayer().getName())
- .replace("%server%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName())))));
- }, 100, TimeUnit.MILLISECONDS);
- }, timeDelay, TimeUnit.SECONDS);
- }
- }
-
- @EventHandler
- public void onPlayerDisconnect(PlayerDisconnectEvent event) {
- if (event.getPlayer().hasPermission("betterstaffchat.messages.leave") && !BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.leave").equals("")) {
- BetterStaffChatBungeeCord.getInstance().getProxy().getScheduler().schedule(BetterStaffChatBungeeCord.getInstance(), () -> {
- if (event.getPlayer().getServer() == null) return;
- String message = TextUtil.colorize(
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.leave")
- .replace("%player_name%", event.getPlayer().getName())
- .replace("%server%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName()))
- );
-
- if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- message = message.replace("%luckperms_prefix%", LuckPermsUtil.getPrefix(event.getPlayer())).replace("%luckperms_suffix%", LuckPermsUtil.getSuffix(event.getPlayer()));
- }
-
- message = TextUtil.colorize(message);
-
- StaffChatUtil.getInstance().broadcast(message, "betterstaffchat.messages.read");
- StaffChatUtil.getInstance().discord(event.getPlayer(), ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-leave")
- .replace("%player_name%", event.getPlayer().getName())
- .replace("%server%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName())))));
- }, 1, TimeUnit.SECONDS);
- }
- }
-
- @EventHandler
- public void onServerSwitch(ServerSwitchEvent event) {
- if (event.getPlayer().hasPermission("betterstaffchat.messages.switch") && !BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.switch").equals("")) {
- if (event.getFrom() == null) return;
-
- String message = TextUtil.colorize(
- BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.switch")
- .replace("%player_name%", event.getPlayer().getName())
- .replace("%from%", StaffChatUtil.getFormattedServerName(event.getFrom().getName()))
- .replace("%to%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName()))
- );
-
- if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- message = message.replace("%luckperms_prefix%", LuckPermsUtil.getPrefix(event.getPlayer())).replace("%luckperms_suffix%", LuckPermsUtil.getSuffix(event.getPlayer()));
- }
-
- message = TextUtil.colorize(message);
-
- StaffChatUtil.getInstance().broadcast(message, "betterstaffchat.messages.read");
- StaffChatUtil.getInstance().discord(event.getPlayer(), ChatColor.stripColor(TextUtil.colorize(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.staffchat-switch")
- .replace("%player_name%", event.getPlayer().getName()))
- .replace("%from%", StaffChatUtil.getFormattedServerName(event.getFrom().getName()))
- .replace("%to%", StaffChatUtil.getFormattedServerName(event.getPlayer().getServer().getInfo().getName()))));
- }
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/Config.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/Config.java
deleted file mode 100644
index 69cea46..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/Config.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * BetterStaffChat - Config.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.util;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import lombok.experimental.UtilityClass;
-import net.md_5.bungee.config.Configuration;
-import net.md_5.bungee.config.ConfigurationProvider;
-import net.md_5.bungee.config.YamlConfiguration;
-import org.yaml.snakeyaml.parser.ParserException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.util.Optional;
-
-@UtilityClass
-public class Config {
- public void load() {
- BetterStaffChatBungeeCord.getInstance().getDataFolder().mkdir();
-
- File file = new File(BetterStaffChatBungeeCord.getInstance().getPluginDataFolder(), "config.yml");
-
- if (!file.exists()) {
- try (InputStream in = BetterStaffChatBungeeCord.getInstance().getClass().getResourceAsStream("/config.yml")) {
- Files.copy(in, file.toPath());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- try {
- Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BetterStaffChatBungeeCord.getInstance().getPluginDataFolder(), "config.yml"));
-
- int currentVersion = ConfigurationProvider.getProvider(YamlConfiguration.class).load(BetterStaffChatBungeeCord.getInstance().getClass().getResourceAsStream("/config.yml")).getInt("config-version");
-
- if (config.getInt("config-version") != currentVersion)
- newVersion(config.getInt("config-version"));
- else
- BetterStaffChatBungeeCord.getInstance().setConfig(config);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ParserException exception) {
- File broken = new File(file.getAbsolutePath() + ".broken." + System.currentTimeMillis());
- file.renameTo(broken);
- BetterStaffChatBungeeCord.getInstance().logPrefix("&cThe config file is broken, and has been renamed to config.yml.broken." + System.currentTimeMillis());
-
- try (InputStream in = BetterStaffChatBungeeCord.getInstance().getClass().getResourceAsStream("/config.yml")) {
- Files.copy(in, file.toPath());
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- try {
- BetterStaffChatBungeeCord.getInstance().setConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BetterStaffChatBungeeCord.getInstance().getPluginDataFolder(), "config.yml")));
- } catch (IOException ex1) {
- ex1.printStackTrace();
- }
- }
- }
-
- public Optional getOptional(String path) {
- String find = BetterStaffChatBungeeCord.getInstance().getConfig().getString(path);
- return Optional.ofNullable(find.isEmpty() ? null : find);
- }
-
- public void newVersion(int ver) throws IOException {
- File file = new File(BetterStaffChatBungeeCord.getInstance().getPluginDataFolder(), "config.yml");
-
- File broken = new File(file.getAbsolutePath() + ".old." + ver);
- file.renameTo(broken);
- BetterStaffChatBungeeCord.getInstance().logPrefix("&cThe config file is old, and has been renamed to config.yml.old." + ver);
-
- try (InputStream inputStream = BetterStaffChatBungeeCord.getInstance().getClass().getResourceAsStream("/config.yml")) {
- Files.copy(inputStream, file.toPath());
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- BetterStaffChatBungeeCord.getInstance().setConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(BetterStaffChatBungeeCord.getInstance().getPluginDataFolder(), "config.yml")));
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/LuckPermsUtil.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/LuckPermsUtil.java
deleted file mode 100755
index 7e7129c..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/LuckPermsUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * BetterStaffChat - LuckPermsUtil.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.util;
-
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import lombok.Setter;
-import lombok.experimental.UtilityClass;
-import net.luckperms.api.LuckPerms;
-import net.luckperms.api.model.user.User;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-
-@UtilityClass
-public class LuckPermsUtil {
- @Setter
- private LuckPerms luckPerms;
-
- /**
- * Gets a player's LuckPerms prefix.
- *
- * @param player the player to get the prefix
- * @return the prefix
- */
- public String getPrefix(ProxiedPlayer player) {
- User lpUser = luckPerms.getUserManager().getUser(player.getUniqueId());
- if (lpUser.getCachedData().getMetaData().getPrefix() == null) return "";
- return TextUtil.colorize(lpUser.getCachedData().getMetaData().getPrefix());
- }
-
- /**
- * Gets a player's LuckPerms suffix.
- *
- * @param player the player to get the suffix
- * @return the suffix
- */
- public String getSuffix(ProxiedPlayer player) {
- User lpUser = luckPerms.getUserManager().getUser(player.getUniqueId());
- if (lpUser.getCachedData().getMetaData().getSuffix() == null) return "";
- return TextUtil.colorize(lpUser.getCachedData().getMetaData().getSuffix());
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/StaffChatUtil.java b/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/StaffChatUtil.java
deleted file mode 100755
index 42d48a8..0000000
--- a/BetterStaffChat-bungeecord/src/main/java/dev/austech/betterstaffchat/bungeecord/util/StaffChatUtil.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * BetterStaffChat - StaffChatUtil.java
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.austech.betterstaffchat.bungeecord.util;
-
-import dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord;
-import dev.austech.betterstaffchat.common.discord.DiscordWebhook;
-import dev.austech.betterstaffchat.common.util.AbstractStaffChatUtil;
-import dev.austech.betterstaffchat.common.util.TextUtil;
-import lombok.Getter;
-import net.md_5.bungee.api.ChatColor;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-
-import java.awt.*;
-import java.io.IOException;
-
-public class StaffChatUtil extends AbstractStaffChatUtil {
- @Getter
- private static final StaffChatUtil instance = new StaffChatUtil();
-
- /**
- * Gets the formatted server name from the config, if exists.
- *
- * @param serverName the server to replace
- * @return the server with the formatted name or the provided server name if not found
- */
- public static String getFormattedServerName(String serverName) {
- return Config.getOptional("staffchat.server-replacement." + serverName).orElse(serverName);
- }
-
- @Override
- public String getFormattedMessage(Object sender, String message) {
- StringBuilder builder = new StringBuilder();
- message = BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.format")
- .replace("%player_name%", (sender instanceof ProxiedPlayer) ? ((ProxiedPlayer) sender).getName() : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-replacement"))
- .replace("%message%", BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("staffchat.strip-color-codes") ? ChatColor.stripColor(TextUtil.colorize(message)) : message)
- .replace("%server%", (sender instanceof ProxiedPlayer) ? getFormattedServerName(((ProxiedPlayer) sender).getServer().getInfo().getName()) : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-server-replacement"));
-
- if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null && sender instanceof ProxiedPlayer) {
- message = message.replace("%luckperms_prefix%", LuckPermsUtil.getPrefix((ProxiedPlayer) sender)).replace("%luckperms_suffix%", LuckPermsUtil.getSuffix((ProxiedPlayer) sender));
- } else if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- message = message.replace("%luckperms_prefix%", "").replace("%luckperms_suffix%", "");
- }
-
- for (String word : message.split(" ")) {
- builder.append(TextUtil.colorize(word));
- builder.append(" ");
- }
-
- return builder.substring(0, builder.length() - 1);
- }
-
- @Override
- public void broadcast(String string, String permission) {
- for (ProxiedPlayer player : BetterStaffChatBungeeCord.getInstance().getProxy().getPlayers()) {
- if (!BetterStaffChatBungeeCord.getInstance().getIgnoreStaffChat().contains(player.getUniqueId()) && player.hasPermission(permission)) {
- player.sendMessage(TextUtil.colorizeToComponent(string));
- }
- }
-
- if (BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("staffchat.log-to-console")) {
- BetterStaffChatBungeeCord.getInstance().log(TextUtil.colorize(string));
- }
- }
-
- public void discord(Object sender, String string) {
- if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null && sender instanceof ProxiedPlayer) {
- string = string.replace("%luckperms_prefix%", ChatColor.stripColor(TextUtil.colorize(LuckPermsUtil.getPrefix((ProxiedPlayer) sender)))).replace("%luckperms_suffix%", ChatColor.stripColor(TextUtil.colorize(LuckPermsUtil.getSuffix((ProxiedPlayer) sender))));
- } else if (BetterStaffChatBungeeCord.getInstance().getProxy().getPluginManager().getPlugin("LuckPerms") != null) {
- string = string.replace("%luckperms_prefix%", "").replace("%luckperms_suffix%", "");
- }
-
- String finalString = string;
- BetterStaffChatBungeeCord.getInstance().getProxy().getScheduler().runAsync(BetterStaffChatBungeeCord.getInstance(), () -> {
- if (BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("discord.webhook.enabled")) {
- DiscordWebhook webhook = new DiscordWebhook(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.webhook.url"));
-
- if (BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("discord.discord-messages.embed.enabled")) {
- webhook.addEmbed(generateEmbed(sender, finalString));
- } else {
- webhook.setContent(finalString);
- }
-
- try {
- webhook.execute();
- } catch (IOException exception) {
- exception.printStackTrace();
- BetterStaffChatBungeeCord.getInstance().logPrefix("&cFailed to send Discord webhook.");
- }
- } else if (BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("discord.bot.enabled")) {
- if (BetterStaffChatBungeeCord.getInstance().getConfig().getBoolean("discord.discord-messages.embed.enabled")) {
- for (String guildChannelPair : BetterStaffChatBungeeCord.getInstance().getConfig().getStringList("discord.bot.channels")) {
- String[] parts = guildChannelPair.split(": ");
- BetterStaffChatBungeeCord.getInstance().getJda().sendEmbed(parts[0], parts[1], generateEmbed(sender, finalString));
- }
- } else {
- for (String guildChannelPair : BetterStaffChatBungeeCord.getInstance().getConfig().getStringList("discord.bot.channels")) {
- String[] parts = guildChannelPair.split(": ");
- BetterStaffChatBungeeCord.getInstance().getJda().sendMessage(parts[0], parts[1], finalString);
- }
- }
- }
- });
- }
-
- @Override
- public void handleDiscord(Object event) {
- if (BetterStaffChatBungeeCord.getInstance().getConfig().getStringList("discord.bot.channels").stream().anyMatch(a -> a.equals(((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getGuild().getId() + ": " + ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getChannel().getId()))) {
- StringBuilder builder = new StringBuilder();
-
- StringBuilder discordMessage = new StringBuilder(((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getMessage().getContentStripped().trim());
-
- if (!((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getMessage().getAttachments().isEmpty()) {
- for (net.dv8tion.jda.api.entities.Message.Attachment attachment : ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getMessage().getAttachments()) {
- discordMessage.append(" ").append(attachment.getUrl());
- }
- }
-
- String nickName = ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getMember().getNickname();
-
- String name = BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.name-format")
- .replace("%username%", ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getAuthor().getName())
- .replace("%discriminator%", ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getAuthor().getDiscriminator())
- .replace("%nickname%", nickName != null ? nickName : ((net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) event).getAuthor().getName());
-
- String message = BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.format")
- .replace("%player_name%", name)
- .replace("%message%", discordMessage.toString())
- .replace("%server%", "Discord")
- .replaceAll("%\\S*%", "");
-
-
- for (String word : message.split(" ")) {
- builder.append(ChatColor.translateAlternateColorCodes('&', word));
- builder.append(" ");
- }
-
- broadcast(builder.substring(0, builder.length() - 1), "betterstaffchat.messages.read");
- }
- }
-
- protected DiscordWebhook.EmbedObject generateEmbed(Object sender, String string) {
- DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject();
- embed.setColor(Color.decode(BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.embed.embed-color")));
- embed.setDescription(string);
-
- String footer = BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.embed.embed-footer")
- .replace("%player_name%", (sender instanceof ProxiedPlayer) ? TextUtil.cleanForDiscord(((ProxiedPlayer) sender).getName()) : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-replacement"))
- .replace("%uuid%", (sender instanceof ProxiedPlayer) ? ((ProxiedPlayer) sender).getUniqueId().toString() : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-uuid-replacement"))
- .replace("%server%", (sender instanceof ProxiedPlayer) ? getFormattedServerName(((ProxiedPlayer) sender).getServer().getInfo().getName()) : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-server-replacement"));
-
- String icon = BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.embed.embed-footer-icon").replace("%player_name%", (sender instanceof ProxiedPlayer) ? TextUtil.cleanForDiscord(((ProxiedPlayer) sender).getName()) : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-replacement"))
- .replace("%uuid%", (sender instanceof ProxiedPlayer) ? ((ProxiedPlayer) sender).getUniqueId().toString() : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-uuid-replacement"))
- .replace("%server%", (sender instanceof ProxiedPlayer) ? getFormattedServerName(((ProxiedPlayer) sender).getServer().getInfo().getName()) : BetterStaffChatBungeeCord.getInstance().getConfig().getString("staffchat.console-server-replacement"));
-
- if (!BetterStaffChatBungeeCord.getInstance().getConfig().getString("discord.discord-messages.embed.embed-footer").equals("")) {
- embed.setFooter(footer, icon);
- } else embed.setFooter(footer, null);
- return embed;
- }
-}
diff --git a/BetterStaffChat-bungeecord/src/main/resources/bungee.yml b/BetterStaffChat-bungeecord/src/main/resources/bungee.yml
deleted file mode 100644
index d0728b8..0000000
--- a/BetterStaffChat-bungeecord/src/main/resources/bungee.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-name: BetterStaffChat
-version: @version@
-main: dev.austech.betterstaffchat.bungeecord.BetterStaffChatBungeeCord
-author: AusTechDev
\ No newline at end of file
diff --git a/BetterStaffChat-common/build.gradle b/BetterStaffChat-common/build.gradle
deleted file mode 100644
index f3cf87d..0000000
--- a/BetterStaffChat-common/build.gradle
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * BetterStaffChat - build.gradle
- * Copyright (C) 2021 AusTech Development Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-dependencies {
- compileOnly 'me.lucko:jar-relocator:1.4'
- compileOnly 'net.md-5:bungeecord-chat:1.16-R0.4'
-}
-
-tasks.build.dependsOn tasks.shadowJar
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/BetterStaffChatDependencyProvider.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/BetterStaffChatDependencyProvider.java
deleted file mode 100755
index a59fe1a..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/BetterStaffChatDependencyProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency;
-
-import dev.austech.betterstaffchat.common.dependency.maven.builder.MavenDependencyProvider;
-import dev.austech.betterstaffchat.common.dependency.maven.builder.MavenDependencyProviderBuilder;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocationInfo;
-
-public class BetterStaffChatDependencyProvider {
- public static MavenDependencyProvider getDependencies() {
- MavenDependencyProviderBuilder builder = new MavenDependencyProviderBuilder();
-
- builder.dependency("org|slf4j", "slf4j-api", "1.7.25");
- builder.dependency("org|slf4j", "slf4j-nop", "1.7.25");
- builder.relocation("org|slf4j", "dev.austech.betterstaffchat.shaded.slf4j");
-
- builder.repository("https://m2.dv8tion.net/releases/");
- builder.dependency("net|dv8tion", "JDA", "4.2.1_262");
-
- builder.relocation(RelocationInfo.of("net|dv8tion|jda", "dev.austech.betterstaffchat.shaded.jda"));
-
- builder.dependency("com|squareup|okhttp3", "okhttp", "3.13.0");
- builder.dependency("com|squareup|okio", "okio", "1.17.2");
- builder.dependency("org|apache|commons", "commons-collections4", "4.1");
- builder.dependency("com|fasterxml|jackson|core", "jackson-databind", "2.10.1");
- builder.dependency("com|fasterxml|jackson|core", "jackson-core", "2.10.1");
- builder.dependency("com|fasterxml|jackson|core", "jackson-annotations", "2.10.1");
-
- builder.dependency("net|sf|trove4j", "trove4j", "3.0.3");
- builder.dependency("com|neovisionaries", "nv-websocket-client", "2.14");
-
- return (MavenDependencyProvider) builder.build();
- }
-}
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/DependencyEngine.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/DependencyEngine.java
deleted file mode 100755
index 88290a4..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/DependencyEngine.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency;
-
-import dev.austech.betterstaffchat.common.dependency.annotations.LoaderPriority;
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.builder.DependencyProvider;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocatableDependencyLoader;
-import lombok.Getter;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-import java.net.URLClassLoader;
-import java.nio.file.Path;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ForkJoinPool;
-
-/**
- * A dependency engine is used as the starter point for adding dependencies to be downloaded and
- * loaded at runtime.
- */
-public final class DependencyEngine {
-
- /**
- * The base path for dependencies.
- */
- private final Path basePath;
- /**
- * A map containing all the dependency loaders for this dependency engine.
- */
- private final Map, DependencyLoader>> dependencyLoaders;
-
- /**
- * The errors that occurred during the loading process.
- */
- @Getter private final Set errors;
-
- /**
- * Creates a new dependency engine with the specified base path.
- *
- * @param basePath The base path for this dependency engine.
- */
- public DependencyEngine(final @NotNull Path basePath) {
- this.basePath = basePath;
- this.dependencyLoaders = new IdentityHashMap<>();
- this.errors = new HashSet<>();
- }
-
- /**
- * Creates a new Dependency Engine with the specified base path. It includes all the default
- * DependencyLoader's by default.
- *
- * @param basePath The base path for all dependencies to be downloaded
- * @return A new {@link DependencyEngine}
- */
- @Contract("_ -> new")
- public static @NotNull DependencyEngine createNew(final @NotNull Path basePath) {
- return DependencyEngine.createNew(basePath, true);
- }
-
- /**
- * Creates a new Dependency Engine with the specified base path.
- *
- * @param basePath The base path for all dependencies to be downloaded
- * @param addDefaultLoader Whether or not to include the default dependency loaders
- * @return A new {@link DependencyEngine}
- */
- @Contract("_,_ -> new")
- public static @NotNull DependencyEngine createNew(
- final @NotNull Path basePath,
- final boolean addDefaultLoader
- ) {
- final DependencyEngine engine = new DependencyEngine(basePath);
-
- if (addDefaultLoader) {
- engine.addDefaultDependencyLoaders();
- }
-
- return engine;
- }
-
- private void addDefaultDependencyLoaders() {
- this.addDependencyLoader(new MavenDependencyLoader(this.basePath));
- }
-
- /**
- * Adds a new dependency loader to the dependency engine. If a duplicate dependency loader is
- * added an error is thrown.
- *
- * @param loader The loader to add to the dependency engine
- * @return this
- */
- @Contract("_ -> this")
- public @NotNull DependencyEngine addDependencyLoader(final @NotNull DependencyLoader> loader) {
- if (this.dependencyLoaders.containsKey(loader.getClass())) {
- throw new IllegalArgumentException(String.format(
- "Loader with type '%s' already loaded.",
- loader.getClass().getName()
- ));
- }
-
- this.dependencyLoaders.put(loader.getClass(), loader);
- return this;
- }
-
- /**
- * Adds dependency annotations from a class to the currently loaded dependency loaders in this
- * engine. These are not added retroactively, you need to add the dependency loaders first.
- *
- * @param clazz The class to load the annotations from
- * @return this
- */
- @Contract("_ -> this")
- public @NotNull DependencyEngine addDependenciesFromClass(final @NotNull Class> clazz) {
- this.dependencyLoaders
- .values()
- .forEach(loader -> loader.loadDependenciesFrom(clazz));
- return this;
- }
-
- /**
- * Adds dependencies to the dependency loaders based on the input dependency provider. These are
- * not added retroactively, you need to add the dependency loaders first.
- *
- * @param provider The provider to add the dependencies from
- * @return this
- */
- @Contract("_ -> this")
- @SuppressWarnings("unchecked, rawtypes")
- public @NotNull DependencyEngine addDependenciesFromProvider(
- final @NotNull DependencyProvider> provider) {
- this.dependencyLoaders
- .values()
- .stream()
- .filter(loader -> loader.getGenericType() == provider.getGenericType())
- .forEach(loader -> loader.loadDependenciesFrom((DependencyProvider) provider));
- return this;
- }
-
-
- /**
- * Loads all the dependencies in the specified executor.
- *
- * @param executor An executor to load the dependencies in
- * @return A completable future that completes when all dependencies are loaded
- */
- @Contract("_ -> new")
- public @NotNull CompletableFuture loadDependencies(final @NotNull Executor executor) {
- return CompletableFuture.runAsync(
- () -> this.dependencyLoaders
- .values()
- .stream()
- .sorted(
- Comparator.comparingInt(loader ->
- loader.getClass()
- .getAnnotation(LoaderPriority.class)
- .value())
- )
- .forEach(loader -> {
- if (!this.errors.isEmpty()) {
- return;
- }
-
- try {
- loader.downloadDependencies();
-
- this.errors.addAll(loader.getErrors());
-
- if (this.errors.isEmpty() && loader instanceof RelocatableDependencyLoader) {
- ((RelocatableDependencyLoader>) loader).relocateDependencies();
- this.errors.addAll(loader.getErrors());
- }
-
- if (this.errors.isEmpty()) {
- loader.loadDependencies((URLClassLoader) this.getClass().getClassLoader());
- }
- } catch (final Exception ex) {
- this.errors.add(ex);
- }
- }),
- executor
- );
- }
-
- /**
- * Loads all dependencies in {@link ForkJoinPool#commonPool()}.
- *
- * @return A completable future that completes when all dependencies are loaded
- */
- @Contract("-> new")
- public @NotNull CompletableFuture loadDependencies() {
- return this.loadDependencies(ForkJoinPool.commonPool());
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/LoaderPriority.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/LoaderPriority.java
deleted file mode 100755
index 2c7741d..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/LoaderPriority.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.annotations;
-
-import java.lang.annotation.*;
-
-/**
- * This is used to define the order dependency loaders should be executed in.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface LoaderPriority {
-
- /**
- * The priority of the loader. Lower values go first. Default value 1000.
- *
- * @return The loader priority
- */
- int value() default 1000;
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenDependency.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenDependency.java
deleted file mode 100755
index 323a686..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenDependency.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.annotations;
-
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.annotation.*;
-
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Repeatable(MavenDependency.List.class)
-public @interface MavenDependency {
-
- /**
- * Used to declare variables in a single line Gradle notation.
- *
- *
eg: 'com.google.guava:guava:30.1-jre'; if you would like to declare dependencies in a
- * structured manner use the other variables.
- *
- * @return A Gradle style single line dependency string
- */
- @NotNull String value() default "";
-
- /**
- * Used to define a group ID for a Maven dependency.
- *
- * @return The group ID
- */
- @NotNull String groupId() default "";
-
- /**
- * Used to define an artifact ID for a Maven dependency.
- *
- * @return The artifact ID
- */
- @NotNull String artifactId() default "";
-
- /**
- * Used to define the version for a Maven dependency.
- *
- * @return The version
- */
- @NotNull String version() default "";
-
- /**
- * Used to define the package path separator.
- *
- * @return The separator to use instead of '.' or '/'
- */
- @NotNull String separator() default DependencyLoader.DEFAULT_SEPARATOR;
-
- /**
- * Used to store multiple {@link MavenDependency} annotations on a single class type.
- */
- @Documented
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- @interface List {
-
- /**
- * Used to define an array of {@link MavenDependency} annotations.
- *
- * @return An array of {@link MavenDependency} annotations
- */
- @NotNull MavenDependency[] value() default {};
- }
-
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenRepository.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenRepository.java
deleted file mode 100755
index b5919d3..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/MavenRepository.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.annotations;
-
-import dev.austech.betterstaffchat.common.dependency.maven.MavenRepositoryInfo;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.annotation.*;
-
-/**
- * Used to define a Maven repo URL for the dependencies.
- *
- * @see MavenRepositoryInfo
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Repeatable(MavenRepository.List.class)
-public @interface MavenRepository {
-
- /**
- * The URL to the Maven repository.
- *
- * @return A string that represents the URL to a Maven repo
- */
- @NotNull String value() default "https://repo1.maven.org/maven2/";
-
- /**
- * Used to store multiple {@link MavenRepository} annotations on a single class type.
- */
- @Documented
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- @interface List {
-
- /**
- * An array of maven repositories.
- *
- * @return An array of {@link MavenRepository} annotations.
- */
- @NotNull MavenRepository @NotNull [] value() default {};
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/Relocation.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/Relocation.java
deleted file mode 100755
index 17915ba..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/annotations/Relocation.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.annotations;
-
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocationInfo;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.annotation.*;
-
-/**
- * Used to define relocations for any imported {@link MavenDependency} dependencies.
- *
- *
You can't use '.' or '/' for the package names due to maven/Gradle relocation changing those
- * at compile time. The separator by default is '|' you can change the separator by changing the
- * separator value in this annotation.
- *
- *
- *
- * @see RelocationInfo
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Repeatable(Relocation.List.class)
-public @interface Relocation {
-
- /**
- * The original package location.
- *
- * @return The original package location
- */
- @NotNull String from();
-
- /**
- * Where to move the package to.
- *
- * @return Where to move the package to
- */
- @NotNull String to();
-
- /**
- * The separator to use.
- *
- * @return The separator to use instead of '.' or '/'
- */
- @NotNull String separator() default DependencyLoader.DEFAULT_SEPARATOR;
-
- /**
- * Used to store multiple {@link Relocation} annotations on a single class type.
- */
- @Documented
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- @interface List {
-
- /**
- * An array of {@link Relocation} annotations.
- *
- * @return An array of {@link Relocation} annotations
- */
- @NotNull Relocation[] value() default {};
- }
-}
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/DependencyLoadException.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/DependencyLoadException.java
deleted file mode 100755
index cc278ed..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/DependencyLoadException.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.exception;
-
-import dev.austech.betterstaffchat.common.dependency.maven.Dependency;
-import lombok.Getter;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Used when there is an error loading a dependency.
- */
-public final class DependencyLoadException extends RuntimeException {
-
- /**
- * The dependency that had an error while loading.
- */
- @Getter private final transient @NotNull Dependency dependency;
-
- /**
- * Creates a new dependency load exception.
- *
- * @param dependency The dependency that had an error while loading
- * @param message The message to pass
- */
- public DependencyLoadException(
- final @NotNull Dependency dependency,
- final @NotNull String message
- ) {
- super(message);
- this.dependency = dependency;
- }
-
- /**
- * Creates a new dependency load exception.
- *
- * @param dependency The dependency that had an error while loading
- * @param cause The cause of the error
- */
- public DependencyLoadException(
- final @NotNull Dependency dependency,
- final @NotNull Throwable cause
- ) {
- super(cause);
- this.dependency = dependency;
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/InvalidDependencyException.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/InvalidDependencyException.java
deleted file mode 100755
index f88d141..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/exception/InvalidDependencyException.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.exception;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * When a dependency isn't able to process this error is thrown.
- */
-public final class InvalidDependencyException extends RuntimeException {
-
- /**
- * A basic error that indicates there was an error parsing a dependency.
- */
- public InvalidDependencyException() {
- super();
- }
-
- /**
- * Creates a new invalid dependency exception.
- *
- * @param message The message to pass
- * @param cause The cause of the error
- */
- public InvalidDependencyException(
- final @NotNull String message,
- final @NotNull Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new invalid dependency exception.
- *
- * @param cause The cause of the error
- */
- public InvalidDependencyException(final @NotNull Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new invalid dependency exception.
- *
- * @param message The message to pass
- */
- public InvalidDependencyException(final @NotNull String message) {
- super(message);
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/generics/TypeDefinition.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/generics/TypeDefinition.java
deleted file mode 100755
index 3101a5c..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/generics/TypeDefinition.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.generics;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Used to store the generic type of a class for comparison.
- *
- * @param The generic type of this definition.
- */
-public interface TypeDefinition {
-
- /**
- * Returns the generic type of this class.
- *
- * @return The generic type
- */
- @NotNull Class getGenericType();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/Dependency.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/Dependency.java
deleted file mode 100755
index 4bbcac9..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/Dependency.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Base dependency abstraction used to define basic information for dependency retrieval.
- */
-public interface Dependency {
-
- /**
- * If there is an issue downloading the dependency this is used to get the manual download
- * location.
- *
- * @return The manual download url
- */
- @NotNull String getManualDownloadString();
-
- /**
- * Used to get the download URL of a dependency.
- *
- * @return The relative download url
- */
- @NotNull String getRelativeDownloadString();
-
- /**
- * Used to get where the dependency should be stored on download. The path is relative.
- *
- * @return The downloaded location of this dependency
- */
- @NotNull String getDownloadedFileName();
-
- /**
- * Used to get the name of the dependency for logging information.
- *
- * @return The name of this dependency
- */
- @NotNull String getName();
-
- /**
- * Set where or not this dependency has been loaded.
- *
- * @param loaded Whether or not this dependency has been loaded
- */
- void setLoaded(boolean loaded);
-
- /**
- * Whether or not this dependency has been loaded into the class path.
- *
- * @return True if it has been loaded already, false otherwise
- */
- boolean isLoaded();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/DependencyLoader.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/DependencyLoader.java
deleted file mode 100755
index f3759c6..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/DependencyLoader.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven;
-
-import dev.austech.betterstaffchat.common.dependency.generics.TypeDefinition;
-import dev.austech.betterstaffchat.common.dependency.maven.builder.DependencyProvider;
-import lombok.Getter;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.reflect.Method;
-import java.net.URLClassLoader;
-import java.nio.file.Path;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Abstract implementation of a dependency loader.
- *
- * @param Type of dependency implementation.
- * @see MavenDependencyLoader
- */
-public abstract class DependencyLoader implements TypeDefinition {
-
- /**
- * The default separator used to have compatibility with gradle/Maven relocation.
- */
- public static final @NotNull String DEFAULT_SEPARATOR = "|";
-
- /**
- * The base path for files in this dependency loader.
- */
- @Getter private final @NotNull Path basePath;
-
- /**
- * The dependencies that this dependency loader handles.
- */
- @Getter private final @NotNull List dependencies;
-
- /**
- * The errors that occurred while loading dependencies.
- */
- @Getter private final @NotNull Set errors;
-
- /**
- * Creates a new dependency loader with the specified base path.
- *
- * @param basePath The base path for dependencies.
- */
- protected DependencyLoader(final @NotNull Path basePath) {
- this.basePath = basePath;
- this.dependencies = new ArrayList<>();
- this.errors = new HashSet<>();
- this.openClassLoaderJava9();
- }
-
- /**
- * Creates a new dependency loader with the specified base path. Storage destination is used as a
- * relative sub directory for dependencies.
- *
- * @param basePath The base path for dependencies
- * @param storageDestination The relative path to dependencies in this dependency loader
- */
- protected DependencyLoader(
- final @NotNull Path basePath,
- final @NotNull String storageDestination
- ) {
- this(basePath.resolve(storageDestination));
- }
-
- /**
- * Gives this module access to the URLClassLoader.
- */
- private void openClassLoaderJava9() {
- AccessController.doPrivileged((PrivilegedAction) () -> {
- try {
- final Class> moduleClass = Class.forName("java.lang.Module");
- final Method getModuleMethod = Class.class.getMethod("getModule");
- final Method addOpensMethod = moduleClass.getMethod("addOpens", String.class, moduleClass);
-
- final Object urlClassLoaderModule = getModuleMethod.invoke(URLClassLoader.class);
- final Object thisModule = getModuleMethod.invoke(DependencyLoader.class);
-
- addOpensMethod
- .invoke(urlClassLoaderModule, URLClassLoader.class.getPackage().getName(), thisModule);
- } catch (final Exception ignored) {
- // Will throw error on clazz);
-
- /**
- * Used to load dependencies from a dependency provider.
- *
- * @param dependencyProvider The dependency provider to load dependencies from
- */
- public abstract void loadDependenciesFrom(@NotNull DependencyProvider dependencyProvider);
-
- /**
- * Downloads handled dependencies.
- */
- public abstract void downloadDependencies();
-
- /**
- * Loads the dependencies to be used by the plugin.
- *
- * @param classLoader The class loader to add the dependencies to
- */
- public abstract void loadDependencies(@NotNull URLClassLoader classLoader);
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyInfo.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyInfo.java
deleted file mode 100755
index 1217a61..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyInfo.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven;
-
-import dev.austech.betterstaffchat.common.dependency.annotations.MavenDependency;
-import dev.austech.betterstaffchat.common.dependency.exception.InvalidDependencyException;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocatableDependency;
-import lombok.Getter;
-import lombok.Setter;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-import java.util.regex.Pattern;
-
-/**
- * This is the backend class for {@link MavenDependency} dependencies. It's responsible for
- * providing basic information needed to download and relocate a dependency jar.
- *
- * @see MavenDependency
- */
-public final class MavenDependencyInfo implements RelocatableDependency {
-
- /**
- * This is used to validate a single line dependency. A single line dependency should have a size
- * of 3 always.
- */
- private static final int DEPENDENCY_SPLIT_SIZE = 3;
-
- /**
- * This is used to make sure a dependency string is valid before we try to do extra processing on
- * it.
- */
- private static final @NotNull Pattern DEPENDENCY_PATTERN = Pattern.compile("^([\\w.\\-])+$");
-
- /**
- * The group ID of this Maven dependency.
- */
- @Getter private @Nullable String groupId;
-
- /**
- * The artifact ID of this Maven dependency.
- */
- @Getter private @Nullable String artifactId;
-
- /**
- * The version of this Maven dependency.
- */
- @Getter private @Nullable String version;
-
- /**
- * Whether or not this dependency has been loaded.
- */
- @Getter @Setter private boolean loaded;
-
- private MavenDependencyInfo(
- final @NotNull String separator,
- final @NotNull String groupId,
- final @NotNull String artifactId,
- final @NotNull String version
- ) {
- this.validateAndSetValues(separator, groupId, artifactId, version);
- }
-
- private MavenDependencyInfo(final @NotNull String separator,
- final @NotNull String singleLineDependency) {
- if (singleLineDependency.isEmpty()) {
- throw new InvalidDependencyException(String.format(
- "Invalid single line dependency passed. dependency = '%s'.",
- singleLineDependency
- ));
- }
-
- final List values = new ArrayList<>(MavenDependencyInfo.DEPENDENCY_SPLIT_SIZE);
- values.addAll(Arrays.asList(singleLineDependency.split(":")));
-
- if (values.size() != MavenDependencyInfo.DEPENDENCY_SPLIT_SIZE
- || values.get(0) == null
- || values.get(1) == null
- || values.get(2) == null) {
- throw new InvalidDependencyException(String.format(
- "Invalid dependency format '%s'",
- singleLineDependency
- ));
- }
-
- this.validateAndSetValues(separator, values.get(0), values.get(1), values.get(2));
- }
-
- private static boolean hasInvalidCharacters(final @NotNull String validate) {
- return validate.contains(".") || validate.contains("/");
- }
-
- private static boolean patternMismatchString(final @NotNull String validate) {
- return !DEPENDENCY_PATTERN.matcher(validate).matches();
- }
-
- /**
- * Creates a new {@link MavenDependencyInfo} based off the passed in information.
- *
- * @param separator The separator to use instead of '.' or '/'
- * @param groupId The group ID of the dependency
- * @param artifactId The artifact ID of the dependency
- * @param version The version of the dependency
- * @return A {@link MavenDependencyInfo} representing the passed in arguments
- */
- @Contract("_,_,_,_ -> new")
- public static @NotNull MavenDependencyInfo of(
- final @NotNull String separator,
- final @NotNull String groupId,
- final @NotNull String artifactId,
- final @NotNull String version
- ) {
- return new MavenDependencyInfo(separator, groupId, artifactId, version);
- }
-
- /**
- * Create a new dependency information object.
- *
- * @param separator The separator to use instead of '.' or '/'
- * @param singleLineDependency A Gradle style single line dependency
- * @return A {@link MavenDependencyInfo} representing the passed in arguments
- */
- @Contract("_,_ -> new")
- public static @NotNull MavenDependencyInfo of(
- final @NotNull String separator,
- final @NotNull String singleLineDependency
- ) {
- return new MavenDependencyInfo(separator, singleLineDependency);
- }
-
- /**
- * Creates a new {@link MavenDependencyInfo} based off of an {@link MavenDependency} annotation.
- *
- * @param dependency The {@link MavenDependency} annotation
- * @return A {@link MavenDependencyInfo} representing the passed in arguments
- */
- @Contract("_ -> new")
- public static @NotNull MavenDependencyInfo of(
- final @NotNull MavenDependency dependency
- ) {
- return dependency.value().isEmpty()
- ? MavenDependencyInfo.of(
- dependency.separator(),
- dependency.groupId(),
- dependency.artifactId(),
- dependency.version()
- )
- : MavenDependencyInfo.of(
- dependency.separator(),
- dependency.value()
- );
- }
-
- private void validateAndSetValues(
- final @NotNull String separator,
- final @NotNull String groupId,
- final @NotNull String artifactId,
- final @NotNull String version
- ) {
- if (separator.isEmpty() || MavenDependencyInfo.hasInvalidCharacters(separator)) {
- throw new InvalidDependencyException(String.format(
- "Separator '%s' cannot contain '.' or '/'",
- separator
- ));
- }
-
- if (groupId.isEmpty() || MavenDependencyInfo.hasInvalidCharacters(groupId)) {
- throw new InvalidDependencyException(String.format(
- "Group ID '%s' cannot contain '.' or '/', use a separator instead",
- groupId
- ));
- }
-
- if (artifactId.isEmpty() || MavenDependencyInfo.hasInvalidCharacters(artifactId)) {
- throw new InvalidDependencyException(String.format(
- "Artifact ID '%s' cannot contain '.' or '/', use a separator instead",
- artifactId
- ));
- }
-
- if (version.isEmpty()) {
- throw new InvalidDependencyException("Dependency version cannot be empty");
- }
-
- final String validateGroupId = groupId.replace(separator, ".");
- final String validateArtifactId = artifactId.replace(separator, ".");
-
- if (MavenDependencyInfo.patternMismatchString(validateGroupId)) {
- throw new InvalidDependencyException(String.format(
- "Group ID '%s' contains invalid characters",
- validateGroupId
- ));
- }
-
- if (MavenDependencyInfo.patternMismatchString(validateArtifactId)) {
- throw new InvalidDependencyException(String.format(
- "Artifact ID '%s' contains invalid characters",
- validateArtifactId
- ));
- }
-
- if (MavenDependencyInfo.patternMismatchString(version)) {
- throw new InvalidDependencyException(String.format(
- "Version '%s' contains invalid characters",
- version
- ));
- }
-
- this.groupId = validateGroupId;
- this.artifactId = validateArtifactId;
- this.version = version;
- }
-
- @Override
- public @NotNull String getManualDownloadString() {
- return this.getRelativeDownloadString();
- }
-
- @Override
- public @NotNull String getRelativeDownloadString() {
- return String.format(
- "%s/%s/%s/%s-%s.jar",
- Objects.requireNonNull(this.groupId).replace(".", "/"),
- Objects.requireNonNull(this.artifactId),
- Objects.requireNonNull(this.version),
- Objects.requireNonNull(this.artifactId),
- Objects.requireNonNull(this.version)
- );
- }
-
- @Override
- public @NotNull String getDownloadedFileName() {
- return this.getName() + ".jar";
- }
-
- @Override
- public @NotNull String getName() {
- return this.artifactId + "-" + this.version;
- }
-
- @Override
- public @NotNull String getRelocatedFileName() {
- return this.getName() + "-relocated.jar";
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyLoader.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyLoader.java
deleted file mode 100755
index 3f7a7d0..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenDependencyLoader.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven;
-
-import dev.austech.betterstaffchat.common.dependency.annotations.LoaderPriority;
-import dev.austech.betterstaffchat.common.dependency.annotations.MavenDependency;
-import dev.austech.betterstaffchat.common.dependency.annotations.MavenRepository;
-import dev.austech.betterstaffchat.common.dependency.annotations.Relocation;
-import dev.austech.betterstaffchat.common.dependency.exception.DependencyLoadException;
-import dev.austech.betterstaffchat.common.dependency.exception.InvalidDependencyException;
-import dev.austech.betterstaffchat.common.dependency.maven.builder.DependencyProvider;
-import dev.austech.betterstaffchat.common.dependency.maven.builder.MavenDependencyProvider;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocatableDependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocationInfo;
-import dev.austech.betterstaffchat.common.dependency.relocation.Relocator;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * The dependency loader responsible for loading Maven dependencies.
- */
-@LoaderPriority
-public final class MavenDependencyLoader extends
- RelocatableDependencyLoader<@NotNull MavenDependencyInfo> {
-
- /**
- * This is used as the user agent for requesting the direct download jar link.
- */
- private static final AbstractMap.SimpleImmutableEntry REQUEST_USER_AGENT =
- new AbstractMap.SimpleImmutableEntry<>("User-Agent",
- "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 "
- + "Firefox/3.5.2" + " (.NET CLR 3.5.30729)"
- );
-
- /**
- * The repos attached to these dependencies.
- */
- private final @NotNull Set repos;
- /**
- * Any relocations that should be ran on the incoming dependencies.
- */
- private final @NotNull Set relocations;
-
- /**
- * Creates a new Maven dependency loader with the specified base path.
- *
- * @param basePath The base path used to resolve relative file names.
- */
- public MavenDependencyLoader(final @NotNull Path basePath) {
- this(basePath, "maven");
- }
-
- /**
- * Creates a new Maven dependency loader with the specified base path and destination directory
- * name.
- *
- * @param basePath The base path used to resolve relative file names.
- * @param storageDestination relative location for Maven dependencies to be stored.
- */
- public MavenDependencyLoader(
- final @NotNull Path basePath,
- final @NotNull String storageDestination
- ) {
- super(basePath, storageDestination);
- this.repos = new HashSet<>();
- this.repos.add(MavenRepositoryInfo.of("https://repo1.maven.org/maven2/"));
- this.relocations = new HashSet<>();
- }
-
- @Override
- public void loadDependenciesFrom(final @NotNull Class<@NotNull ?> clazz) {
- if (clazz.isAnnotationPresent(MavenRepository.class)) {
- this.repos.add(MavenRepositoryInfo.of(clazz.getAnnotation(MavenRepository.class)));
- }
-
- if (clazz.isAnnotationPresent(MavenRepository.List.class)) {
- Arrays.stream(clazz.getAnnotation(MavenRepository.List.class).value())
- .map(MavenRepositoryInfo::of)
- .forEach(this.repos::add);
- }
-
- if (clazz.isAnnotationPresent(Relocation.class)) {
- this.relocations.add(RelocationInfo.of(clazz.getAnnotation(Relocation.class)));
- }
-
- if (clazz.isAnnotationPresent(Relocation.List.class)) {
- this.relocations.addAll(
- Arrays.stream(clazz.getAnnotation(Relocation.List.class).value())
- .map(RelocationInfo::of)
- .collect(Collectors.toList())
- );
- }
-
- if (clazz.isAnnotationPresent(MavenDependency.class)) {
- super.addDependency(MavenDependencyInfo.of(clazz.getAnnotation(MavenDependency.class)));
- }
-
- if (clazz.isAnnotationPresent(MavenDependency.List.class)) {
- Arrays.stream(clazz.getAnnotation(MavenDependency.List.class).value())
- .map(MavenDependencyInfo::of)
- .forEach(super::addDependency);
- }
- }
-
- @Override
- public void loadDependenciesFrom(
- final @NotNull DependencyProvider<@NotNull MavenDependencyInfo> dependencyProvider
- ) {
- final MavenDependencyProvider provider = (MavenDependencyProvider) dependencyProvider;
-
- this.repos.addAll(provider.getRepositories());
- this.relocations.addAll(provider.getRelocations());
- provider.getDependencies().forEach(super::addDependency);
- }
-
- private @NotNull Optional> findRepoForDependency(
- final @NotNull MavenDependencyInfo dependency
- ) throws IOException {
- Optional> downloadUrl = Optional.empty();
- for (final MavenRepositoryInfo repo : this.repos) {
- final URL tempUrl = new URL((repo.getUrl().endsWith("/")
- ? repo.getUrl()
- : repo.getUrl() + "/") + dependency.getRelativeDownloadString());
-
- final HttpURLConnection connection = (HttpURLConnection) tempUrl.openConnection();
- connection.setInstanceFollowRedirects(false);
- connection.setRequestProperty(
- MavenDependencyLoader.REQUEST_USER_AGENT.getKey(),
- MavenDependencyLoader.REQUEST_USER_AGENT.getValue()
- );
- connection.setRequestMethod("HEAD");
-
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK
- || connection.getResponseCode() == HttpURLConnection.HTTP_ACCEPTED) {
- downloadUrl = Optional.of(new AbstractMap.SimpleImmutableEntry<>(repo.getUrl(), tempUrl));
- break;
- }
- }
-
- return downloadUrl;
- }
-
- @Override
- public void downloadDependencies() {
- super.getDependencies()
- .parallelStream()
- .forEach(dependency -> {
- if (dependency.isLoaded()) {
- return;
- }
-
- final Path downloadLocation = super.getBasePath()
- .resolve(dependency.getDownloadedFileName());
-
- if (!Files.exists(downloadLocation)
- && !Files.exists(super.getBasePath().resolve(dependency.getRelocatedFileName()))) {
-
- try {
- final Optional> downloadUrl =
- this.findRepoForDependency(dependency);
-
- if (!downloadUrl.isPresent()) {
- throw new InvalidDependencyException(String.format(
- "Couldn't download dependency: '%s'.",
- dependency.getName()
- ));
- }
-
- try (final InputStream is = downloadUrl.get().getValue().openStream()) {
- Files.createDirectories(downloadLocation.getParent());
- Files.deleteIfExists(downloadLocation);
- Files.copy(is, downloadLocation);
- }
- } catch (final IOException ex) {
- super.addError(new DependencyLoadException(dependency, ex));
- }
- }
- });
- }
-
- private void relocateDependency(
- final @NotNull Relocator relocator,
- final @NotNull MavenDependencyInfo dependency
- ) {
- try {
- final Path relocatedLocation = super.getBasePath().resolve(dependency.getRelocatedFileName());
-
- if (!Files.exists(relocatedLocation)) {
- relocator.relocate(this.relocations, dependency);
-
- Files.delete(super.getBasePath().resolve(dependency.getDownloadedFileName()));
- }
- } catch (final DependencyLoadException ex) {
- super.addError(ex);
- } catch (final Exception ex) {
- super.addError(new DependencyLoadException(dependency, ex));
- }
- }
-
- @Override
- public void relocateDependencies() {
- try {
-
- final Relocator relocator = new Relocator(super.getBasePath());
-
-
- super.getDependencies()
- .parallelStream()
- .forEach( dependency -> {
- if (dependency.isLoaded()) {
- return;
- }
- this.relocateDependency(relocator, dependency);
- });
- } catch (final DependencyLoadException ex) {
- super.addError(ex);
- }
- }
-
- @Override
- public void loadDependencies(final @NotNull URLClassLoader classLoader) {
- try {
- final Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- AccessController.doPrivileged((PrivilegedAction) () -> {
- method.setAccessible(true);
- return null;
- });
-
- super.getDependencies()
- .parallelStream()
- .forEach(dependency -> {
- if (dependency.isLoaded()) {
- return;
- }
-
- try {
- final Path downloadLocation = super.getBasePath()
- .resolve(dependency.getDownloadedFileName());
- final Path relocatedLocation = super.getBasePath()
- .resolve(dependency.getRelocatedFileName());
-
- if (Files.exists(relocatedLocation)) {
- method.invoke(classLoader, relocatedLocation.toUri().toURL());
- } else {
- method.invoke(classLoader, downloadLocation.toUri().toURL());
- }
-
- dependency.setLoaded(true);
- } catch (final IllegalAccessException
- | InvocationTargetException
- | MalformedURLException ex) {
- super.addError(new DependencyLoadException(dependency, ex));
- }
- });
- } catch (final Exception ex) {
- super.addError(ex);
- }
- }
-
- @Override
- public @NotNull Class<@NotNull MavenDependencyInfo> getGenericType() {
- return MavenDependencyInfo.class;
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenRepositoryInfo.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenRepositoryInfo.java
deleted file mode 100755
index 824def7..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/MavenRepositoryInfo.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven;
-
-import dev.austech.betterstaffchat.common.dependency.annotations.MavenRepository;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-import java.net.URL;
-
-/**
- * Implementation representing {@link MavenRepository}.
- *
- * @see MavenRepository
- */
-@RequiredArgsConstructor
-@EqualsAndHashCode
-public final class MavenRepositoryInfo {
-
- /**
- * The URL for this Maven repository.
- */
- @Getter private final @NotNull String url;
-
- /**
- * Creates a new Maven repository from a {@link URL}.
- *
- * @param url The url
- * @return A new {@link MavenRepositoryInfo}.
- */
- @Contract("_ -> new")
- public static @NotNull MavenRepositoryInfo of(final @NotNull URL url) {
- return new MavenRepositoryInfo(String.valueOf(url));
- }
-
- /**
- * Creates a new Maven repository from a {@link MavenRepository} annotation.
- *
- * @param repository The annotation
- * @return A new {@link MavenRepositoryInfo}.
- */
- @Contract("_ -> new")
- public static @NotNull MavenRepositoryInfo of(final @NotNull MavenRepository repository) {
- return new MavenRepositoryInfo(repository.value());
- }
-
- /**
- * Creates a new Maven repository from a string representing a url.
- *
- * @param url the url
- * @return A new {@link MavenRepositoryInfo}.
- */
- @Contract("_ -> new")
- public static @NotNull MavenRepositoryInfo of(final @NotNull String url) {
- return new MavenRepositoryInfo(url);
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyBuilder.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyBuilder.java
deleted file mode 100755
index 2cee6ea..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven.builder;
-
-import dev.austech.betterstaffchat.common.dependency.maven.Dependency;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Base level implementation of DependencyBuilder.
- *
- * @param The dependency type
- */
-public interface DependencyBuilder {
-
- /**
- * Add a dependency to the dependency builder.
- *
- * @param dependency The dependency to add
- * @return this
- */
- @Contract("_ -> this")
- @NotNull DependencyBuilder dependency(@NotNull T dependency);
-
- /**
- * Creates a new {@link DependencyProvider} from the builder.
- *
- * @return A new {@link DependencyProvider}
- */
- @Contract("-> new")
- @NotNull DependencyProvider build();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyProvider.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyProvider.java
deleted file mode 100755
index d5a5e11..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/DependencyProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven.builder;
-
-import dev.austech.betterstaffchat.common.dependency.generics.TypeDefinition;
-import dev.austech.betterstaffchat.common.dependency.maven.Dependency;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Set;
-
-/**
- * Base level dependency provider.
- *
- * @param The dependency this class provides
- */
-public interface DependencyProvider extends TypeDefinition {
-
- /**
- * Gets the set of dependencies attached to this provider.
- *
- * @return The set of dependencies attached to this provider
- */
- @NotNull Set getDependencies();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProvider.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProvider.java
deleted file mode 100755
index d3cf5bc..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProvider.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven.builder;
-
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyInfo;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenRepositoryInfo;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocationInfo;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Set;
-
-/**
- * This class is used to attach dependencies to a {@link MavenDependencyLoader}.
- */
-@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
-public final class MavenDependencyProvider implements DependencyProvider {
-
- /**
- * The repositories in this provider.
- */
- @Getter private final @NotNull Set repositories;
-
- /**
- * The dependencies in this provider.
- */
- @Getter private final @NotNull Set dependencies;
-
- /**
- * The relocations in this provider.
- */
- @Getter private final @NotNull Set relocations;
-
- /**
- * Creates a new {@link MavenDependencyProviderBuilder} instance.
- *
- * @return new {@link MavenDependencyProviderBuilder}
- */
- @Contract("-> new")
- public static MavenDependencyProviderBuilder builder() {
- return new MavenDependencyProviderBuilder();
- }
-
- @Override
- public @NotNull Class getGenericType() {
- return MavenDependencyInfo.class;
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProviderBuilder.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProviderBuilder.java
deleted file mode 100755
index 4b0f512..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/maven/builder/MavenDependencyProviderBuilder.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.maven.builder;
-
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyInfo;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenRepositoryInfo;
-import dev.austech.betterstaffchat.common.dependency.relocation.RelocationInfo;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Used to build a dependency provider that should be attached to a {@link MavenDependencyLoader}
- * then loaded.
- */
-public final class MavenDependencyProviderBuilder implements
- DependencyBuilder {
-
- /**
- * The set of repositories to add to the provider.
- */
- private final @NotNull Set repositories;
-
- /**
- * The set of Maven dependencies to add to the provider.
- */
- private final @NotNull Set dependencies;
-
- /**
- * The set of relocations to add to the provider.
- */
- private final @NotNull Set relocations;
-
- /**
- * Creates a new dependency builder.
- */
- public MavenDependencyProviderBuilder() {
- this.repositories = new HashSet<>();
- this.dependencies = new HashSet<>();
- this.relocations = new HashSet<>();
- }
-
- @Contract("_ -> this")
- @Override
- public @NotNull MavenDependencyProviderBuilder dependency(
- final @NotNull MavenDependencyInfo dependency
- ) {
- this.dependencies.add(dependency);
- return this;
- }
-
- /**
- * Creates a new Maven dependency provider builder.
- *
- * @param groupId The group ID of the Maven dependency
- * @param artifactId The artifact ID of the Maven dependency
- * @param version The version of the Maven dependency
- * @return this
- */
- @Contract("_,_,_ -> this")
- public @NotNull MavenDependencyProviderBuilder dependency(
- final @NotNull String groupId,
- final @NotNull String artifactId,
- final @NotNull String version
- ) {
- return this.dependency(MavenDependencyInfo.of(
- DependencyLoader.DEFAULT_SEPARATOR,
- groupId,
- artifactId,
- version
- ));
- }
-
- /**
- * Creates a new Maven dependency provider builder.
- *
- * @param separator The separator used for package names
- * @param groupId The group ID of the Maven dependency
- * @param artifactId The artifact ID of the Maven dependency
- * @param version The version of the Maven dependency
- * @return this
- */
- @Contract("_,_,_,_ -> this")
- public @NotNull MavenDependencyProviderBuilder dependency(
- final @NotNull String separator,
- final @NotNull String groupId,
- final @NotNull String artifactId,
- final @NotNull String version
- ) {
- return this.dependency(MavenDependencyInfo.of(separator, groupId, artifactId, version));
- }
-
- /**
- * Creates a new Maven dependency provider builder.
- *
- * @param separator The separator used for package separation
- * @param singleLineDependency The Gradle style single line dependency string
- * @return this
- */
- @Contract("_,_ -> this")
- public @NotNull MavenDependencyProviderBuilder dependency(
- final @NotNull String separator,
- final @NotNull String singleLineDependency
- ) {
- return this.dependency(MavenDependencyInfo.of(separator, singleLineDependency));
- }
-
- /**
- * Creates a new Maven dependency provider builder.
- *
- * @param singleLineDependency The Gradle style single line dependency string
- * @return this
- */
- @Contract("_ -> this")
- public @NotNull MavenDependencyProviderBuilder dependency(
- final @NotNull String singleLineDependency
- ) {
- return this.dependency(
- MavenDependencyInfo.of(DependencyLoader.DEFAULT_SEPARATOR, singleLineDependency));
- }
-
- /**
- * Creates a new Maven dependency provider builder.
- *
- * @param repository The repository
- * @return The same instance
- * @see MavenRepositoryInfo
- */
- @Contract("_ -> this")
- public MavenDependencyProviderBuilder repository(final @NotNull MavenRepositoryInfo repository) {
- this.repositories.add(repository);
- return this;
- }
-
- /**
- * Sets the repository URL.
- *
- * @param url String URL representation of a Maven repository
- * @return The same instance
- */
- @Contract("_ -> this")
- public MavenDependencyProviderBuilder repository(final @NotNull String url) {
- return this.repository(MavenRepositoryInfo.of(url));
- }
-
- /**
- * Sets the repository URL.
- *
- * @param url URL representation of a Maven repository
- * @return The same instance
- */
- @Contract("_ -> this")
- public MavenDependencyProviderBuilder repository(final @NotNull URL url) {
- return this.repository(MavenRepositoryInfo.of(url));
- }
-
- /**
- * Sets the relocation.
- *
- * @param relocation The relocation
- * @return The same instance
- * @see RelocationInfo
- */
- @Contract("_ -> this")
- public MavenDependencyProviderBuilder relocation(final @NotNull RelocationInfo relocation) {
- this.relocations.add(relocation);
- return this;
- }
-
- /**
- * Sets the relocation.
- *
- * @param from Original package destination name
- * @param to Target package destination name
- * @param separator The separator to use instead of '.' or '/'
- * @return The same instance
- */
- @Contract("_,_,_ -> this")
- public MavenDependencyProviderBuilder relocation(
- final @NotNull String from,
- final @NotNull String to,
- final @NotNull String separator
- ) {
- return this.relocation(RelocationInfo.of(from, to, separator));
- }
-
- /**
- * Sets the relocation.
- *
- * @param from The package to relocate from
- * @param to The package to relocate to
- * @return this
- */
- @Contract("_,_ -> this")
- public MavenDependencyProviderBuilder relocation(final @NotNull String from,
- final @NotNull String to) {
- return this.relocation(RelocationInfo.of(from, to, DependencyLoader.DEFAULT_SEPARATOR));
- }
-
- @Contract("-> new")
- @Override
- public @NotNull DependencyProvider build() {
- return new MavenDependencyProvider(this.repositories, this.dependencies, this.relocations);
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/IsolatedClassLoader.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/IsolatedClassLoader.java
deleted file mode 100755
index f855f1f..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/IsolatedClassLoader.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-package dev.austech.betterstaffchat.common.dependency.relocation;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.file.Path;
-import java.util.Objects;
-
-/**
- * This class handles loading some dependencies that are needed for loading other dependencies, but
- * not need afterwards.
- */
-public final class IsolatedClassLoader extends URLClassLoader {
-
- static {
- ClassLoader.registerAsParallelCapable();
- }
-
- /**
- * Instantiates a new Isolated class loader.
- *
- * @param urls The URLs
- */
- public IsolatedClassLoader(final @NotNull URL... urls) {
- super(Objects.requireNonNull(urls), ClassLoader.getSystemClassLoader().getParent());
- }
-
- @Override
- public void addURL(final @NotNull URL url) {
- super.addURL(url);
- }
-
- /**
- * Add path boolean.
- *
- * @param path The path
- * @return The boolean
- */
- public boolean addPath(final @NotNull Path path) {
- try {
- this.addURL(path.toUri().toURL());
- return true;
- } catch (final MalformedURLException ex) {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependency.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependency.java
deleted file mode 100755
index 5fab9b8..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependency.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.relocation;
-
-import dev.austech.betterstaffchat.common.dependency.maven.Dependency;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyInfo;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Used to define dependencies that need to be relocated at runtime.
- *
- * @see MavenDependencyInfo
- */
-public interface RelocatableDependency extends Dependency {
-
- /**
- * Used to get the relocated location of a dependency. This path is relative.
- *
- * @return The relocation jar location of this dependency
- */
- @NotNull String getRelocatedFileName();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependencyLoader.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependencyLoader.java
deleted file mode 100755
index ed31c40..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocatableDependencyLoader.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.relocation;
-
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import org.jetbrains.annotations.NotNull;
-
-import java.nio.file.Path;
-
-/**
- * A {@link DependencyLoader} that supports relocations.
- *
- * @param A Relocatable Dependency to handle.
- */
-public abstract class RelocatableDependencyLoader extends
- DependencyLoader {
-
- /**
- * Creates a new dependency loader that supports relocations with the specified base path.
- *
- * @param basePath The base path for dependencies in this dependency loader
- */
- protected RelocatableDependencyLoader(final @NotNull Path basePath) {
- super(basePath);
- }
-
- /**
- * Creates a new dependency loader that supports relocations with the specified base path. The
- * storage destination is a relative sub directory for dependencies specific to this loader.
- *
- * @param basePath The base path for this dependency loader
- * @param storageDestination The relative sub directory for dependencies
- */
- protected RelocatableDependencyLoader(
- final @NotNull Path basePath,
- final @NotNull String storageDestination
- ) {
- super(basePath, storageDestination);
- }
-
- /**
- * Relocates dependencies based on provided relocations.
- */
- public abstract void relocateDependencies();
-}
\ No newline at end of file
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocationInfo.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocationInfo.java
deleted file mode 100755
index 29891ec..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/RelocationInfo.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.relocation;
-
-import dev.austech.betterstaffchat.common.dependency.annotations.Relocation;
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Implementation representing {@link Relocation}.
- *
- * @see Relocation
- */
-@RequiredArgsConstructor
-@EqualsAndHashCode
-public final class RelocationInfo {
-
- /**
- * The package to search for.
- */
- @Getter private final @NotNull String from;
-
- /**
- * The package to place.
- */
- @Getter private final @NotNull String to;
-
- /**
- * The separate used to indicate package names.
- */
- @Getter private final @NotNull String separator;
-
- /**
- * Creates a new relocation based off of the passed in information.
- *
- * @param from The package to find
- * @param to The package to replace with
- * @param separator The separator used to indicate package names
- * @return A new {@link RelocationInfo} instance
- */
- @Contract("_,_,_ -> new")
- public static @NotNull RelocationInfo of(
- final @NotNull String from,
- final @NotNull String to,
- final @NotNull String separator
- ) {
- return new RelocationInfo(from, to, separator);
- }
-
- /**
- * Creates a new relocation based off of the passed in information. Uses the {@link
- * DependencyLoader#DEFAULT_SEPARATOR} as the separator.
- *
- * @param from The package to find
- * @param to The package to replace with
- * @return A new {@link RelocationInfo} instance
- */
- @Contract("_,_-> new")
- public static @NotNull RelocationInfo of(
- final @NotNull String from,
- final @NotNull String to
- ) {
- return new RelocationInfo(from, to, DependencyLoader.DEFAULT_SEPARATOR);
- }
-
- /**
- * Creates a new relocation from the passed in {@link Relocation} annotation.
- *
- * @param relocation The {@link Relocation} annotation
- * @return A new {@link RelocationInfo} instance
- */
- @Contract("_ -> new")
- public static @NotNull RelocationInfo of(final @NotNull Relocation relocation) {
- return new RelocationInfo(relocation.from(), relocation.to(), relocation.separator());
- }
-}
diff --git a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/Relocator.java b/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/Relocator.java
deleted file mode 100755
index 2e143ed..0000000
--- a/BetterStaffChat-common/src/main/java/dev/austech/betterstaffchat/common/dependency/relocation/Relocator.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 Justin Heflin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * This file is apart of PluginBase (https://github.com/Demeng7215/PluginBase)
- */
-
-package dev.austech.betterstaffchat.common.dependency.relocation;
-
-import dev.austech.betterstaffchat.common.dependency.exception.DependencyLoadException;
-import dev.austech.betterstaffchat.common.dependency.maven.DependencyLoader;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyInfo;
-import dev.austech.betterstaffchat.common.dependency.maven.MavenDependencyLoader;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Path;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * This class is used for relocating the packages inside of a downloaded jar.
- */
-public final class Relocator {
-
- /**
- * The ASM Dependency information.
- */
- private static final MavenDependencyInfo ASM;
- /**
- * The ASM commons dependency information.
- */
- private static final MavenDependencyInfo ASM_COMMONS;
- /**
- * The jar relocator dependency information.
- */
- private static final MavenDependencyInfo JAR_RELOCATOR;
-
- static {
- ASM = MavenDependencyInfo.of("|", "org|ow2|asm:asm:7.0");
- ASM_COMMONS = MavenDependencyInfo.of("|", "org|ow2|asm:asm-commons:7.0");
- JAR_RELOCATOR = MavenDependencyInfo.of("|", "me|lucko:jar-relocator:1.4");
- }
-
- /**
- * The base directory for the relocator dependencies.
- */
- private final @NotNull Path basePath;
- /**
- * The constructor for the jar relocator class.
- */
- private final @NotNull Constructor> jarRelocatorConstructor;
- /**
- * The method to run the jar relocator.
- */
- private final @NotNull Method jarRelocatorRunMethod;
- /**
- * The relocation constructor.
- */
- private final @NotNull Constructor> relocationConstructor;
- /**
- * The isolated class loader instance. This is used to separate the classes used at only for
- * relocating from everywhere else.
- */
- private @Nullable IsolatedClassLoader isolatedClassLoader;
-
-
- /**
- * Creates a new relocator instance.
- *
- * @param basePath The base path for relocations
- */
- public Relocator(final @NotNull Path basePath) {
- this.basePath = basePath;
- AccessController.doPrivileged(
- (PrivilegedAction>) () -> this.isolatedClassLoader = new IsolatedClassLoader());
-
- final DependencyLoader dependencyHandler =
- new MavenDependencyLoader(this.basePath.resolve("relocator"));
- dependencyHandler.addDependency(ASM);
- dependencyHandler.addDependency(ASM_COMMONS);
- dependencyHandler.addDependency(JAR_RELOCATOR);
-
- dependencyHandler.downloadDependencies();
- dependencyHandler.loadDependencies(this.isolatedClassLoader);
-
-
- if (!dependencyHandler.getErrors().isEmpty()) {
- final Exception e = dependencyHandler.getErrors().stream().iterator().next();
-
- throw e instanceof DependencyLoadException
- ? (DependencyLoadException) e
- : new DependencyLoadException(ASM, e);
- }
-
- try {
- final Class> jarRelocatorClass = this.isolatedClassLoader
- .loadClass("me.lucko.jarrelocator.JarRelocator");
- final Class> relocationClass = this.isolatedClassLoader
- .loadClass("me.lucko.jarrelocator.Relocation");
-
- this.jarRelocatorConstructor = jarRelocatorClass.getConstructor(
- File.class,
- File.class,
- Collection.class
- );
- this.jarRelocatorRunMethod = jarRelocatorClass.getMethod("run");
-
- this.relocationConstructor = relocationClass.getConstructor(
- String.class,
- String.class,
- Collection.class,
- Collection.class
- );
- } catch (final Exception ex) {
- throw new DependencyLoadException(ASM, ex);
- }
- }
-
- /**
- * Relocates the packages in a jar file based on the specified relocations.
- *
- * @param relocations A collection of {@link RelocationInfo} used for relocation information
- * @param dependency The dependency to relocate
- * @throws IllegalAccessException If the relocator was denied access to any of the methods
- * @throws InvocationTargetException If there was an error while relocating the jar files
- * @throws InstantiationException If there was an error while creating a new relocation
- * instance
- */
- public void relocate(
- final @NotNull Collection relocations,
- final @NotNull RelocatableDependency dependency
- ) throws IllegalAccessException, InvocationTargetException, InstantiationException {
- final Set