├── simplixcore-minecraft ├── simplixcore-minecraft-spigot │ ├── simplixcore-minecraft-spigot-tests │ │ ├── settings.yml │ │ ├── src │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── spigot │ │ │ │ └── tests │ │ │ │ ├── stub │ │ │ │ ├── StubServer.java │ │ │ │ └── StubPlayer.java │ │ │ │ ├── SpigotPluginLoadTest.java │ │ │ │ ├── SpigotCommandTest.java │ │ │ │ ├── SpigotListenerImplTest.java │ │ │ │ └── SpigotPluginShadeTest.java │ │ └── pom.xml │ ├── simplixcore-minecraft-spigot-plugin │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── fakeplugin.yml │ │ │ ├── FakeJavaPlugin.class │ │ │ ├── plugin.yml │ │ │ └── updatepolicy.json │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── spigot │ │ │ └── plugin │ │ │ ├── util │ │ │ └── PluginDescriptionUtil.java │ │ │ ├── listeners │ │ │ └── ApplicationPreInstallListener.java │ │ │ └── deploader │ │ │ └── PluginTypeHandler.java │ ├── simplixcore-minecraft-spigot-implementation │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── spigot │ │ │ ├── SpigotSimplixModule.java │ │ │ └── plugin │ │ │ └── SpigotPluginManager.java │ ├── simplixcore-minecraft-spigot-dynamiclisteners │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── spigot │ │ │ │ └── dynamiclisteners │ │ │ │ └── DynamicListenersSimplixModule.java │ │ └── pom.xml │ ├── simplixcore-minecraft-spigot-dynamiccommands │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── minecraft │ │ │ │ └── spigot │ │ │ │ └── dynamiccommands │ │ │ │ └── DynamicCommandsSimplixModule.java │ │ └── pom.xml │ ├── pom.xml │ └── simplixcore-minecraft-spigot-quickstart │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── dev │ │ └── simplix │ │ └── core │ │ └── minecraft │ │ └── spigot │ │ └── quickstart │ │ ├── SimplixCommand.java │ │ └── SimplixQuickStart.java ├── simplixcore-minecraft-bungeecord │ ├── simplixcore-minecraft-bungeecord-plugin │ │ └── src │ │ │ └── main │ │ │ ├── resources │ │ │ ├── bungee.yml │ │ │ └── updatepolicy.json │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── bungeecord │ │ │ └── plugin │ │ │ ├── util │ │ │ └── PluginDescriptionUtil.java │ │ │ ├── listeners │ │ │ └── ApplicationPreInstallListener.java │ │ │ └── BungeeCordListenerImpl.java │ ├── simplixcore-minecraft-bungeecord-tests │ │ ├── src │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── bungeecord │ │ │ │ └── tests │ │ │ │ ├── stub │ │ │ │ ├── StubProxyServer.java │ │ │ │ └── StubProxiedPlayer.java │ │ │ │ ├── BungeeCordCommandTest.java │ │ │ │ ├── BungeeCordListenerImplTest.java │ │ │ │ └── BungeeCordPluginShadeTest.java │ │ └── pom.xml │ ├── simplixcore-minecraft-bungeecord-implementation │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── bungeecord │ │ │ ├── BungeeCordSimplixModule.java │ │ │ └── plugin │ │ │ └── BungeeCordPluginManager.java │ ├── simplixcore-minecraft-bungeecord-slf4j │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── bungeecord │ │ │ └── slf4j │ │ │ └── BungeeLoggerFactory.java │ ├── simplixcore-minecraft-bungeecord-dynamiccommands │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── bungeecord │ │ │ │ └── dynamiccommands │ │ │ │ └── DynamicCommandsSimplixModule.java │ │ └── pom.xml │ ├── simplixcore-minecraft-bungeecord-dynamiclisteners │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── bungeecord │ │ │ │ └── dynamiclisteners │ │ │ │ └── DynamicListenersSimplixModule.java │ │ └── pom.xml │ ├── pom.xml │ └── simplixcore-minecraft-bungeecord-quickstart │ │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── bungeecord │ │ │ └── quickstart │ │ │ ├── SimplixQuickStart.java │ │ │ └── SimplixCommand.java │ │ └── pom.xml ├── simplixcore-minecraft-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ ├── api │ │ │ ├── providers │ │ │ │ └── PluginManager.java │ │ │ └── events │ │ │ │ ├── QuitEvent.java │ │ │ │ ├── JoinEvent.java │ │ │ │ └── ChatEvent.java │ │ │ └── modules │ │ │ └── SimplixMinecraftModule.java │ └── pom.xml ├── simplixcore-minecraft-velocity │ ├── simplixcore-minecraft-velocity-implementation │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── velocity │ │ │ │ └── VelocitySimplixModule.java │ │ └── pom.xml │ ├── simplixcore-minecraft-velocity-dynamiccommands │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── dev │ │ │ │ └── simplix │ │ │ │ └── core │ │ │ │ └── minecraft │ │ │ │ └── velocity │ │ │ │ └── dynamiccommands │ │ │ │ ├── CommandMeta.java │ │ │ │ └── DynamicCommandsSimplixModule.java │ │ └── pom.xml │ ├── simplixcore-minecraft-velocity-tests │ │ └── pom.xml │ ├── simplixcore-minecraft-velocity-quickstart │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── velocity │ │ │ └── quickstart │ │ │ └── SimplixQuickStart.java │ ├── simplixcore-minecraft-velocity-dynamiclisteners │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── velocity │ │ │ └── dynamiclisteners │ │ │ └── DynamicListenersSimplixModule.java │ ├── simplixcore-minecraft-velocity-plugin │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── minecraft │ │ │ └── velocity │ │ │ └── plugin │ │ │ ├── VelocityPluginManager.java │ │ │ ├── libloader │ │ │ └── PluginClassLoaderFabricator.java │ │ │ ├── VelocityListenerImpl.java │ │ │ └── listeners │ │ │ └── ApplicationPreInstallListener.java │ └── pom.xml └── pom.xml ├── simplixcore-common ├── simplixcore-common-tests │ ├── src │ │ └── test │ │ │ ├── resources │ │ │ ├── en.properties │ │ │ └── de.properties │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── common │ │ │ ├── event │ │ │ └── EventsTest.java │ │ │ ├── i18n │ │ │ └── InternationalizationTest.java │ │ │ ├── version │ │ │ └── VersionTest.java │ │ │ ├── deploader │ │ │ └── ArtifactDependencyLoaderTest.java │ │ │ ├── ReplacerTest.java │ │ │ ├── listener │ │ │ └── ListenersTest.java │ │ │ ├── ApplicationInfoTest.java │ │ │ ├── converter │ │ │ └── ConvertersTest.java │ │ │ ├── durations │ │ │ └── SimpleDurationTest.java │ │ │ ├── permission │ │ │ └── PermissionsTest.java │ │ │ └── inject │ │ │ └── SimplixInstallerTest.java │ └── pom.xml ├── simplixcore-common-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── dev │ │ │ └── simplix │ │ │ └── core │ │ │ └── common │ │ │ ├── platform │ │ │ ├── Platform.java │ │ │ └── PlatformDependent.java │ │ │ ├── deploader │ │ │ ├── DependencyTypeHandler.java │ │ │ ├── DependencyManifest.java │ │ │ ├── Repository.java │ │ │ ├── DependencyLoader.java │ │ │ ├── DependencyLoadingException.java │ │ │ └── Dependency.java │ │ │ ├── scanner │ │ │ └── FailureAware.java │ │ │ ├── providers │ │ │ ├── ExceptionHandler.java │ │ │ └── Debugger.java │ │ │ ├── updater │ │ │ ├── UpdateDownloader.java │ │ │ ├── UpdatePolicy.java │ │ │ ├── VersionFetcher.java │ │ │ └── Updater.java │ │ │ ├── event │ │ │ ├── Event.java │ │ │ ├── AbstractEvent.java │ │ │ └── Events.java │ │ │ ├── duration │ │ │ ├── AbstractDuration.java │ │ │ ├── Duration.java │ │ │ └── Durations.java │ │ │ ├── aop │ │ │ ├── SuppressWarnings.java │ │ │ ├── ComponentInterceptor.java │ │ │ ├── Private.java │ │ │ ├── AlwaysConstruct.java │ │ │ ├── ScanComponents.java │ │ │ ├── RequireModules.java │ │ │ ├── ApplicationModule.java │ │ │ ├── SimplixApplication.java │ │ │ ├── Component.java │ │ │ └── AbstractSimplixModule.java │ │ │ ├── converter │ │ │ └── Converter.java │ │ │ ├── libloader │ │ │ ├── LibraryLoader.java │ │ │ └── SimplixClassLoader.java │ │ │ ├── permission │ │ │ ├── Permission.java │ │ │ └── Permissions.java │ │ │ ├── listener │ │ │ ├── Listener.java │ │ │ └── Listeners.java │ │ │ ├── events │ │ │ └── ApplicationPreInstallEvent.java │ │ │ ├── i18n │ │ │ ├── LocalizationManagerFactory.java │ │ │ └── LocalizationManager.java │ │ │ ├── ApplicationInfo.java │ │ │ ├── durations │ │ │ └── SimpleDuration.java │ │ │ └── utils │ │ │ └── FileUtils.java │ └── pom.xml ├── simplixcore-common-implementation │ └── src │ │ └── main │ │ └── java │ │ └── dev │ │ └── simplix │ │ └── core │ │ └── common │ │ ├── libloader │ │ ├── LibraryDescription.java │ │ ├── StandaloneClassLoaderFabricator.java │ │ ├── LibraryTypeHandler.java │ │ ├── LibraryClassLoader.java │ │ └── SharedLibraryTypeHandler.java │ │ ├── CommonSimplixModule.java │ │ ├── updater │ │ ├── SpigotMcResourceVersionFetcher.java │ │ ├── UrlUpdateDownloader.java │ │ └── UrlVersionFetcher.java │ │ └── i18n │ │ └── SimpleLocalizationManager.java └── pom.xml ├── simplixcore-http ├── src │ └── main │ │ ├── resources │ │ └── library.json │ │ └── java │ │ └── dev │ │ └── simplix │ │ └── core │ │ └── http │ │ └── HttpLibrary.java └── pom.xml ├── simplixcore-database ├── simplixcore-database-sql │ └── src │ │ └── main │ │ └── java │ │ └── dev │ │ └── simplix │ │ └── core │ │ └── database │ │ └── sql │ │ ├── function │ │ ├── Transaction.java │ │ ├── ResultSetConsumer.java │ │ ├── BatchFiller.java │ │ ├── PreparedStatementFiller.java │ │ ├── PreparedStatementExecutor.java │ │ ├── PreparedStatementTransformer.java │ │ ├── PreparedStatementSupplier.java │ │ └── ResultSetTransformer.java │ │ ├── exceptions │ │ └── SqlRuntimeException.java │ │ ├── handlers │ │ ├── HikariConnectionHandler.java │ │ └── SqlConnectionHandler.java │ │ ├── handler │ │ └── ConnectionHandler.java │ │ ├── JdbcDataSourceCreator.java │ │ ├── model │ │ ├── TableInformation.java │ │ └── FieldInformation.java │ │ ├── HikariDataSourceCreator.java │ │ └── util │ │ └── QueryFactory.java └── pom.xml ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── .gitlab-ci.yml ├── LICENSE └── simplixcore-config └── pom.xml /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/settings.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/resources/en.properties: -------------------------------------------------------------------------------- 1 | test-string=A test string 2 | another-test=Hello World -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/resources/de.properties: -------------------------------------------------------------------------------- 1 | # Test strings 2 | test-string=Ein Teststring 3 | another-test=Hallo Welt -------------------------------------------------------------------------------- /simplixcore-http/src/main/resources/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SimplixCoreHttp", 3 | "version": "1.0", 4 | "authors": [ 5 | "SimplixSoftworks" 6 | ], 7 | "mainClass": "dev.simplix.core.http.HttpLibrary" 8 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/platform/Platform.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.platform; 2 | 3 | public enum Platform { 4 | 5 | SPIGOT, BUNGEECORD, VELOCITY, SPONGE, HYTALE, STANDALONE 6 | 7 | } 8 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/Transaction.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | public interface Transaction { 4 | 5 | void transact() throws Exception; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: SimplixCore 2 | main: dev.simplix.core.minecraft.bungeecord.plugin.SimplixPlugin 3 | version: '${project.version}' 4 | author: SimplixSoftworks -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/resources/fakeplugin.yml: -------------------------------------------------------------------------------- 1 | name: SimplixBridge 2 | version: 1.0 3 | authors: [ SimplixSoftworks ] 4 | 5 | main: dev.simplix.core.minecraft.spigot.fake.FakeJavaPlugin 6 | 7 | api-version: 1.16 8 | -------------------------------------------------------------------------------- /simplixcore-http/src/main/java/dev/simplix/core/http/HttpLibrary.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.http; 2 | 3 | import dev.simplix.core.common.aop.SimplixApplication; 4 | 5 | @SimplixApplication(name = "SimplixCoreHttp", version = "1.0", authors = "SimplixSoftworks") 6 | public class HttpLibrary { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/src/test/java/dev/simplix/core/minecraft/bungeecord/tests/stub/StubProxyServer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.tests.stub; 2 | 3 | public class StubProxyServer extends FakeProxyServer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/resources/FakeJavaPlugin.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simplix-Softworks/SimplixCore/HEAD/simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/resources/FakeJavaPlugin.class -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: SimplixCore 2 | main: dev.simplix.core.minecraft.spigot.plugin.SimplixPlugin 3 | version: '${project.version}' 4 | author: SimplixSoftworks 5 | softdepend: 6 | - SimplixBridge 7 | 8 | api-version: 1.16 -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/DependencyTypeHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import java.io.File; 4 | 5 | public interface DependencyTypeHandler { 6 | 7 | void handle(Dependency dependency, File file); 8 | 9 | boolean shouldInstall(Dependency dependency); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/scanner/FailureAware.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.scanner; 2 | 3 | /** 4 | * Used in our class scanner to show that this class knows that it is using imports that might not 5 | * be available at runtime and handles this gracefully. 6 | */ 7 | public @interface FailureAware { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/providers/ExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.providers; 2 | 3 | import lombok.NonNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public interface ExceptionHandler { 7 | 8 | void saveError(@Nullable Throwable throwable, @NonNull String... messages); 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/updater/UpdateDownloader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import lombok.NonNull; 6 | 7 | public interface UpdateDownloader { 8 | 9 | void download(@NonNull File target, @NonNull Version latest) throws IOException; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/event/Event.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.event; 2 | 3 | import lombok.NonNull; 4 | 5 | public interface Event { 6 | 7 | void canceled(boolean canceled); 8 | 9 | boolean canceled(); 10 | 11 | void cancelReason(@NonNull String cancelReason); 12 | 13 | String cancelReason(); 14 | } 15 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/ResultSetConsumer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import lombok.NonNull; 6 | 7 | public interface ResultSetConsumer { 8 | 9 | void consume(@NonNull ResultSet resultSet) throws SQLException; 10 | 11 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/src/main/java/dev/simplix/core/minecraft/api/providers/PluginManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.api.providers; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | import lombok.NonNull; 6 | 7 | public interface PluginManager { 8 | 9 | void enablePlugin(@NonNull final File jarFile); 10 | 11 | List enabledPlugins(); 12 | } 13 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/duration/AbstractDuration.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.duration; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @RequiredArgsConstructor(access = AccessLevel.PROTECTED) 7 | public abstract class AbstractDuration implements Duration { 8 | 9 | protected final long ms; 10 | } 11 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/src/main/java/dev/simplix/core/minecraft/modules/SimplixMinecraftModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.modules; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import dev.simplix.core.common.aop.ApplicationModule; 5 | 6 | @ApplicationModule("SimplixCore") 7 | public class SimplixMinecraftModule extends AbstractSimplixModule { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/BatchFiller.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.SQLException; 5 | import lombok.NonNull; 6 | 7 | public interface BatchFiller { 8 | 9 | void fill(@NonNull PreparedStatement preparedStatement, @NonNull T type) throws SQLException; 10 | } -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/PreparedStatementFiller.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.SQLException; 5 | import lombok.NonNull; 6 | 7 | public interface PreparedStatementFiller { 8 | 9 | void fill(@NonNull PreparedStatement preparedStatement) throws SQLException; 10 | } -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/PreparedStatementExecutor.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.SQLException; 5 | import lombok.NonNull; 6 | 7 | public interface PreparedStatementExecutor { 8 | 9 | T execute(@NonNull PreparedStatement preparedStatement) throws SQLException; 10 | 11 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/DependencyManifest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import lombok.Data; 4 | import lombok.NonNull; 5 | import lombok.experimental.Accessors; 6 | 7 | @Data 8 | @Accessors(fluent = true) 9 | @NonNull 10 | public class DependencyManifest { 11 | 12 | private Repository[] repositories; 13 | private Dependency[] dependencies; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/exceptions/SqlRuntimeException.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.exceptions; 2 | 3 | import java.sql.SQLException; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public class SqlRuntimeException extends RuntimeException { 7 | 8 | public SqlRuntimeException(@Nullable SQLException exception) { 9 | super(exception); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/Repository.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import lombok.Data; 4 | import lombok.NonNull; 5 | import lombok.ToString; 6 | import lombok.experimental.Accessors; 7 | 8 | @Data 9 | @ToString 10 | @Accessors(fluent = true) 11 | @NonNull 12 | public class Repository { 13 | 14 | private String id; 15 | private String url; 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-implementation/src/main/java/dev/simplix/core/minecraft/spigot/SpigotSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import dev.simplix.core.common.aop.ApplicationModule; 5 | 6 | @ApplicationModule("SimplixCore") 7 | public class SpigotSimplixModule extends AbstractSimplixModule { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/PreparedStatementTransformer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.PreparedStatement; 4 | import java.sql.SQLException; 5 | import lombok.NonNull; 6 | 7 | public interface PreparedStatementTransformer { 8 | 9 | T transform(@NonNull PreparedStatement preparedStatement, @NonNull K k) throws SQLException; 10 | 11 | } -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/PreparedStatementSupplier.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.SQLException; 6 | import lombok.NonNull; 7 | 8 | public interface PreparedStatementSupplier { 9 | 10 | PreparedStatement get(@NonNull Connection connection) throws SQLException; 11 | 12 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-implementation/src/main/java/dev/simplix/core/minecraft/velocity/VelocitySimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import dev.simplix.core.common.aop.ApplicationModule; 5 | 6 | @ApplicationModule("SimplixCore") 7 | public class VelocitySimplixModule extends AbstractSimplixModule { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/SuppressWarnings.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface SuppressWarnings { 11 | 12 | String[] value(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/updater/UpdatePolicy.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | import lombok.experimental.Accessors; 6 | 7 | @Data 8 | @Builder 9 | @Accessors(fluent = true) 10 | public class UpdatePolicy { 11 | 12 | private String versionPattern; 13 | private UpdateDownloader updateDownloader; 14 | private VersionFetcher versionFetcher; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-implementation/src/main/java/dev/simplix/core/minecraft/bungeecord/BungeeCordSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import dev.simplix.core.common.aop.ApplicationModule; 5 | 6 | @ApplicationModule("SimplixCore") 7 | public final class BungeeCordSimplixModule extends AbstractSimplixModule { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/updater/VersionFetcher.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import java.io.IOException; 5 | import lombok.NonNull; 6 | 7 | public interface VersionFetcher { 8 | 9 | Version fetchLatestVersion( 10 | @NonNull ApplicationInfo applicationInfo, 11 | @NonNull UpdatePolicy updatePolicy) 12 | throws IOException; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/handlers/HikariConnectionHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.handlers; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | public final class HikariConnectionHandler extends SqlConnectionHandler { 7 | 8 | @Override 9 | public Connection openConnection() throws SQLException { 10 | return getDataSource().getConnection(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/providers/Debugger.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.providers; 2 | 3 | import lombok.NonNull; 4 | 5 | public interface Debugger { 6 | 7 | boolean isDebugged(@NonNull String section); 8 | 9 | boolean isWarned(@NonNull String section); 10 | 11 | void debug(@NonNull String section, @NonNull String... messages); 12 | 13 | void warn(@NonNull String section, @NonNull String... messages); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/libloader/LibraryDescription.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import lombok.Data; 4 | import lombok.NonNull; 5 | import lombok.ToString; 6 | import lombok.experimental.Accessors; 7 | 8 | @Data 9 | @Accessors(fluent = true) 10 | @ToString 11 | @NonNull 12 | public class LibraryDescription { 13 | 14 | private String name; 15 | private String version; 16 | private String[] authors; 17 | private String mainClass; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | **Is your feature request related to a problem? Please describe.** 2 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 3 | 4 | **Describe the solution you'd like** 5 | A clear and concise description of what you want to happen. 6 | 7 | **Describe alternatives you've considered** 8 | A clear and concise description of any alternative solutions or features you've considered. 9 | 10 | **Additional context** 11 | Add any other context or screenshots about the feature request here. 12 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/resources/updatepolicy.json: -------------------------------------------------------------------------------- 1 | { 2 | "versionFetcherClass": "dev.simplix.core.common.updater.SpigotMcResourceVersionFetcher", 3 | "versionFetcher": { 4 | "resourceId": "84206" 5 | }, 6 | "downloaderClass": "dev.simplix.core.common.updater.UrlUpdateDownloader", 7 | "downloader": { 8 | "url": "https://ci.exceptionflug.de/job/SimplixCore/lastSuccessfulBuild/artifact/simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/target/SimplixCore-Spigot.jar" 9 | } 10 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/src/main/resources/updatepolicy.json: -------------------------------------------------------------------------------- 1 | { 2 | "versionFetcherClass": "dev.simplix.core.common.updater.SpigotMcResourceVersionFetcher", 3 | "versionFetcher": { 4 | "resourceId": "84206" 5 | }, 6 | "downloaderClass": "dev.simplix.core.common.updater.UrlUpdateDownloader", 7 | "downloader": { 8 | "url": "https://ci.exceptionflug.de/job/SimplixCore/lastSuccessfulBuild/artifact/simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/target/SimplixCore-BungeeCord.jar" 9 | } 10 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-dynamiccommands/src/main/java/dev/simplix/core/minecraft/velocity/dynamiccommands/CommandMeta.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.dynamiccommands; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface CommandMeta { 11 | 12 | String name(); 13 | 14 | String[] aliases() default {}; 15 | 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/event/EventsTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.event; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | class EventsTest { 7 | 8 | @Test 9 | void registeredEvents() { 10 | Assertions.assertTrue(Events.registeredEvents().contains(new TestEvent())); 11 | } 12 | 13 | @Test 14 | void call() { 15 | TestEvent call = Events.call(new TestEvent()); 16 | Assertions.assertFalse(call.canceled()); 17 | } 18 | 19 | private static class TestEvent extends AbstractEvent { 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | **Describe the bug** 2 | A clear and concise description of what the bug is. 3 | 4 | **To Reproduce** 5 | Steps to reproduce the behavior: 6 | 1. Go to '...' 7 | 2. Click on '....' 8 | 3. Scroll down to '....' 9 | 4. See error 10 | 11 | **Expected behavior** 12 | A clear and concise description of what you expected to happen. 13 | 14 | **Screenshots** 15 | If applicable, add screenshots to help explain your problem. 16 | 17 | **Desktop (please complete the following information):** 18 | - OS: [e.g. Windows/MacOS/Linux] 19 | - Version [e.g. 22] 20 | 21 | **Additional context** 22 | Add any other context about the problem here. 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/ComponentInterceptor.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import lombok.NonNull; 4 | 5 | /** 6 | * A component interceptor intercepts specific {@link Component}s of a given subtype after component 7 | * scanning. 8 | * 9 | * @param The type of the component 10 | */ 11 | public interface ComponentInterceptor { 12 | 13 | /** 14 | * Passes an instance of an intercepted component to this interceptor for further processing. 15 | * 16 | * @param obj An instance of component 17 | */ 18 | void intercept(@NonNull T obj); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/converter/Converter.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.converter; 2 | 3 | import lombok.NonNull; 4 | 5 | /** 6 | * A converter is used to convert one object to another. 7 | * 8 | * @param The source type of the object 9 | * @param The target type ot the object 10 | */ 11 | public interface Converter { 12 | 13 | /** 14 | * Converts a given source object to the target type. 15 | * 16 | * @param src The source object 17 | * @return The target object 18 | */ 19 | Target convert(@NonNull Source src); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/function/ResultSetTransformer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.function; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.sql.Timestamp; 6 | import lombok.NonNull; 7 | 8 | public interface ResultSetTransformer { 9 | 10 | T transform(@NonNull ResultSet resultSet) throws SQLException; 11 | 12 | static long ms(@NonNull ResultSet resultSet, @NonNull String name) throws SQLException { 13 | Timestamp timestamp = resultSet.getTimestamp(name); 14 | return timestamp == null ? 0 : timestamp.getTime(); 15 | } 16 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/Private.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import javax.inject.Qualifier; 8 | 9 | /** 10 | * This will set the privacy level of an injection client. A private client cannot be accessed from 11 | * other SimplixApplications. 12 | */ 13 | @Qualifier 14 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface Private { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/handler/ConnectionHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.handler; 2 | 3 | import dev.simplix.core.database.sql.SqlDatabaseConnection; 4 | import java.sql.Connection; 5 | import java.sql.SQLException; 6 | import lombok.NonNull; 7 | 8 | public interface ConnectionHandler { 9 | 10 | void init(@NonNull SqlDatabaseConnection sqlDatabaseConnection); 11 | 12 | void preConnect(); 13 | 14 | Connection openConnection() throws SQLException; 15 | 16 | void updateConnection(); 17 | 18 | Connection connection(); 19 | 20 | void finishConnection(@NonNull Connection connection); 21 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/DependencyLoader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import java.util.Optional; 4 | import lombok.NonNull; 5 | 6 | /** 7 | * The dependency loader is used to download dependencies from remote repositories. 8 | */ 9 | public interface DependencyLoader { 10 | 11 | /** 12 | * Download a dependency from the given repositories. 13 | * 14 | * @param dependency The dependency to download 15 | * @param repositories The repositories to search 16 | */ 17 | Optional load( 18 | @NonNull Dependency dependency, 19 | @NonNull Iterable repositories); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/src/main/java/dev/simplix/core/minecraft/api/events/QuitEvent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.api.events; 2 | 3 | import dev.simplix.core.common.event.AbstractEvent; 4 | import java.util.UUID; 5 | import lombok.AccessLevel; 6 | import lombok.Getter; 7 | import lombok.NonNull; 8 | import lombok.RequiredArgsConstructor; 9 | import lombok.experimental.Accessors; 10 | 11 | @Getter 12 | @Accessors(fluent = true) 13 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) 14 | public class QuitEvent extends AbstractEvent { 15 | 16 | public static QuitEvent create(@NonNull final UUID target) { 17 | return new QuitEvent(target); 18 | } 19 | 20 | private final UUID target; 21 | } 22 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/libloader/LibraryLoader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import java.io.File; 4 | import java.util.Set; 5 | import lombok.NonNull; 6 | 7 | public interface LibraryLoader { 8 | 9 | /** 10 | * Loads all .jar libraries in an given directory 11 | * 12 | * @param directory 13 | */ 14 | void loadLibraries(@NonNull File directory); 15 | 16 | void loadLibrary(@NonNull File file); 17 | 18 | void loadLibraryEncapsulated(@NonNull File file, @NonNull Class owner); 19 | 20 | /** 21 | * Returns which jar files have been loaded as library by the given application 22 | */ 23 | Set loadedLibraries(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: maven:3.3.9-jdk-8 2 | 3 | stages: 4 | - build 5 | - test 6 | - deploy 7 | 8 | variables: 9 | MAVEN_CLI_OPTS: "--batch-mode" 10 | MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" 11 | 12 | cache: 13 | key: maven-local-repository 14 | paths: 15 | - .m2/repository/ 16 | 17 | build: 18 | stage: build 19 | script: 20 | - mvn $MAVEN_CLI_OPTS package -U -Dmaven.test.skip=true 21 | artifacts: 22 | paths: 23 | - ./**/target/*.jar 24 | 25 | test: 26 | stage: test 27 | script: 28 | - mvn $MAVEN_CLI_OPTS test 29 | 30 | #deploy: 31 | # stage: deploy 32 | # script: 33 | # - mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true 34 | # only: 35 | # - master 36 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-velocity 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity-tests 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-quickstart/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-velocity 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity-quickstart 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/AlwaysConstruct.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Normally, {@link Component}s are lazy constructed. When there is no need for a specific component 10 | * to be injected, there will also be no instance of this component. A component annotated with 11 | * {@link AlwaysConstruct} will always be constructed during application installation. 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface AlwaysConstruct { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-dynamiccommands/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-velocity 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity-dynamiccommands 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-dynamiclisteners/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-velocity 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity-dynamiclisteners 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-implementation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-velocity 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity-implementation 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/permission/Permission.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.permission; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.NonNull; 6 | import lombok.RequiredArgsConstructor; 7 | import lombok.experimental.Accessors; 8 | 9 | @Data 10 | @Accessors(fluent = true, chain = true) 11 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) 12 | public class Permission { 13 | 14 | private final String permissionString; 15 | private final String[] description; 16 | 17 | public static Permission of( 18 | @NonNull final String permissionString, 19 | @NonNull final String... desc) { 20 | return new Permission(permissionString, desc); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/CommonSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common; 2 | 3 | import com.google.inject.Binder; 4 | import dev.simplix.core.common.aop.AbstractSimplixModule; 5 | import dev.simplix.core.common.aop.ApplicationModule; 6 | import dev.simplix.core.common.listener.Listener; 7 | import dev.simplix.core.common.listener.Listeners; 8 | import lombok.NonNull; 9 | 10 | @ApplicationModule("SimplixCore") 11 | public final class CommonSimplixModule extends AbstractSimplixModule { 12 | 13 | { 14 | registerComponentInterceptor(Listener.class, Listeners::register); 15 | } 16 | 17 | @Override 18 | public void configure(@NonNull Binder binder) { 19 | super.configure(binder); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/event/AbstractEvent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.event; 2 | 3 | import lombok.Getter; 4 | import lombok.NonNull; 5 | import lombok.experimental.Accessors; 6 | 7 | @Getter 8 | @Accessors(fluent = true, chain = false) 9 | public abstract class AbstractEvent implements Event { 10 | 11 | private boolean canceled; 12 | private String cancelReason = ""; 13 | 14 | protected AbstractEvent() { 15 | Events.add(this); 16 | } 17 | 18 | @Override 19 | public void canceled(boolean canceled) { 20 | this.canceled = canceled; 21 | } 22 | 23 | @Override 24 | public void cancelReason(@NonNull String cancelReason) { 25 | this.cancelReason = cancelReason; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/stub/StubServer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests.stub; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import org.bukkit.entity.Player; 6 | 7 | public class StubServer extends FakeServer { 8 | 9 | private final String name = "Mock-Server"; 10 | private final String version = "1.0.0-SNAPSHOT"; 11 | 12 | @Override 13 | public String getName() { 14 | return this.name; 15 | } 16 | 17 | @Override 18 | public String getVersion() { 19 | return this.version; 20 | } 21 | 22 | @Override 23 | public Collection getOnlinePlayers() { 24 | return new ArrayList<>(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/platform/PlatformDependent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.platform; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Marks a module or class to be platform dependent. SimplixCore will recognize this module during 10 | * installation but will only bind it if the specified platform matches with the platform running 11 | * on. 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.TYPE) 15 | public @interface PlatformDependent { 16 | 17 | /** 18 | * @return The platform this module should be applied on. 19 | */ 20 | Platform value(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/updater/SpigotMcResourceVersionFetcher.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import java.io.IOException; 5 | import lombok.NonNull; 6 | 7 | public final class SpigotMcResourceVersionFetcher implements VersionFetcher { 8 | 9 | private String resourceId; 10 | 11 | @Override 12 | public Version fetchLatestVersion( 13 | @NonNull ApplicationInfo applicationInfo, 14 | @NonNull UpdatePolicy updatePolicy) 15 | throws IOException { 16 | return new UrlVersionFetcher("https://api.spigotmc.org/legacy/update.php?resource=" 17 | + resourceId) 18 | .fetchLatestVersion(applicationInfo, updatePolicy); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/libloader/StandaloneClassLoaderFabricator.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import java.io.File; 4 | import java.net.MalformedURLException; 5 | import java.util.function.Function; 6 | import lombok.NonNull; 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | @Slf4j 10 | public final class StandaloneClassLoaderFabricator implements Function { 11 | 12 | @Override 13 | public ClassLoader apply(@NonNull File file) { 14 | try { 15 | return new LibraryClassLoader(file, file.toURI().toURL()); 16 | } catch (MalformedURLException malformedURLException) { 17 | log.error("[Simplix | LibLoader] Cannot fabricate ClassLoader", malformedURLException); 18 | } 19 | return null; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/i18n/InternationalizationTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.i18n; 2 | 3 | import java.io.File; 4 | import java.util.Locale; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class InternationalizationTest { 9 | 10 | @Test 11 | public void testResource() { 12 | LocalizationManager localizationManager = new SimpleLocalizationManagerFactory() 13 | .create(new File("src/test/resources/")); 14 | 15 | String localized = localizationManager.localized("test-string", Locale.GERMAN); 16 | Assertions.assertEquals("Ein Teststring", localized); 17 | 18 | localized = localizationManager.localized("test-string", Locale.ENGLISH); 19 | Assertions.assertEquals("A test string", localized); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/updater/Updater.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import lombok.NonNull; 5 | 6 | /** 7 | * The updater handles all update relevant tasks. Checking for updates, downloading and install them 8 | * during startup. 9 | */ 10 | public interface Updater { 11 | 12 | /** 13 | * This will install all previously downloaded updates 14 | */ 15 | void installCachedUpdates(); 16 | 17 | /** 18 | * This checks for available updates. 19 | * 20 | * @param applicationInfo The application to be checked for 21 | * @param updatePolicy The defined update policy of this application 22 | */ 23 | void checkForUpdates( 24 | @NonNull ApplicationInfo applicationInfo, 25 | @NonNull UpdatePolicy updatePolicy); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/ScanComponents.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import dev.simplix.core.common.inject.SimplixInstaller; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Only usable in combination with {@link SimplixApplication}. This tells the {@link 11 | * SimplixInstaller} the possible locations for components or modules. 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface ScanComponents { 16 | 17 | /** 18 | * @return An array containing the base packages for components or modules. The packages will be 19 | * scanned recursively. 20 | */ 21 | String[] value(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/src/test/java/dev/simplix/core/minecraft/bungeecord/tests/BungeeCordCommandTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.tests; 2 | 3 | import dev.simplix.core.minecraft.bungeecord.quickstart.SimplixCommand; 4 | import dev.simplix.core.minecraft.bungeecord.quickstart.SimplixQuickStart; 5 | import dev.simplix.core.minecraft.bungeecord.tests.stub.StubProxiedPlayer; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class BungeeCordCommandTest { 10 | 11 | @Test 12 | void test() { 13 | try { 14 | new SimplixCommand(SimplixQuickStart.SIMPLIX_DOWNLOAD_URL).execute( 15 | new StubProxiedPlayer(), 16 | new String[0]); 17 | } catch (Throwable throwable) { 18 | Assertions.fail(throwable); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/listener/Listener.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.listener; 2 | 3 | import dev.simplix.core.common.event.Event; 4 | import dev.simplix.core.common.event.Events; 5 | import lombok.NonNull; 6 | 7 | /** 8 | * Listener that can listen to an {@link Event}. An Listener can be registered using the {@link 9 | * Listeners#register(Listener)} method 10 | * 11 | * @param Event the listener should listen to. 12 | */ 13 | public interface Listener { 14 | 15 | /** 16 | * Class of the event we want to listen to. 17 | */ 18 | Class type(); 19 | 20 | /** 21 | * Will be executed once the event is called using {@link Events#call(Event)} method All event 22 | * handling is done in the implementations of this method 23 | */ 24 | void handleEvent(@NonNull T event); 25 | } 26 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/version/VersionTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.version; 2 | 3 | import dev.simplix.core.common.updater.Version; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | public class VersionTest { 8 | 9 | @Test 10 | public void testVersions() { 11 | Version v1_12_2 = Version.parse("1.12.2"); 12 | Assertions.assertEquals(1, v1_12_2.values().get(0)); 13 | Assertions.assertEquals(12, v1_12_2.values().get(1)); 14 | Assertions.assertEquals(2, v1_12_2.values().get(2)); 15 | 16 | Version v1_16 = Version.parse("1.16"); 17 | Assertions.assertEquals(1, v1_16.values().get(0)); 18 | Assertions.assertEquals(16, v1_16.values().get(1)); 19 | 20 | Assertions.assertTrue(v1_16.newerThen(v1_12_2)); 21 | Assertions.assertTrue(v1_12_2.olderThen(v1_16)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/deploader/ArtifactDependencyLoaderTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import org.junit.jupiter.api.AfterEach; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class ArtifactDependencyLoaderTest { 8 | 9 | private static ArtifactDependencyLoader artifactDependencyLoader; 10 | 11 | @BeforeEach 12 | void setUp() { 13 | artifactDependencyLoader = new ArtifactDependencyLoader(); 14 | } 15 | 16 | @AfterEach 17 | void tearDown() { 18 | artifactDependencyLoader = null; 19 | } 20 | 21 | @Test 22 | void load() { 23 | } 24 | 25 | @Test 26 | void createRemoteRepositories() { 27 | } 28 | 29 | @Test 30 | void newRepositorySystem() { 31 | } 32 | 33 | @Test 34 | void newSession() { 35 | } 36 | 37 | @Test 38 | void localRepository() { 39 | } 40 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-slf4j/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | 9 | net.md-5 10 | bungeecord-api 11 | 1.16-R0.4-SNAPSHOT 12 | 13 | 14 | 15 | 16 | dev.simplix.core 17 | simplixcore-minecraft-bungeecord 18 | 1.0.0-SNAPSHOT 19 | 20 | 21 | simplixcore-minecraft-bungeecord-slf4j 22 | 1.0.0-SNAPSHOT 23 | 24 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/RequireModules.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * Only usable in combination with {@link SimplixApplication}. This class makes it possible to 11 | * create module instances using specified {@link Supplier}. 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface RequireModules { 16 | 17 | /** 18 | * A supplier which will deliver initialized modules of subtype {@link AbstractSimplixModule}. The 19 | * supplier class needs to have an accessible default constructor. 20 | * 21 | * @return The supplier class 22 | */ 23 | Class> value(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /simplixcore-database/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | simplixcore-database 6 | 7 | dev.simplix.core 8 | 4.0.0 9 | 1.0.0-SNAPSHOT 10 | pom 11 | 12 | 13 | dev.simplix.core 14 | simplixcore 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | 19 | simplixcore-database-sql 20 | 21 | 22 | 23 | 24 | 25 | org.jetbrains 26 | annotations 27 | 20.1.0 28 | 29 | 30 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/src/main/java/dev/simplix/core/minecraft/api/events/JoinEvent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.api.events; 2 | 3 | import dev.simplix.core.common.event.AbstractEvent; 4 | import java.net.InetAddress; 5 | import java.util.UUID; 6 | import lombok.AccessLevel; 7 | import lombok.Getter; 8 | import lombok.NonNull; 9 | import lombok.RequiredArgsConstructor; 10 | import lombok.experimental.Accessors; 11 | 12 | @Getter 13 | @Accessors(fluent = true) 14 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) 15 | public final class JoinEvent extends AbstractEvent { 16 | 17 | private final UUID targetUUID; 18 | private final String name; 19 | private final InetAddress targetAddress; 20 | 21 | public static JoinEvent create( 22 | @NonNull final UUID targetUUID, 23 | @NonNull final String name, 24 | @NonNull final InetAddress targetInetAddress) { 25 | return new JoinEvent(targetUUID, name, targetInetAddress); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/DependencyLoadingException.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import lombok.Data; 4 | import lombok.NonNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | @Data 8 | public class DependencyLoadingException extends RuntimeException { 9 | 10 | private final Dependency dependency; 11 | 12 | public DependencyLoadingException(@NonNull Dependency dependency, @NonNull final String message) { 13 | super(message); 14 | this.dependency = dependency; 15 | } 16 | 17 | public DependencyLoadingException(@NonNull Dependency dependency, @Nullable Throwable cause) { 18 | super("Unable to load dependency " + dependency.toString(), cause); 19 | this.dependency = dependency; 20 | } 21 | 22 | public DependencyLoadingException(@NonNull Dependency dependency) { 23 | super("Unable to load dependency " + dependency.toString()); 24 | this.dependency = dependency; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/deploader/Dependency.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.deploader; 2 | 3 | import dev.simplix.core.common.platform.Platform; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.NonNull; 7 | import lombok.experimental.Accessors; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | @Data 11 | @EqualsAndHashCode 12 | @Accessors(fluent = true) 13 | @NonNull 14 | public class Dependency { 15 | 16 | private String applicationName; 17 | private Class applicationClass; 18 | 19 | private String groupId; 20 | private String artifactId; 21 | private String version; 22 | private String type = "library"; 23 | @Nullable 24 | private Platform platform; 25 | 26 | @Nullable 27 | public Platform platform() { 28 | return this.platform; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return this.groupId + ':' + this.artifactId + ':' + this.version; 34 | } 35 | } 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/ApplicationModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import com.google.inject.Module; 4 | import dev.simplix.core.common.inject.SimplixInstaller; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Marks a class for automatic {@link Module} detection during module scanning. The annotated module 12 | * needs to have an accessible default constructor. Otherwise please register the module using 13 | * {@link RequireModules} or using {@link SimplixInstaller#register(Class, Module...)} in your 14 | * application class. 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | public @interface ApplicationModule { 19 | 20 | /** 21 | * @return The application name of the {@link SimplixApplication} where this module belongs to. 22 | */ 23 | String value(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/src/main/java/dev/simplix/core/minecraft/api/events/ChatEvent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.api.events; 2 | 3 | import dev.simplix.core.common.event.AbstractEvent; 4 | import java.net.InetAddress; 5 | import java.util.UUID; 6 | import lombok.*; 7 | import lombok.experimental.Accessors; 8 | 9 | /** 10 | * Represents an event when a player is chatting. On Bukkit it will always be triggered 11 | * asynchronously. 12 | */ 13 | @Getter 14 | @Setter 15 | @Accessors(fluent = true) 16 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) 17 | public final class ChatEvent extends AbstractEvent { 18 | 19 | private final UUID targetUUID; 20 | private final InetAddress targetAddress; 21 | @NonNull 22 | private String message; 23 | 24 | public static ChatEvent create( 25 | @NonNull final UUID targetUUID, 26 | @NonNull final InetAddress targetAddress, 27 | @NonNull final String message) { 28 | return new ChatEvent(targetUUID, targetAddress, message); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-plugin/src/main/java/dev/simplix/core/minecraft/velocity/plugin/VelocityPluginManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.plugin; 2 | 3 | import com.velocitypowered.api.proxy.ProxyServer; 4 | import dev.simplix.core.common.aop.Component; 5 | import dev.simplix.core.minecraft.api.providers.PluginManager; 6 | import java.io.File; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import dev.simplix.core.minecraft.velocity.VelocitySimplixModule; 10 | import lombok.NonNull; 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | @Component(value = VelocitySimplixModule.class, parent = PluginManager.class) 14 | @Slf4j 15 | public final class VelocityPluginManager implements PluginManager { 16 | 17 | @Override 18 | public void enablePlugin(@NonNull File jarFile) { 19 | log.warn("[Simplix] Plugin management on velocity not supported"); 20 | } 21 | 22 | @Override 23 | public List enabledPlugins() { 24 | return new ArrayList<>(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/SpigotPluginLoadTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests; 2 | 3 | import be.seeseemelk.mockbukkit.MockBukkit; 4 | import dev.simplix.core.minecraft.spigot.plugin.SimplixPlugin; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class SpigotPluginLoadTest { 10 | 11 | private static SimplixPlugin plugin; 12 | 13 | @BeforeAll 14 | @Test 15 | static void setUp() { 16 | if (!MockBukkit.isMocked()) { 17 | MockBukkit.mock(); 18 | } 19 | plugin = MockBukkit.load(SimplixPlugin.class); 20 | } 21 | 22 | @Test 23 | void testEnabled() { 24 | Assertions.assertEquals( 25 | "dev.simplix.core.minecraft.spigot.plugin.SimplixPlugin", 26 | SimplixPlugin.class.getName(), 27 | "Plugin was invalidly relocated"); 28 | Assertions.assertTrue(plugin.isEnabled(), "Plugin must be enabled"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-dynamiclisteners/src/main/java/dev/simplix/core/minecraft/spigot/dynamiclisteners/DynamicListenersSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.dynamiclisteners; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.plugin.Plugin; 7 | 8 | public class DynamicListenersSimplixModule extends AbstractSimplixModule { 9 | 10 | private final Plugin plugin; 11 | 12 | public DynamicListenersSimplixModule(Plugin plugin) { 13 | if (plugin == null) { 14 | this.plugin = Bukkit 15 | .getPluginManager() 16 | .getPlugins()[0]; 17 | } else { 18 | this.plugin = plugin; 19 | } 20 | 21 | registerComponentInterceptor( 22 | Listener.class, 23 | listener -> Bukkit 24 | .getPluginManager() 25 | .registerEvents(listener, plugin)); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-implementation/src/main/java/dev/simplix/core/minecraft/bungeecord/plugin/BungeeCordPluginManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.plugin; 2 | 3 | import dev.simplix.core.common.aop.Component; 4 | import dev.simplix.core.minecraft.api.providers.PluginManager; 5 | import dev.simplix.core.minecraft.bungeecord.BungeeCordSimplixModule; 6 | import java.io.File; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import lombok.NonNull; 10 | import net.md_5.bungee.api.ProxyServer; 11 | 12 | @Component(value = BungeeCordSimplixModule.class, parent = PluginManager.class) 13 | public final class BungeeCordPluginManager implements PluginManager { 14 | 15 | @Override 16 | public void enablePlugin(@NonNull File jarFile) { 17 | final File parentFile = jarFile.getParentFile(); 18 | if (parentFile != null) { 19 | ProxyServer.getInstance().getPluginManager().detectPlugins(parentFile); 20 | } 21 | } 22 | 23 | @Override 24 | public List enabledPlugins() { 25 | return new ArrayList<>(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/ReplacerTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common; 2 | 3 | import java.util.Arrays; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.BeforeAll; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class ReplacerTest { 9 | 10 | private static Replacer replacer; 11 | 12 | @Test 13 | @BeforeAll 14 | static void setUp() { 15 | replacer = Replacer.of("I am a {replace-me}"); 16 | Assertions.assertEquals("I am a {replace-me}", replacer.messages().get(0)); 17 | } 18 | 19 | @Test 20 | void replacedMessage() { 21 | final String[] replacedMessage = replacer 22 | .replaceAll("replace-me", "Replacer") 23 | .replacedMessage(); 24 | Assertions.assertTrue(Arrays.equals(replacedMessage, new String[]{"I am a Replacer"})); 25 | } 26 | 27 | @Test 28 | void replacedMessageJoined() { 29 | String replacedMessageJoined = replacer 30 | .replaceAll("replace-me", "Replacer") 31 | .replacedMessageJoined(); 32 | Assertions.assertEquals("I am a Replacer", replacedMessageJoined); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Simplix Softworks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-dynamiccommands/src/main/java/dev/simplix/core/minecraft/bungeecord/dynamiccommands/DynamicCommandsSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.dynamiccommands; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import lombok.NonNull; 5 | import lombok.extern.slf4j.Slf4j; 6 | import net.md_5.bungee.api.ProxyServer; 7 | import net.md_5.bungee.api.plugin.Command; 8 | import net.md_5.bungee.api.plugin.Plugin; 9 | 10 | @Slf4j 11 | public class DynamicCommandsSimplixModule extends AbstractSimplixModule { 12 | 13 | private final Plugin plugin; 14 | 15 | public DynamicCommandsSimplixModule(@NonNull Plugin plugin) { 16 | this.plugin = plugin; 17 | registerComponentInterceptor( 18 | Command.class, 19 | command -> { 20 | log.info("[Simplix] Register command /" + command.getName()); 21 | ProxyServer 22 | .getInstance() 23 | .getPluginManager() 24 | .registerCommand(plugin, command); 25 | }); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/java/dev/simplix/core/minecraft/spigot/plugin/util/PluginDescriptionUtil.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.plugin.util; 2 | 3 | import java.io.File; 4 | import java.io.InputStream; 5 | import java.util.jar.JarEntry; 6 | import java.util.jar.JarFile; 7 | import java.util.logging.Level; 8 | import lombok.experimental.UtilityClass; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.plugin.PluginDescriptionFile; 11 | 12 | @UtilityClass 13 | public final class PluginDescriptionUtil { 14 | 15 | public PluginDescriptionFile loadPluginYml(File target) { 16 | try (JarFile jar = new JarFile(target)) { 17 | JarEntry pdf = jar.getJarEntry("plugin.yml"); 18 | 19 | try (InputStream in = jar.getInputStream(pdf)) { 20 | PluginDescriptionFile desc = new PluginDescriptionFile(in); 21 | return desc; 22 | } 23 | } catch (Exception exception) { 24 | Bukkit 25 | .getLogger() 26 | .log(Level.WARNING, "Could not load plugin from file " + target, exception); 27 | } 28 | return null; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-dynamiclisteners/src/main/java/dev/simplix/core/minecraft/bungeecord/dynamiclisteners/DynamicListenersSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.dynamiclisteners; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import java.util.ArrayList; 5 | import net.md_5.bungee.api.ProxyServer; 6 | import net.md_5.bungee.api.plugin.Listener; 7 | import net.md_5.bungee.api.plugin.Plugin; 8 | 9 | public class DynamicListenersSimplixModule extends AbstractSimplixModule { 10 | 11 | private final Plugin plugin; 12 | 13 | public DynamicListenersSimplixModule(Plugin plugin) { 14 | if (plugin == null) { 15 | this.plugin = new ArrayList<>(ProxyServer 16 | .getInstance() 17 | .getPluginManager() 18 | .getPlugins()).get(0); 19 | } else { 20 | this.plugin = plugin; 21 | } 22 | 23 | registerComponentInterceptor( 24 | Listener.class, 25 | listener -> ProxyServer 26 | .getInstance() 27 | .getPluginManager() 28 | .registerListener(plugin, listener)); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/events/ApplicationPreInstallEvent.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.events; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import dev.simplix.core.common.event.AbstractEvent; 5 | import lombok.NonNull; 6 | 7 | public final class ApplicationPreInstallEvent extends AbstractEvent { 8 | 9 | private Class applicationClass; 10 | private ApplicationInfo applicationInfo; 11 | 12 | public ApplicationPreInstallEvent( 13 | @NonNull ApplicationInfo applicationInfo, 14 | @NonNull Class applicationClass) { 15 | this.applicationInfo = applicationInfo; 16 | this.applicationClass = applicationClass; 17 | } 18 | 19 | public Class applicationClass() { 20 | return applicationClass; 21 | } 22 | 23 | public void applicationClass(@NonNull Class applicationClass) { 24 | this.applicationClass = applicationClass; 25 | } 26 | 27 | public ApplicationInfo applicationInfo() { 28 | return applicationInfo; 29 | } 30 | 31 | public void applicationInfo(@NonNull ApplicationInfo applicationInfo) { 32 | this.applicationInfo = applicationInfo; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /simplixcore-minecraft/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | simplixcore-minecraft 14 | 1.0.0-SNAPSHOT 15 | pom 16 | 17 | 18 | simplixcore-minecraft-spigot 19 | simplixcore-minecraft-api 20 | simplixcore-minecraft-bungeecord 21 | simplixcore-minecraft-velocity 22 | 23 | 24 | 25 | 26 | 27 | dev.simplix.core 28 | simplixcore-common-api 29 | 1.0.0-SNAPSHOT 30 | provided 31 | 32 | 33 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/SimplixApplication.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import dev.simplix.core.common.inject.SimplixInstaller; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * This marks a class as the main class of a SimplixCore compliant application. 11 | */ 12 | @Target(ElementType.TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface SimplixApplication { 15 | 16 | /** 17 | * @return The name of the application 18 | */ 19 | String name(); 20 | 21 | /** 22 | * @return The version of the application 23 | */ 24 | String version() default ""; 25 | 26 | /** 27 | * @return The authors of the application 28 | */ 29 | String[] authors(); 30 | 31 | /** 32 | * Tells the {@link SimplixInstaller} to install dependent applications before this application. 33 | * 34 | * @return The dependencies of the application 35 | */ 36 | String[] dependencies() default {}; 37 | 38 | /** 39 | * @return A path for the working directory 40 | */ 41 | String workingDirectory() default "."; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-dynamiccommands/src/main/java/dev/simplix/minecraft/spigot/dynamiccommands/DynamicCommandsSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.minecraft.spigot.dynamiccommands; 2 | 3 | import dev.simplix.core.common.aop.AbstractSimplixModule; 4 | import java.lang.reflect.Field; 5 | import lombok.NonNull; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.command.Command; 9 | import org.bukkit.command.CommandMap; 10 | 11 | @Slf4j 12 | public class DynamicCommandsSimplixModule extends AbstractSimplixModule { 13 | 14 | { 15 | registerComponentInterceptor( 16 | Command.class, 17 | this::registerCommand); 18 | } 19 | 20 | public void registerCommand(@NonNull final Command command) { 21 | try { 22 | final Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap"); 23 | commandMapField.setAccessible(true); 24 | 25 | final CommandMap commandMap = (CommandMap) commandMapField.get(Bukkit.getServer()); 26 | commandMap.register(command.getLabel(), command); 27 | } catch (final Throwable throwable) { 28 | log.error("Unable to register command " + command.getName(), throwable); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/updater/UrlUpdateDownloader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import java.io.BufferedInputStream; 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.net.URL; 9 | import java.net.URLConnection; 10 | import lombok.NonNull; 11 | 12 | public class UrlUpdateDownloader implements UpdateDownloader { 13 | 14 | private String url; 15 | 16 | @Override 17 | public void download(@NonNull File target, @NonNull Version latest) throws IOException { 18 | URL url = new URL(this.url.replace("{latest}", latest.toString())); 19 | target.getParentFile().mkdirs(); 20 | URLConnection urlConnection = url.openConnection(); 21 | try (BufferedInputStream bufferedInputStream = new BufferedInputStream(urlConnection.getInputStream())) { 22 | try (FileOutputStream fileOutputStream = new FileOutputStream(target)) { 23 | fileOutputStream.write(ByteStreams.toByteArray(bufferedInputStream)); 24 | fileOutputStream.flush(); 25 | } 26 | } catch (Exception exception) { 27 | try { 28 | target.delete(); 29 | } catch (Exception ignored) { 30 | } 31 | throw exception; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/SpigotCommandTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests; 2 | 3 | import be.seeseemelk.mockbukkit.MockBukkit; 4 | import dev.simplix.core.minecraft.spigot.plugin.SimplixPlugin; 5 | import dev.simplix.core.minecraft.spigot.quickstart.SimplixCommand; 6 | import dev.simplix.core.minecraft.spigot.quickstart.SimplixQuickStart; 7 | import dev.simplix.core.minecraft.spigot.tests.stub.StubPlayer; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class SpigotCommandTest { 13 | 14 | private static SimplixCommand SIMPLIX_COMMAND; 15 | 16 | @BeforeAll 17 | @Test 18 | static void setUp() { 19 | SIMPLIX_COMMAND = new SimplixCommand(SimplixQuickStart.SIMPLIX_DOWNLOAD_URL); 20 | if (!MockBukkit.isMocked()) { 21 | MockBukkit.mock(); 22 | } 23 | MockBukkit.load(SimplixPlugin.class); 24 | } 25 | 26 | @Test 27 | @BeforeEach 28 | void testNoArgs() { 29 | SIMPLIX_COMMAND.execute(new StubPlayer(), "simplix", new String[0]); 30 | } 31 | 32 | @Test 33 | void testInstallCommand() { 34 | SIMPLIX_COMMAND.execute(new StubPlayer(), "simplix", new String[]{"install"}); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/JdbcDataSourceCreator.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql; 2 | 3 | import com.mysql.cj.jdbc.MysqlDataSource; 4 | import java.util.Calendar; 5 | import javax.sql.DataSource; 6 | import lombok.NonNull; 7 | import lombok.experimental.UtilityClass; 8 | 9 | @UtilityClass 10 | public class JdbcDataSourceCreator { 11 | 12 | public final String OPTIONS = 13 | ( 14 | "?jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=utf8" 15 | + "&serverTimezone={timezone}&zeroDateTimeBehavior=convertToNull&autoReconnect=true" 16 | + "&zeroDateTimeBehavior=convertToNull&max_allowed_packet=512M") 17 | .replace("{timezone}", Calendar.getInstance().getTimeZone().getID()); 18 | 19 | public DataSource createSource(@NonNull String host, @NonNull String port, @NonNull String data) { 20 | return createSource(host, port, data, OPTIONS); 21 | } 22 | 23 | public DataSource createSource( 24 | @NonNull String host, 25 | @NonNull String port, 26 | @NonNull String data, 27 | @NonNull String options) { 28 | MysqlDataSource mysqlDataSource = new MysqlDataSource(); 29 | mysqlDataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + data + options); 30 | return mysqlDataSource; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/i18n/LocalizationManagerFactory.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.i18n; 2 | 3 | import java.io.File; 4 | import lombok.NonNull; 5 | 6 | /** 7 | * Used to create {@link LocalizationManager}s using language files 8 | */ 9 | public interface LocalizationManagerFactory { 10 | 11 | /** 12 | * Constructs a {@link LocalizationManager} based on a directory containing all translation 13 | * files. 14 | * 15 | * @param translationDirectory The directory where the language files are in 16 | * @return A new instance of {@link LocalizationManager} 17 | */ 18 | LocalizationManager create(@NonNull File translationDirectory); 19 | 20 | /** 21 | * Constructs a {@link LocalizationManager} based on a resource path containing all translation 22 | * files. 23 | * 24 | * @param translationResourcesDirectory The resource path the language files are in 25 | * @param refClass The class reference that is used to determine the source 26 | * file and the resource location 27 | * @return A new instance of {@link LocalizationManager} 28 | */ 29 | LocalizationManager create( 30 | @NonNull String translationResourcesDirectory, 31 | @NonNull Class refClass); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-dynamiclisteners/src/main/java/dev/simplix/core/minecraft/velocity/dynamiclisteners/DynamicListenersSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.dynamiclisteners; 2 | 3 | import com.velocitypowered.api.event.Subscribe; 4 | import com.velocitypowered.api.proxy.ProxyServer; 5 | import dev.simplix.core.common.aop.AbstractSimplixModule; 6 | import lombok.NonNull; 7 | import lombok.extern.slf4j.Slf4j; 8 | import java.lang.reflect.Method; 9 | 10 | @Slf4j 11 | public class DynamicListenersSimplixModule extends AbstractSimplixModule { 12 | 13 | public DynamicListenersSimplixModule(@NonNull ProxyServer proxyServer, @NonNull Object plugin) { 14 | registerComponentInterceptor(Object.class, obj -> { 15 | if (containsAnyListener(obj.getClass())) { 16 | proxyServer.getEventManager().register(plugin, obj); 17 | } else { 18 | log.debug("[Simplix] " 19 | + obj.getClass().getName() 20 | + " is bound to dynamic listeners module but is not containing any listener."); 21 | } 22 | }); 23 | } 24 | 25 | private boolean containsAnyListener(@NonNull Class c) { 26 | for (Method method : c.getMethods()) { 27 | if (method.isAnnotationPresent(Subscribe.class)) { 28 | return true; 29 | } 30 | } 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/updater/UrlVersionFetcher.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.updater; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import java.io.BufferedReader; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.net.URL; 8 | import lombok.AllArgsConstructor; 9 | import lombok.NoArgsConstructor; 10 | import lombok.NonNull; 11 | 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public final class UrlVersionFetcher implements VersionFetcher { 15 | 16 | private String url; 17 | 18 | @Override 19 | public Version fetchLatestVersion( 20 | @NonNull ApplicationInfo applicationInfo, 21 | @NonNull UpdatePolicy updatePolicy) 22 | throws IOException { 23 | URL url = new URL(this.url.replace("{name}", applicationInfo.name())); 24 | String latestVersion; 25 | try ( 26 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url 27 | .openConnection() 28 | .getInputStream()))) { 29 | latestVersion = bufferedReader.readLine(); 30 | } 31 | Version version; 32 | if (updatePolicy.versionPattern() != null) { 33 | version = Version.parse(updatePolicy.versionPattern(), latestVersion); 34 | } else { 35 | version = Version.parse(latestVersion); 36 | } 37 | return version; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/model/TableInformation.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.model; 2 | 3 | import dev.simplix.core.database.sql.ObjectResultSetTransformer; 4 | import dev.simplix.core.database.sql.function.ResultSetTransformer; 5 | import java.math.BigInteger; 6 | import java.sql.Timestamp; 7 | import lombok.*; 8 | 9 | @Data 10 | @Builder 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class TableInformation { 14 | 15 | @Getter 16 | public static ResultSetTransformer transformer = new ObjectResultSetTransformer<>( 17 | TableInformation.class); 18 | private String catalog; 19 | private String schema; 20 | private String name; 21 | private String type; 22 | private String engine; 23 | private BigInteger version; 24 | private String rowFormat; 25 | private BigInteger tableRows; 26 | private BigInteger avgRowLength; 27 | private BigInteger dataLength; 28 | private BigInteger maxDataLength; 29 | private BigInteger indexLength; 30 | private BigInteger dataFree; 31 | private BigInteger autoIncrement; 32 | private Timestamp createTime; 33 | private Timestamp updateTime; 34 | private Timestamp checkTime; 35 | private String collation; 36 | private String checkSum; 37 | private String createOptions; 38 | private String tableComment; 39 | } 40 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/ApplicationInfo.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common; 2 | 3 | import dev.simplix.core.common.aop.SimplixApplication; 4 | import dev.simplix.core.common.inject.SimplixInstaller; 5 | import java.io.File; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NonNull; 9 | import lombok.experimental.Accessors; 10 | 11 | /** 12 | * Objects of this type hold information about the {@link SimplixApplication} of this context. An 13 | * instance will be automatically created and bound by the {@link SimplixInstaller} during install. 14 | */ 15 | @NonNull 16 | @Accessors(fluent = true) 17 | @Builder 18 | @Data 19 | public final class ApplicationInfo { 20 | 21 | private final String name; 22 | @Builder.Default() 23 | private final String version; 24 | private final String[] authors; 25 | @Builder.Default() 26 | private File workingDirectory = new File("."); 27 | @Builder.Default() 28 | private String[] dependencies = new String[0]; 29 | 30 | public ApplicationInfo( 31 | @NonNull String name, 32 | @NonNull String version, 33 | @NonNull String[] authors, 34 | @NonNull File workingDirectory, 35 | @NonNull String[] dependencies) { 36 | this.name = name; 37 | this.version = version; 38 | this.authors = authors; 39 | this.workingDirectory = workingDirectory; 40 | this.dependencies = dependencies; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/model/FieldInformation.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.model; 2 | 3 | import dev.simplix.core.database.sql.ObjectResultSetTransformer; 4 | import dev.simplix.core.database.sql.function.ResultSetTransformer; 5 | import java.math.BigInteger; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.Getter; 10 | 11 | @Data 12 | @Builder 13 | @AllArgsConstructor 14 | public final class FieldInformation { 15 | 16 | @Getter 17 | public static ResultSetTransformer transformer = new ObjectResultSetTransformer<>( 18 | FieldInformation.class); 19 | private String catalog; 20 | private String schema; 21 | private String name; 22 | private String columnName; 23 | private BigInteger ordinalPosition; 24 | private Object defaultValue; 25 | private String nullAble; 26 | private String dataType; 27 | private BigInteger maxLength; 28 | private BigInteger octetLength; 29 | private BigInteger numericPrecision; 30 | private BigInteger numericScale; 31 | private BigInteger dateTimePrecision; 32 | private String characterSetName; 33 | private String collationName; 34 | private String columnType; 35 | private String columnKey; 36 | private String extra; 37 | private String privileges; 38 | private String columnComment; 39 | } 40 | -------------------------------------------------------------------------------- /simplixcore-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | simplixcore-common 6 | pom 7 | 8 | simplixcore-common-api 9 | simplixcore-common-implementation 10 | simplixcore-common-tests 11 | 12 | 13 | 4.0.0 14 | 15 | simplixcore 16 | dev.simplix.core 17 | 1.0.0-SNAPSHOT 18 | 19 | 1.0.0-SNAPSHOT 20 | 21 | 22 | 23 | 24 | com.google.inject 25 | guice 26 | 5.0.1 27 | 28 | 29 | com.google.inject.extensions 30 | guice-assistedinject 31 | 4.1.0 32 | 33 | 34 | org.reflections 35 | reflections 36 | 0.9.10 37 | 38 | 39 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-minecraft-bungeecord 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-minecraft-bungeecord-tests 13 | 14 | 15 | 16 | dev.simplix.core 17 | simplixcore-minecraft-bungeecord-plugin 18 | 1.0.${build.number} 19 | test 20 | 21 | 22 | dev.simplix.core 23 | simplixcore-minecraft-bungeecord-quickstart 24 | 1.0.0-SNAPSHOT 25 | test 26 | 27 | 28 | 29 | org.junit.jupiter 30 | junit-jupiter-engine 31 | 5.7.0 32 | test 33 | 34 | 35 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-plugin/src/main/java/dev/simplix/core/minecraft/velocity/plugin/libloader/PluginClassLoaderFabricator.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.plugin.libloader; 2 | 3 | import static org.reflections.Reflections.log; 4 | 5 | import java.io.File; 6 | import java.lang.reflect.Constructor; 7 | import java.lang.reflect.Field; 8 | import java.net.URL; 9 | import java.util.Set; 10 | import java.util.function.Function; 11 | 12 | public class PluginClassLoaderFabricator implements Function { 13 | 14 | @Override 15 | public ClassLoader apply(File file) { 16 | try { 17 | Class classLoaderClass = Class.forName("com.velocitypowered.proxy.plugin.PluginClassloader", 18 | false, ClassLoader.getSystemClassLoader()); 19 | Constructor constructor = classLoaderClass.getDeclaredConstructor(URL[].class); 20 | 21 | Object loader = constructor.newInstance((Object) new URL[]{file.toURI().toURL()}); 22 | 23 | Field loadersField = classLoaderClass.getDeclaredField("loaders"); 24 | loadersField.setAccessible(true); 25 | Set loaders = (Set) loadersField.get(null); 26 | loaders.add(loader); 27 | return (ClassLoader) loader; 28 | } catch (Exception exception) { 29 | log.error("[Simplix | LibLoader] Cannot fabricate PluginClassLoader", exception); 30 | } 31 | return null; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/listener/ListenersTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.listener; 2 | 3 | import dev.simplix.core.common.event.AbstractEvent; 4 | import dev.simplix.core.common.event.Events; 5 | import lombok.NonNull; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | 10 | class ListenersTest { 11 | 12 | private static final ExampleListener LISTENER = new ExampleListener(); 13 | 14 | @BeforeEach 15 | void setUp() { 16 | Listeners.register(LISTENER); 17 | } 18 | 19 | @Test 20 | void registeredListeners() { 21 | Assertions.assertTrue(Listeners.registeredListeners().contains(LISTENER)); 22 | } 23 | 24 | @Test 25 | void callEvent() { 26 | ExampleEvent call = Events.call(new ExampleEvent()); 27 | Assertions.assertTrue(call.canceled(), "Event has been canceled"); 28 | Assertions.assertEquals(call.cancelReason(), "Example cancel reason"); 29 | } 30 | 31 | static class ExampleEvent extends AbstractEvent { 32 | 33 | } 34 | 35 | static class ExampleListener implements Listener { 36 | 37 | @Override 38 | public Class type() { 39 | return ExampleEvent.class; 40 | } 41 | 42 | @Override 43 | public void handleEvent(@NonNull ExampleEvent event) { 44 | event.canceled(true); 45 | event.cancelReason("Example cancel reason"); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/Component.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import com.google.inject.Binder; 4 | import com.google.inject.Inject; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * A component is a class that will be automatically registered as a candidate for dependency 12 | * injection. Components can be used in class constructors annotated with {@link Inject}. Components 13 | * are singletons in their specific context which will only be constructed when there is a need for 14 | * them. 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | public @interface Component { 19 | 20 | /** 21 | * The owner of this component. Components need to be registered at a {@link 22 | * AbstractSimplixModule}. 23 | * 24 | * @return The module class 25 | */ 26 | Class value(); 27 | 28 | /** 29 | * The type that is being used to bind this component to a key during module configuration. If 30 | * nothing is specified, it will use the explicit type of this component. 31 | * 32 | * @return The type that is being used for binding 33 | * @see com.google.inject.Module#configure(Binder) 34 | */ 35 | Class parent() default Object.class; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-dynamiccommands/src/main/java/dev/simplix/core/minecraft/velocity/dynamiccommands/DynamicCommandsSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.dynamiccommands; 2 | 3 | import com.velocitypowered.api.command.Command; 4 | import com.velocitypowered.api.proxy.ProxyServer; 5 | import dev.simplix.core.common.aop.AbstractSimplixModule; 6 | import lombok.NonNull; 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | @Slf4j 10 | public class DynamicCommandsSimplixModule extends AbstractSimplixModule { 11 | 12 | public DynamicCommandsSimplixModule(@NonNull ProxyServer proxyServer) { 13 | registerComponentInterceptor(Command.class, obj -> { 14 | if (obj.getClass().isAnnotationPresent(CommandMeta.class)) { 15 | CommandMeta meta = obj.getClass().getAnnotation(CommandMeta.class); 16 | com.velocitypowered.api.command.CommandMeta commandMeta = proxyServer 17 | .getCommandManager() 18 | .metaBuilder(meta.name()) 19 | .aliases(meta.aliases()) 20 | .build(); 21 | proxyServer.getCommandManager().register(commandMeta, obj); 22 | log.info("[Simplix] Register command /" + meta.name()); 23 | } else { 24 | log.warn("[Simplix] Cannot register command " 25 | + obj.getClass().getName() 26 | + ": Please annotate your command class with @CommandMeta"); 27 | } 28 | }); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/listener/Listeners.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.listener; 2 | 3 | import dev.simplix.core.common.event.Event; 4 | import dev.simplix.core.common.event.Events; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.Collections; 8 | import java.util.List; 9 | import lombok.NonNull; 10 | import lombok.experimental.UtilityClass; 11 | 12 | /** 13 | * Central utility class for handling listeners 14 | *

15 | * They will be called in a class called Proxy/Spigot-ListenerImpl 16 | */ 17 | @UtilityClass 18 | public class Listeners { 19 | 20 | private final List> registeredListeners = new ArrayList<>(); 21 | 22 | /** 23 | * Registers an {@link Listener}. If an {@link Listener} is registered using this method it's 24 | * {@link Listener#handleEvent(Event)} method will be called once an {@link Event} is called using 25 | * {@link Events#call(Event)} method 26 | */ 27 | public void register(@NonNull final Listener listener) { 28 | registeredListeners.add(listener); 29 | } 30 | 31 | /** 32 | * Returns all registered {@link Listener}'s as an unmodifiable collection. It is made 33 | * unmodifiable since we don't want listeners to be removed from it 34 | */ 35 | public Collection> registeredListeners() { 36 | return Collections.unmodifiableCollection(registeredListeners); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/duration/Duration.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.duration; 2 | 3 | import lombok.NonNull; 4 | 5 | public interface Duration { 6 | 7 | /** 8 | * Compares the length of this and another specified duration. 9 | * 10 | * @param duration Duration to compare to 11 | */ 12 | boolean moreThan(@NonNull Duration duration); 13 | 14 | /** 15 | * Convenience method for the opposite of {@link #moreThan(Duration)} 16 | * 17 | * @param duration Duration to compare to 18 | */ 19 | boolean lessThan(@NonNull Duration duration); 20 | 21 | /** 22 | * Compares the length of this and another specified duration for equality 23 | * 24 | * @param duration Duration to compare to 25 | */ 26 | boolean sameAs(@NonNull Duration duration); 27 | 28 | /** 29 | * An Duration can also have no value. This is usually the case if the duration in milliseconds is 30 | * equal to {@link Long#MIN_VALUE} 31 | */ 32 | boolean isEmpty(); 33 | 34 | /** 35 | * A duration can be indefinite. If a Duration is indefinite it is called permanent. Usually this 36 | * happens when the duration in milliseconds is equal to -1 37 | */ 38 | boolean isPermanent(); 39 | 40 | /** 41 | * Returns an formatted time string 42 | */ 43 | @Override 44 | String toString(); 45 | 46 | /** 47 | * Returns the duration in milliseconds 48 | */ 49 | long toMs(); 50 | } 51 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/HikariDataSourceCreator.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql; 2 | 3 | import com.zaxxer.hikari.HikariConfig; 4 | import com.zaxxer.hikari.HikariDataSource; 5 | import javax.sql.DataSource; 6 | import lombok.NonNull; 7 | import lombok.experimental.UtilityClass; 8 | 9 | @UtilityClass 10 | public class HikariDataSourceCreator { 11 | 12 | public DataSource createSource( 13 | @NonNull String host, 14 | @NonNull String port, 15 | @NonNull String database, 16 | @NonNull String user, 17 | @NonNull String password) { 18 | HikariConfig config = new HikariConfig(); 19 | config.setDataSource(JdbcDataSourceCreator.createSource(host, port, database)); 20 | config.setUsername(user); 21 | config.setPassword(password); 22 | return new HikariDataSource(config); 23 | } 24 | 25 | public DataSource createSource( 26 | @NonNull String host, 27 | @NonNull String port, 28 | @NonNull String data, 29 | @NonNull String user, 30 | @NonNull String pass, 31 | int minimumIdle, 32 | int maxPoolSize) { 33 | HikariConfig hikariConfig = new HikariConfig(); 34 | hikariConfig.setDataSource(JdbcDataSourceCreator.createSource(host, port, data)); 35 | hikariConfig.setUsername(user); 36 | hikariConfig.setPassword(pass); 37 | hikariConfig.setMinimumIdle(minimumIdle); 38 | hikariConfig.setMaximumPoolSize(maxPoolSize); 39 | return new HikariDataSource(hikariConfig); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/ApplicationInfoTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common; 2 | 3 | import java.io.File; 4 | import java.util.Arrays; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.Test; 8 | 9 | class ApplicationInfoTest { 10 | 11 | private static final String NAME = "Name"; 12 | private static final String VERSION = "1.0.0-SNAPSHOT"; 13 | private static final String[] AUTHORS = new String[0]; 14 | private static final String[] DEPENDENCIES = new String[0]; 15 | private static final File WORKING_DIRECTORY = new File("."); 16 | private static ApplicationInfo applicationInfo; 17 | 18 | @BeforeAll 19 | static void setUp() { 20 | applicationInfo = new ApplicationInfo( 21 | NAME, 22 | VERSION, 23 | AUTHORS, 24 | WORKING_DIRECTORY, 25 | DEPENDENCIES); 26 | } 27 | 28 | @Test 29 | void name() { 30 | Assertions.assertEquals(applicationInfo.name(), NAME); 31 | } 32 | 33 | @Test 34 | void version() { 35 | Assertions.assertEquals(applicationInfo.version(), VERSION); 36 | } 37 | 38 | @Test 39 | void authors() { 40 | Assertions.assertTrue(Arrays.equals(applicationInfo.authors(), AUTHORS)); 41 | } 42 | 43 | @Test 44 | void workingDirectory() { 45 | Assertions.assertEquals(applicationInfo.workingDirectory(), WORKING_DIRECTORY); 46 | } 47 | 48 | @Test 49 | void dependencies() { 50 | Assertions.assertTrue(Arrays.equals(applicationInfo.dependencies(), DEPENDENCIES)); 51 | } 52 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-slf4j/src/main/java/dev/simplix/core/minecraft/bungeecord/slf4j/BungeeLoggerFactory.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.slf4j; 2 | 3 | import java.lang.reflect.Constructor; 4 | import lombok.NonNull; 5 | import net.md_5.bungee.api.ProxyServer; 6 | import org.slf4j.ILoggerFactory; 7 | import org.slf4j.Logger; 8 | import dev.simplix.slf4j.impl.JDK14LoggerAdapter; 9 | 10 | public final class BungeeLoggerFactory implements ILoggerFactory { 11 | 12 | private final JDK14LoggerAdapter bungeeLoggerAdapter; 13 | 14 | public BungeeLoggerFactory() { 15 | this.bungeeLoggerAdapter = createLoggerAdapter(ProxyServer.getInstance().getLogger()); 16 | ProxyServer 17 | .getInstance() 18 | .getLogger() 19 | .info("[Simplix] Slf4j logging configured for BungeeCord"); 20 | } 21 | 22 | private JDK14LoggerAdapter createLoggerAdapter(@NonNull java.util.logging.Logger logger) { 23 | try { 24 | Constructor constructor = JDK14LoggerAdapter.class.getDeclaredConstructor( 25 | java.util.logging.Logger.class); 26 | constructor.setAccessible(true); 27 | return constructor.newInstance(logger); 28 | } catch (ReflectiveOperationException e) { 29 | ProxyServer 30 | .getInstance() 31 | .getLogger() 32 | .severe("[Simplix] Slf4j BungeeCord JUL bridge not working!"); 33 | e.printStackTrace(); 34 | } 35 | return null; 36 | } 37 | 38 | @Override 39 | public Logger getLogger(@NonNull String string) { 40 | return this.bungeeLoggerAdapter; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/stub/StubPlayer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests.stub; 2 | 3 | import java.net.InetAddress; 4 | import java.net.InetSocketAddress; 5 | import java.net.UnknownHostException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.UUID; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import org.bukkit.Server; 12 | 13 | @Data 14 | @NoArgsConstructor 15 | public class StubPlayer extends FakePlayer { 16 | 17 | private final List lastMessages = new ArrayList<>(); 18 | 19 | private String name = "KotlinFactory"; 20 | private UUID uuid = UUID.randomUUID(); 21 | 22 | public StubPlayer(String name, UUID uuid) { 23 | this.name = name; 24 | this.uuid = uuid; 25 | } 26 | 27 | @Override 28 | public UUID getUniqueId() { 29 | return uuid; 30 | } 31 | 32 | @Override 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | @Override 38 | public InetSocketAddress getAddress() { 39 | try { 40 | return new InetSocketAddress(InetAddress.getLocalHost(), 3306); 41 | } catch (UnknownHostException unknownHostException) { 42 | unknownHostException.printStackTrace(); 43 | return null; 44 | } 45 | } 46 | 47 | @Override 48 | public Server getServer() { 49 | return new StubServer(); 50 | } 51 | 52 | @Override 53 | public boolean hasPermission(String name) { 54 | return true; //By pass command permissions 55 | } 56 | 57 | @Override 58 | public void sendMessage(String message) { 59 | lastMessages.add(message); 60 | super.sendMessage(message); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/handlers/SqlConnectionHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.handlers; 2 | 3 | import dev.simplix.core.database.sql.SqlDatabaseConnection; 4 | import dev.simplix.core.database.sql.handler.ConnectionHandler; 5 | import java.sql.Connection; 6 | import java.sql.SQLException; 7 | import javax.sql.DataSource; 8 | import lombok.Getter; 9 | import lombok.NonNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | @Getter 13 | public class SqlConnectionHandler implements ConnectionHandler { 14 | 15 | private SqlDatabaseConnection sqlDatabaseConnection; 16 | private DataSource dataSource; 17 | 18 | @Override 19 | public void init(@NonNull SqlDatabaseConnection mysqlConnection) { 20 | this.sqlDatabaseConnection = mysqlConnection; 21 | this.dataSource = mysqlConnection.getDataSource(); 22 | } 23 | 24 | @Override 25 | public void preConnect() { 26 | // Intentional blank 27 | } 28 | 29 | @Override 30 | public Connection openConnection() throws SQLException { 31 | return this.dataSource.getConnection( 32 | this.sqlDatabaseConnection.getUser(), 33 | this.sqlDatabaseConnection.getPass()); 34 | } 35 | 36 | @Override 37 | public void updateConnection() { 38 | // Intentional blank 39 | } 40 | 41 | @Override 42 | public Connection connection() { 43 | try { 44 | return openConnection(); 45 | } catch (SQLException sqlException) { 46 | throw new RuntimeException(sqlException); 47 | } 48 | } 49 | 50 | @Override 51 | public void finishConnection(@Nullable Connection connection) { 52 | SqlDatabaseConnection.close(connection); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/src/test/java/dev/simplix/core/minecraft/bungeecord/tests/stub/StubProxiedPlayer.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.tests.stub; 2 | 3 | import java.net.InetAddress; 4 | import java.net.InetSocketAddress; 5 | import java.net.UnknownHostException; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.UUID; 9 | import lombok.AllArgsConstructor; 10 | import lombok.NoArgsConstructor; 11 | import net.md_5.bungee.api.chat.BaseComponent; 12 | 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class StubProxiedPlayer extends FakeProxiedPlayer { 16 | 17 | private final List lastMessages = new ArrayList<>(); 18 | 19 | private String name = "KotlinFactory"; 20 | private UUID uuid = UUID.randomUUID(); 21 | 22 | @Override 23 | public UUID getUniqueId() { 24 | return uuid; 25 | } 26 | 27 | @Override 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | @Override 33 | public InetSocketAddress getAddress() { 34 | try { 35 | return new InetSocketAddress(InetAddress.getLocalHost(), 3306); 36 | } catch (UnknownHostException unknownHostException) { 37 | unknownHostException.printStackTrace(); 38 | return null; 39 | } 40 | } 41 | 42 | @Override 43 | public boolean hasPermission(String s) { 44 | return true; //By pass command permissions 45 | } 46 | 47 | @Override 48 | public void sendMessage(String s) { 49 | lastMessages.add(s); 50 | super.sendMessage(s); 51 | } 52 | 53 | @Override 54 | public void sendMessage(BaseComponent baseComponent) { 55 | lastMessages.add(baseComponent.toLegacyText()); 56 | super.sendMessage(baseComponent); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/event/Events.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.event; 2 | 3 | import dev.simplix.core.common.listener.Listener; 4 | import dev.simplix.core.common.listener.Listeners; 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import lombok.NonNull; 9 | import lombok.experimental.UtilityClass; 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | /** 13 | * Central utility class for handling events 14 | */ 15 | @UtilityClass 16 | @Slf4j 17 | public class Events { 18 | 19 | private final List knownEvents = new ArrayList<>(); 20 | 21 | void add(@NonNull Event event) { 22 | knownEvents.add(event); 23 | } 24 | 25 | public List registeredEvents() { 26 | return Collections.unmodifiableList(knownEvents); 27 | } 28 | 29 | /** 30 | * Calls an {@link Event} and the {@link Listener#handleEvent(Event)} method of all {@link 31 | * Listeners} registered using {@link Listeners#register(Listener)} that are listening for the 32 | * given {@link Event} 33 | * 34 | * @return Returns the event 35 | */ 36 | public T call(@NonNull T event) { 37 | for (final Listener listener : Listeners.registeredListeners()) { 38 | if (listener.type() != event.getClass()) { 39 | continue; 40 | } 41 | ((Listener) listener).handleEvent(event); 42 | log.info("Called listener " + listener.getClass().getName() + " and type: " + listener 43 | .type() 44 | .getSimpleName()); 45 | // Don't call further Listeners if the event was already canceled 46 | if (event.canceled()) { 47 | return event; 48 | } 49 | } 50 | 51 | return event; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/converter/ConvertersTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.converter; 2 | 3 | import lombok.Data; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.BeforeAll; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | class ConvertersTest { 10 | 11 | @BeforeAll 12 | static void setUp() { 13 | Converters.register(Car.class, AnotherCar.class, 14 | (Converter) src -> new AnotherCar(src.name, src.age)); 15 | } 16 | 17 | @Test 18 | @BeforeEach 19 | void testRegistered() { 20 | Assertions.assertNotNull( 21 | Converters.getConverter(Car.class, AnotherCar.class), 22 | "Converter must be registered"); 23 | } 24 | 25 | @Test 26 | void convert() { 27 | AnotherCar convert = Converters.convert(new Car("Example-Name", 1), AnotherCar.class); 28 | Assertions.assertEquals(convert.anotherName, "Example-Name"); 29 | Assertions.assertEquals(convert.anotherAge, 1); 30 | } 31 | 32 | @Test 33 | void getConverter() { 34 | Converter converter = Converters.getConverter( 35 | Car.class, 36 | AnotherCar.class); 37 | Assertions.assertNotNull(converter, "Converter must be registered"); 38 | AnotherCar convert = converter.convert(new Car("Example-Name", 1)); 39 | Assertions.assertEquals(convert.anotherName, "Example-Name"); 40 | Assertions.assertEquals(convert.anotherAge, 1); 41 | } 42 | 43 | @Data 44 | private static class Car { 45 | 46 | private final String name; 47 | private final int age; 48 | } 49 | 50 | @Data 51 | private static class AnotherCar { 52 | 53 | private final String anotherName; 54 | private final int anotherAge; 55 | } 56 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/src/main/java/dev/simplix/core/minecraft/bungeecord/plugin/util/PluginDescriptionUtil.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.plugin.util; 2 | 3 | import com.google.common.base.Preconditions; 4 | import java.io.File; 5 | import java.io.InputStream; 6 | import java.util.jar.JarEntry; 7 | import java.util.jar.JarFile; 8 | import java.util.logging.Level; 9 | import lombok.NonNull; 10 | import lombok.experimental.UtilityClass; 11 | import net.md_5.bungee.api.ProxyServer; 12 | import net.md_5.bungee.api.plugin.PluginDescription; 13 | import org.yaml.snakeyaml.Yaml; 14 | 15 | @UtilityClass 16 | public final class PluginDescriptionUtil { 17 | 18 | private final Yaml YAML = new Yaml(); 19 | 20 | public PluginDescription loadPluginYml(@NonNull File target) { 21 | try (JarFile jar = new JarFile(target)) { 22 | JarEntry pdf = jar.getJarEntry("bungee.yml"); 23 | if (pdf == null) { 24 | pdf = jar.getJarEntry("plugin.yml"); 25 | } 26 | 27 | Preconditions.checkNotNull(pdf, "Plugin must have a plugin.yml or bungee.yml"); 28 | 29 | try (InputStream inputStream = jar.getInputStream(pdf)) { 30 | PluginDescription desc = YAML.loadAs(inputStream, PluginDescription.class); 31 | Preconditions.checkNotNull(desc.getName(), "Plugin from %s has no name", target); 32 | Preconditions.checkNotNull(desc.getMain(), "Plugin from %s has no main", target); 33 | 34 | desc.setFile(target); 35 | return desc; 36 | } 37 | } catch (Exception exception) { 38 | ProxyServer 39 | .getInstance() 40 | .getLogger() 41 | .log(Level.WARNING, "Could not load plugin from file " + target, exception); 42 | } 43 | return null; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-implementation/src/main/java/dev/simplix/core/minecraft/spigot/plugin/SpigotPluginManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.plugin; 2 | 3 | import dev.simplix.core.common.aop.Component; 4 | import dev.simplix.core.minecraft.api.providers.PluginManager; 5 | import dev.simplix.core.minecraft.spigot.SpigotSimplixModule; 6 | import java.io.File; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | import lombok.NonNull; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.bukkit.Bukkit; 13 | import org.bukkit.plugin.InvalidDescriptionException; 14 | import org.bukkit.plugin.InvalidPluginException; 15 | import org.bukkit.plugin.Plugin; 16 | 17 | @Component(value = SpigotSimplixModule.class, parent = PluginManager.class) 18 | @Slf4j 19 | public final class SpigotPluginManager implements PluginManager { 20 | 21 | @Override 22 | public void enablePlugin(@NonNull File jarFile) { 23 | try { 24 | final org.bukkit.plugin.PluginManager handle = Bukkit.getPluginManager(); 25 | handle.enablePlugin(handle.loadPlugin(jarFile)); 26 | } catch (InvalidPluginException | InvalidDescriptionException exception) { 27 | log.error("Unable to enable plugin " + jarFile.getName(), exception); 28 | } 29 | } 30 | 31 | @Override 32 | public List enabledPlugins() { 33 | final org.bukkit.plugin.PluginManager handle = Bukkit.getPluginManager(); 34 | return Arrays 35 | .stream(handle.getPlugins()) 36 | .map(Plugin::getName) 37 | .collect(Collectors.toList()); 38 | } 39 | 40 | public static void main(String[] args) { 41 | final SpigotPluginManager spigotPluginManager = new SpigotPluginManager(); 42 | spigotPluginManager.enabledPlugins(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-velocity 15 | 1.0.0-SNAPSHOT 16 | pom 17 | 18 | 19 | simplixcore-minecraft-velocity-plugin 20 | simplixcore-minecraft-velocity-implementation 21 | simplixcore-minecraft-velocity-tests 22 | simplixcore-minecraft-velocity-dynamiclisteners 23 | simplixcore-minecraft-velocity-dynamiccommands 24 | simplixcore-minecraft-velocity-quickstart 25 | 26 | 27 | 28 | 29 | velocity 30 | https://nexus.velocitypowered.com/repository/maven-public/ 31 | 32 | 33 | 34 | 35 | 36 | com.velocitypowered 37 | velocity-proxy 38 | 1.1.3-SNAPSHOT 39 | provided 40 | 41 | 42 | com.velocitypowered 43 | velocity-api 44 | 1.1.3-SNAPSHOT 45 | provided 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/durations/SimpleDurationTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.durations; 2 | 3 | import dev.simplix.core.common.duration.Duration; 4 | import dev.simplix.core.common.duration.Durations; 5 | import java.util.concurrent.TimeUnit; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class SimpleDurationTest { 10 | 11 | @Test 12 | public void moreThan() { 13 | Assertions.assertTrue( 14 | Durations 15 | .of(11L, TimeUnit.MINUTES) 16 | .moreThan(Durations.of(10L, TimeUnit.MINUTES))); 17 | } 18 | 19 | @Test 20 | public void lessThan() { 21 | Assertions.assertTrue( 22 | Durations 23 | .of(10L, TimeUnit.MINUTES) 24 | .lessThan(Durations.of(11L, TimeUnit.MINUTES))); 25 | } 26 | 27 | @Test 28 | public void isEmpty() { 29 | Assertions.assertTrue(Durations.empty().isEmpty()); 30 | Assertions.assertTrue(Durations.of(Long.MIN_VALUE).isEmpty()); 31 | } 32 | 33 | @Test 34 | public void isPermanent() { 35 | Assertions.assertTrue(Durations.permanent().isPermanent()); 36 | Assertions.assertTrue(Durations.of(-1).isPermanent()); 37 | Assertions.assertTrue(Durations.of(-1, TimeUnit.DAYS).isPermanent()); 38 | } 39 | 40 | @Test 41 | public void testToString() { 42 | // Permanent-case 43 | Assertions.assertEquals("Permanent", Durations.permanent().toString()); 44 | // Empty 45 | Assertions.assertEquals("Empty", Durations.empty().toString()); 46 | 47 | // Other 48 | // Assertions.assertEquals("864000000", Durations.of("10 days").toString()); 49 | } 50 | 51 | @Test 52 | public void toMs() { 53 | final Duration testDuration = Durations.of(10L, TimeUnit.MILLISECONDS); 54 | Assertions.assertEquals(testDuration.toMs(), 10); 55 | } 56 | } -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/src/test/java/dev/simplix/core/minecraft/bungeecord/tests/BungeeCordListenerImplTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.tests; 2 | 3 | import dev.simplix.core.minecraft.bungeecord.plugin.BungeeCordListenerImpl; 4 | import dev.simplix.core.minecraft.bungeecord.tests.stub.StubProxiedPlayer; 5 | import net.md_5.bungee.api.event.ChatEvent; 6 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 7 | import net.md_5.bungee.api.event.PostLoginEvent; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.BeforeAll; 10 | import org.junit.jupiter.api.Test; 11 | 12 | class BungeeCordListenerImplTest { 13 | 14 | private static BungeeCordListenerImpl bungeeCordListenerImpl; 15 | 16 | @BeforeAll 17 | static void setUp() { 18 | bungeeCordListenerImpl = BungeeCordListenerImpl.create(); 19 | Assertions.assertEquals( 20 | "dev.simplix.core.minecraft.bungeecord.plugin.ProxyListenerImpl", 21 | bungeeCordListenerImpl.getClass().getName()); 22 | } 23 | 24 | @Test 25 | void login() { 26 | try { 27 | bungeeCordListenerImpl.login(new PostLoginEvent(new StubProxiedPlayer())); 28 | } catch (Throwable throwable) { 29 | Assertions.fail(throwable); 30 | } 31 | } 32 | 33 | @Test 34 | void chat() { 35 | try { 36 | bungeeCordListenerImpl.chat(new ChatEvent( 37 | new StubProxiedPlayer(), 38 | new StubProxiedPlayer(), 39 | "Example message")); 40 | } catch (Throwable throwable) { 41 | Assertions.fail(throwable); 42 | } 43 | } 44 | 45 | @Test 46 | void quit() { 47 | try { 48 | bungeeCordListenerImpl.quit(new PlayerDisconnectEvent(new StubProxiedPlayer())); 49 | } catch (Throwable throwable) { 50 | Assertions.fail(throwable); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/duration/Durations.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.duration; 2 | 3 | import dev.simplix.core.common.TimeFormatUtil; 4 | import dev.simplix.core.common.durations.SimpleDuration; 5 | import java.sql.Timestamp; 6 | import java.util.concurrent.TimeUnit; 7 | import lombok.NonNull; 8 | import lombok.experimental.UtilityClass; 9 | 10 | /** 11 | * Central utility class to manage durations 12 | */ 13 | @UtilityClass 14 | public class Durations { 15 | 16 | /** 17 | * @return Returns an empty punish-duration. Normally indicates that the String that should be 18 | * parsed had the wrong format. 19 | */ 20 | public Duration empty() { 21 | return new SimpleDuration(Long.MIN_VALUE); 22 | } 23 | 24 | public Duration of(@NonNull Timestamp timestamp) { 25 | return of(timestamp.getTime()); 26 | } 27 | 28 | public Duration of(@NonNull String humanReadableTime) { 29 | if (humanReadableTime.equalsIgnoreCase("-1")) { 30 | return permanent(); 31 | } 32 | 33 | // Converting to seconds 34 | long milliseconds = TimeFormatUtil.parseToMilliseconds(humanReadableTime); 35 | 36 | //Invalid format 37 | if (milliseconds == Long.MIN_VALUE) { 38 | return empty(); 39 | } 40 | return new SimpleDuration(milliseconds); 41 | } 42 | 43 | public Duration of(long timeInMs) { 44 | if (timeInMs == -1) { 45 | return permanent(); 46 | } 47 | if (timeInMs == Long.MIN_VALUE) { 48 | return empty(); 49 | } 50 | return new SimpleDuration(timeInMs); 51 | } 52 | 53 | public Duration of(final long time, @NonNull TimeUnit unit) { 54 | if (time == -1) { 55 | return permanent(); 56 | } 57 | 58 | if (time == Long.MIN_VALUE) { 59 | return empty(); 60 | } 61 | return new SimpleDuration(unit.toMillis(time)); 62 | } 63 | 64 | public Duration permanent() { 65 | return new SimpleDuration(-1); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/durations/SimpleDuration.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.durations; 2 | 3 | import dev.simplix.core.common.duration.AbstractDuration; 4 | import dev.simplix.core.common.duration.Duration; 5 | import lombok.NonNull; 6 | 7 | public final class SimpleDuration extends AbstractDuration { 8 | 9 | public SimpleDuration(long ms) { 10 | super(ms); 11 | } 12 | 13 | // ---------------------------------------------------------------------------------------------------- 14 | // Convenience methods here 15 | // ---------------------------------------------------------------------------------------------------- 16 | 17 | @Override 18 | public boolean moreThan(@NonNull Duration duration) { 19 | if (isPermanent()) { 20 | return true; 21 | } 22 | 23 | if (duration.isPermanent()) { 24 | return false; 25 | } 26 | 27 | return toMs() > duration.toMs(); 28 | } 29 | 30 | @Override 31 | public boolean lessThan(@NonNull Duration duration) { 32 | return !moreThan(duration); 33 | } 34 | 35 | @Override 36 | public boolean sameAs(@NonNull Duration duration) { 37 | if (isPermanent() && duration.isPermanent()) { 38 | return true; 39 | } 40 | 41 | if (isEmpty() && duration.isEmpty()) { 42 | return true; 43 | } 44 | 45 | return toMs() == duration.toMs(); 46 | } 47 | 48 | @Override 49 | public boolean isEmpty() { 50 | return toMs() == Long.MIN_VALUE; 51 | } 52 | 53 | @Override 54 | public boolean isPermanent() { 55 | return this.ms == -1L || this.ms == 0; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | if (isPermanent()) { 61 | return "Permanent"; 62 | } 63 | if (isEmpty()) { 64 | return "Empty"; 65 | } 66 | return Long.toString(toMs()); 67 | } 68 | 69 | @Override 70 | public long toMs() { 71 | return this.ms; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/libloader/LibraryTypeHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import com.google.common.io.Files; 4 | import dev.simplix.core.common.deploader.Dependency; 5 | import dev.simplix.core.common.deploader.DependencyTypeHandler; 6 | import dev.simplix.core.common.inject.SimplixInstaller; 7 | import dev.simplix.core.common.utils.FileUtils; 8 | import java.io.File; 9 | import lombok.NonNull; 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | @Slf4j 13 | public class LibraryTypeHandler implements DependencyTypeHandler { 14 | 15 | @Override 16 | public void handle(Dependency dependency, File file) { 17 | File target = FileUtils.context(new File("libraries")) 18 | .subFile(dependency.applicationName()) 19 | .subFile(file.getName()) 20 | .makeParentDirectories() 21 | .file(); 22 | try { 23 | Files.copy(file, target); 24 | SimplixInstaller 25 | .instance() 26 | .libraryLoader() 27 | .loadLibraryEncapsulated(target, dependency.applicationClass()); 28 | } catch (Exception e) { 29 | log.error("[SimplixCore | DependencyLoader] Cannot install " + dependency + " as library!"); 30 | } 31 | } 32 | 33 | @Override 34 | public boolean shouldInstall(@NonNull Dependency dependency) { 35 | return !FileUtils.context(new File("libraries")) 36 | .whenNotExists(fileContext -> fileContext.file().mkdirs()) 37 | .subFile(dependency.applicationName()) 38 | .whenNotExists(fileContext -> fileContext.file().mkdirs()) 39 | .subFiles(fc -> fc.whenFile(fileContext -> { 40 | File file = fileContext.file(); 41 | if (file.getName().startsWith(dependency.artifactId() + "-") 42 | && !file.getName().equals(dependency.artifactId() + "-" + dependency.version())) { 43 | file.delete(); 44 | } 45 | })) 46 | .subFile(dependency.artifactId() + "-" + dependency.version()) 47 | .file().exists(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/permission/PermissionsTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.permission; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.IntStream; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | 10 | class PermissionsTest { 11 | 12 | private static Permission EXAMPLE; 13 | 14 | @BeforeEach 15 | void setUp() { 16 | EXAMPLE = Permission.of("Example.Permission"); 17 | } 18 | 19 | @Test 20 | void register() { 21 | Permissions.register(EXAMPLE); 22 | Assertions.assertTrue(Permissions.registeredPermissions().contains(EXAMPLE)); 23 | } 24 | 25 | @Test 26 | void registerAll() { 27 | final List permissionList = new ArrayList<>(); 28 | 29 | // Generating permissions 30 | IntStream 31 | .range(0, 10) 32 | .forEach(integer -> permissionList.add(Permission.of("Example.AddAll." + integer))); 33 | 34 | Permissions.registerAll(permissionList); 35 | 36 | permissionList.forEach(permission -> Assertions.assertTrue(Permissions 37 | .registeredPermissions() 38 | .contains(permission))); 39 | } 40 | 41 | @Test 42 | void addFromClass() { 43 | Permissions.addFromClass(ClassWithPermissions.class); 44 | Assertions.assertTrue( 45 | Permissions 46 | .registeredPermissions() 47 | .contains(ClassWithPermissions.EXAMPLE_PERMISSION_1), 48 | "Example Permission 1 must be contained"); 49 | Assertions.assertTrue( 50 | Permissions 51 | .registeredPermissions() 52 | .contains(ClassWithPermissions.EXAMPLE_PERMISSION_2), 53 | "Example Permission 1 must be contained"); 54 | } 55 | 56 | static class ClassWithPermissions { 57 | 58 | private static final Permission EXAMPLE_PERMISSION_1 = Permission 59 | .of("Example.Permission.1"); 60 | 61 | private static final Permission EXAMPLE_PERMISSION_2 = Permission 62 | .of("Example.Permission.2"); 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/libloader/LibraryClassLoader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import dev.simplix.core.common.aop.SimplixApplication; 4 | import java.io.File; 5 | import java.net.URL; 6 | import java.net.URLClassLoader; 7 | import java.util.Set; 8 | import java.util.concurrent.CopyOnWriteArraySet; 9 | import lombok.Getter; 10 | import lombok.NonNull; 11 | import lombok.experimental.Accessors; 12 | 13 | @Accessors(fluent = true) 14 | public final class LibraryClassLoader extends URLClassLoader { 15 | 16 | private final static Set LOADERS = new CopyOnWriteArraySet<>(); 17 | 18 | static { 19 | ClassLoader.registerAsParallelCapable(); 20 | } 21 | 22 | @Getter 23 | private final File file; 24 | 25 | public LibraryClassLoader(@NonNull File file, @NonNull URL... urls) { 26 | super(urls, SimplixApplication.class.getClassLoader()); 27 | LOADERS.add(this); 28 | this.file = file; 29 | } 30 | 31 | public static Set loaders() { 32 | return LOADERS; 33 | } 34 | 35 | @Override 36 | protected Class loadClass( 37 | @NonNull String name, 38 | boolean resolve) throws ClassNotFoundException { 39 | return loadClass(name, resolve, true); 40 | } 41 | 42 | private Class loadClass( 43 | @NonNull String name, 44 | boolean resolve, 45 | boolean checkOther) 46 | throws ClassNotFoundException { 47 | ClassNotFoundException exception; 48 | try { 49 | return super.loadClass(name, resolve); 50 | } catch (ClassNotFoundException classNotFoundException) { 51 | exception = classNotFoundException; 52 | } 53 | if (!checkOther) { 54 | throw exception; 55 | } 56 | 57 | for (LibraryClassLoader loader : LOADERS) { 58 | if (loader == this) { 59 | continue; 60 | } 61 | try { 62 | return loader.loadClass(name, resolve, false); 63 | // Expected 64 | } catch (ClassNotFoundException ignored) { 65 | } 66 | } 67 | throw exception; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/SpigotListenerImplTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests; 2 | 3 | import com.google.common.collect.Sets; 4 | import dev.simplix.core.minecraft.spigot.plugin.SpigotListenerImpl; 5 | import dev.simplix.core.minecraft.spigot.tests.stub.StubPlayer; 6 | import java.net.InetAddress; 7 | import java.net.UnknownHostException; 8 | import java.util.UUID; 9 | import org.bukkit.event.player.AsyncPlayerChatEvent; 10 | import org.bukkit.event.player.AsyncPlayerPreLoginEvent; 11 | import org.bukkit.event.player.PlayerCommandPreprocessEvent; 12 | import org.bukkit.event.player.PlayerQuitEvent; 13 | import org.junit.jupiter.api.Assertions; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | 17 | class SpigotListenerImplTest { 18 | 19 | private static SpigotListenerImpl spigotListener; 20 | 21 | @BeforeAll 22 | static void setUp() { 23 | spigotListener = new SpigotListenerImpl(); 24 | Assertions.assertEquals( 25 | "dev.simplix.core.minecraft.spigot.plugin.SpigotListenerImpl", 26 | spigotListener.getClass().getName()); 27 | } 28 | 29 | @Test 30 | void login() throws UnknownHostException { 31 | spigotListener.login(new AsyncPlayerPreLoginEvent( 32 | "KotlinFactory", 33 | InetAddress.getLocalHost(), 34 | UUID.randomUUID())); 35 | } 36 | 37 | @Test 38 | void chat() { 39 | spigotListener.chat(new AsyncPlayerChatEvent( 40 | false, 41 | new StubPlayer(), 42 | "Example message", 43 | Sets.newHashSet())); 44 | } 45 | 46 | @Test 47 | void chat2() { 48 | spigotListener.chat2(new PlayerCommandPreprocessEvent( 49 | new StubPlayer(), 50 | "/example", 51 | // Recipients must be given or the test will fail due to the MockPlayer#getServer returning null 52 | Sets.newHashSet())); 53 | 54 | } 55 | 56 | @Test 57 | void quit() { 58 | spigotListener.quit(new PlayerQuitEvent(new StubPlayer(), "Quitted")); 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-spigot 15 | 1.0.0-SNAPSHOT 16 | pom 17 | 18 | 19 | simplixcore-minecraft-spigot-dynamiclisteners 20 | simplixcore-minecraft-spigot-dynamiccommands 21 | simplixcore-minecraft-spigot-implementation 22 | simplixcore-minecraft-spigot-tests 23 | simplixcore-minecraft-spigot-plugin 24 | simplixcore-minecraft-spigot-quickstart 25 | 26 | 27 | 28 | 29 | spigot-repo 30 | https://hub.spigotmc.org/nexus/content/repositories/snapshots 31 | 32 | 33 | minecraft-repo 34 | https://libraries.minecraft.net/ 35 | 36 | 37 | 38 | 39 | 40 | dev.simplix.core 41 | simplixcore-minecraft-api 42 | 1.0.0-SNAPSHOT 43 | 44 | 45 | org.spigotmc 46 | spigot-api 47 | 1.16.2-R0.1-SNAPSHOT 48 | provided 49 | 50 | 51 | com.mojang 52 | authlib 53 | 1.5.21 54 | provided 55 | 56 | 57 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-minecraft 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-minecraft-bungeecord 13 | pom 14 | 15 | simplixcore-minecraft-bungeecord-slf4j 16 | simplixcore-minecraft-bungeecord-plugin 17 | simplixcore-minecraft-bungeecord-implementation 18 | simplixcore-minecraft-bungeecord-tests 19 | simplixcore-minecraft-bungeecord-dynamiclisteners 20 | simplixcore-minecraft-bungeecord-dynamiccommands 21 | simplixcore-minecraft-bungeecord-quickstart 22 | 23 | 24 | 25 | 26 | bungeecord-repo 27 | https://oss.sonatype.org/content/repositories/snapshots 28 | 29 | 30 | exceptionflug 31 | https://mvn.exceptionflug.de/repository/exceptionflug-public/ 32 | 33 | 34 | simplixsoft-public 35 | https://repo.simplix.dev/repository/simplixsoft-public/ 36 | 37 | 38 | 39 | 40 | 41 | 42 | dev.simplix.core 43 | simplixcore-minecraft-api 44 | 1.0.0-SNAPSHOT 45 | provided 46 | 47 | 48 | dev.simplix 49 | bungee 50 | 1.0.0 51 | provided 52 | 53 | 54 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-quickstart/src/main/java/dev/simplix/core/minecraft/bungeecord/quickstart/SimplixQuickStart.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.quickstart; 2 | 3 | import lombok.NonNull; 4 | import net.md_5.bungee.api.ProxyServer; 5 | import net.md_5.bungee.api.plugin.Plugin; 6 | 7 | /** 8 | * This class is used to quickly populate non-simplix environments with a fresh copy of 9 | * SimplixCore. 10 | */ 11 | public final class SimplixQuickStart { 12 | 13 | public static final String SIMPLIX_DOWNLOAD_URL 14 | = "https://ci.exceptionflug.de/job/SimplixCore/lastSuccessfulBuild/artifact/simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/target/SimplixCore-BungeeCord.jar"; 15 | 16 | /** 17 | * Ensures that SimplixCore is installed on this server. 18 | * 19 | * @param plugin The plugin main class of the caller plugin 20 | * @return true if SimplixCore is installed or false otherwise 21 | */ 22 | public static boolean ensureSimplixCore(@NonNull Plugin plugin) { 23 | if (ProxyServer.getInstance().getPluginManager().getPlugin("SimplixCore") == null) { 24 | registerInstaller(plugin); 25 | return false; 26 | } 27 | return true; 28 | } 29 | 30 | private static void registerInstaller(Plugin plugin) { 31 | log("[" 32 | + plugin.getDescription().getName() 33 | + "] This plugin needs the SimplixCore in order to work " 34 | + "properly."); 35 | log("[" 36 | + plugin.getDescription().getName() 37 | + "] If you wish to automatically install SimplixCore " 38 | + "type the following command: simplix install"); 39 | log("[" 40 | + plugin.getDescription().getName() 41 | + "] " 42 | + plugin.getDescription().getName() 43 | + " will now halt."); 44 | ProxyServer 45 | .getInstance() 46 | .getPluginManager() 47 | .registerCommand(plugin, new SimplixCommand(SIMPLIX_DOWNLOAD_URL)); 48 | } 49 | 50 | private static void log(@NonNull String message) { 51 | ProxyServer.getInstance().getLogger().severe(message); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-common 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-common-tests 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | 19 | 20 | dev.simplix.core 21 | simplixcore-common-api 22 | 1.0.0-SNAPSHOT 23 | test 24 | 25 | 26 | dev.simplix.core 27 | simplixcore-common-implementation 28 | 1.0.0-SNAPSHOT 29 | test 30 | 31 | 32 | 33 | org.junit.jupiter 34 | junit-jupiter-engine 35 | 5.7.0 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | maven-compiler-plugin 44 | 45 | 1.8 46 | 1.8 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-surefire-plugin 52 | 3.0.0-M5 53 | 54 | 55 | **/*Spec.* 56 | **/*Test.* 57 | 58 | false 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/libloader/SimplixClassLoader.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import java.net.URL; 4 | import java.net.URLClassLoader; 5 | import java.net.URLStreamHandlerFactory; 6 | import java.util.Optional; 7 | import lombok.ToString; 8 | 9 | @ToString() 10 | public class SimplixClassLoader extends URLClassLoader { 11 | 12 | private final ClassLoader parentLoader; 13 | 14 | public SimplixClassLoader(URL[] urls, ClassLoader parent) { 15 | super(urls); 16 | this.parentLoader = parent; 17 | } 18 | 19 | public SimplixClassLoader(URL[] urls) { 20 | super(urls); 21 | this.parentLoader = null; 22 | } 23 | 24 | /** 25 | * @param urls the URLs from which to load classes and resources 26 | * @param parentLoader Parent classloader: Not passed on to the super constructor! 27 | * @param factory the URLStreamHandlerFactory to use when creating URLs 28 | */ 29 | public SimplixClassLoader( 30 | URL[] urls, 31 | ClassLoader parentLoader, 32 | URLStreamHandlerFactory factory) { 33 | super(urls, null, factory); 34 | this.parentLoader = parentLoader; 35 | } 36 | 37 | public Optional parent() { 38 | return Optional.ofNullable(parentLoader); 39 | } 40 | 41 | @Override 42 | public void addURL(URL url) { 43 | super.addURL(url); 44 | } 45 | 46 | @Override 47 | public Class loadClass(String name) throws ClassNotFoundException { 48 | return loadClass(name, false); 49 | } 50 | 51 | @Override 52 | protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 53 | return loadClass(name, resolve, true); 54 | } 55 | 56 | public Class loadClass(String name, boolean resolve, boolean useParent) 57 | throws ClassNotFoundException { 58 | try { 59 | return super.loadClass(name, resolve); 60 | } catch (Throwable ignored) { 61 | if (parentLoader != null && useParent) { 62 | try { 63 | return parentLoader.loadClass(name); 64 | } catch (Throwable ignored1) { 65 | } 66 | } 67 | } 68 | throw new ClassNotFoundException(name); 69 | } 70 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/permission/Permissions.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.permission; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import lombok.NonNull; 9 | import lombok.SneakyThrows; 10 | import lombok.experimental.UtilityClass; 11 | 12 | /** 13 | * Central utility class to handle {@link Permission}'s 14 | *

15 | * Within this class you can store and register permissions 16 | */ 17 | @UtilityClass 18 | public class Permissions { 19 | 20 | private final List registeredPermissions = new ArrayList<>(); 21 | 22 | /** 23 | * Returns all registered {@link Permission}'s as an unmodifiable collection. It is made 24 | * unmodifiable since we don't want listeners to be removed from it 25 | */ 26 | public List registeredPermissions() { 27 | return Collections.unmodifiableList(Permissions.registeredPermissions); 28 | } 29 | 30 | /** 31 | * Add an {@link Permission} to the known permissions 32 | */ 33 | public void register(@NonNull Permission permission) { 34 | Permissions.registeredPermissions.add(permission); 35 | } 36 | 37 | /** 38 | * Add a collection of {@link Permission} to the known permissions 39 | */ 40 | public void registerAll(@NonNull Collection permissions) { 41 | Permissions.registeredPermissions.addAll(permissions); 42 | } 43 | 44 | /** 45 | * Method to register permissions from an class that contains them as static fields 46 | */ 47 | @SneakyThrows 48 | public void addFromClass(final Class clazz) { 49 | for (final Field field : clazz.getDeclaredFields()) { 50 | if (field.getType() != Permission.class) { 51 | continue; 52 | } 53 | boolean accessible = field.isAccessible(); 54 | if (!accessible) { 55 | field.setAccessible(true); 56 | } 57 | final Permission perm = (Permission) field.get(null); 58 | if (perm == null) { 59 | continue; 60 | } 61 | field.setAccessible(accessible); 62 | Permissions.register(perm); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /simplixcore-database/simplixcore-database-sql/src/main/java/dev/simplix/core/database/sql/util/QueryFactory.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.database.sql.util; 2 | 3 | import com.google.common.util.concurrent.ListeningExecutorService; 4 | import java.util.function.Supplier; 5 | import javax.sql.DataSource; 6 | import org.apache.commons.dbutils.QueryRunner; 7 | 8 | public class QueryFactory { 9 | 10 | private final Supplier executorServiceSupplier; 11 | private Supplier dataSourceSupplier; 12 | 13 | public QueryFactory( 14 | Supplier executorServiceSupplier, 15 | Supplier dataSourceSupplier) { 16 | this.executorServiceSupplier = executorServiceSupplier; 17 | this.dataSourceSupplier = dataSourceSupplier; 18 | } 19 | 20 | public QueryFactory( 21 | Supplier executorServiceSupplier, 22 | DataSource dataSource) { 23 | this.executorServiceSupplier = executorServiceSupplier; 24 | this.dataSourceSupplier = (() -> dataSource); 25 | } 26 | 27 | public QueryRunner query() { 28 | return new QueryRunner(getDataSource()); 29 | } 30 | 31 | public ReThrowableQueryRunner uncheckedQuery() { 32 | return new ReThrowableQueryRunner(getDataSource()); 33 | } 34 | 35 | public ListenableAsyncQueryRunner listenableQuery() { 36 | return new ListenableAsyncQueryRunner( 37 | executorServiceSupplier.get(), 38 | new QueryRunner(getDataSource())); 39 | } 40 | 41 | public CompletableAsyncQueryRunner completableQuery() { 42 | return new CompletableAsyncQueryRunner( 43 | executorServiceSupplier.get(), 44 | new QueryRunner(getDataSource())); 45 | } 46 | 47 | public ListeningExecutorService getExecutorService() { 48 | return executorServiceSupplier.get(); 49 | } 50 | 51 | public DataSource getDataSource() { 52 | return dataSourceSupplier.get(); 53 | } 54 | 55 | public void setDataSource(DataSource dataSource) { 56 | this.dataSourceSupplier = (() -> dataSource); 57 | } 58 | 59 | public void setDataSourceSupplier(Supplier dataSourceSupplier) { 60 | this.dataSourceSupplier = dataSourceSupplier; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/i18n/LocalizationManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.i18n; 2 | 3 | import java.util.Locale; 4 | import java.util.Set; 5 | import lombok.NonNull; 6 | 7 | /** 8 | * The localization manager handles all translation stuff for any supported language. 9 | */ 10 | public interface LocalizationManager { 11 | 12 | /** 13 | * The string used when some string isn't localized in any language. 14 | * 15 | * @param string The fallback string 16 | */ 17 | void fallbackString(@NonNull String string); 18 | 19 | /** 20 | * The string used when some string isn't localized in any language. 21 | * 22 | * @return The fallback string 23 | */ 24 | String fallbackString(); 25 | 26 | /** 27 | * The locale used when some string isn't localized in a specific language. 28 | * 29 | * @param locale The locale 30 | */ 31 | void fallbackLocale(@NonNull Locale locale); 32 | 33 | /** 34 | * The locale used when some string isn't localized in a specific language. 35 | * 36 | * @return The locale 37 | */ 38 | Locale fallbackLocale(); 39 | 40 | /** 41 | * @return The default locale 42 | */ 43 | Locale defaultLocale(); 44 | 45 | /** 46 | * @param locale default locale 47 | */ 48 | void defaultLocale(@NonNull Locale locale); 49 | 50 | /** 51 | * Translates a string identified by its key. 52 | * 53 | * @param key The string key 54 | * @return The localized string or if not present the fallback string 55 | */ 56 | String localized(@NonNull String key); 57 | 58 | /** 59 | * Translates a string identified by its key. 60 | * 61 | * @param key The string key 62 | * @param locale The locale to use 63 | * @return The localized string or if not present the fallback string 64 | */ 65 | String localized(@NonNull String key, @NonNull Locale locale); 66 | 67 | /** 68 | * Returns all supported keys 69 | * 70 | * @param locale The locale 71 | * @return Supported keys for that locale 72 | */ 73 | Set keys(@NonNull Locale locale); 74 | 75 | /** 76 | * Returns all supported locales 77 | * 78 | * @return Supported locales 79 | */ 80 | Set locales(); 81 | 82 | } 83 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-dynamiccommands/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-bungeecord 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | simplixcore-minecraft-bungeecord-dynamiccommands 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | 20 | maven-compiler-plugin 21 | 22 | 1.8 23 | 1.8 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-source-plugin 29 | 3.0.1 30 | 31 | 32 | attach-sources 33 | deploy 34 | 35 | jar-no-fork 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-javadoc-plugin 43 | 3.3.1 44 | 45 | 46 | attach-javadocs 47 | 48 | jar 49 | 50 | 51 | 52 | 53 | 54 | maven-deploy-plugin 55 | 56 | 57 | deploy 58 | deploy 59 | 60 | deploy 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/src/test/java/dev/simplix/core/minecraft/spigot/tests/SpigotPluginShadeTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.tests; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import lombok.NonNull; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | /** 9 | * Test to shade whether everything was shaded correctly 10 | */ 11 | public class SpigotPluginShadeTest { 12 | 13 | @Test 14 | void testClassPresence() { 15 | //Common-Api 16 | assertPresent("dev.simplix.core.common.ApplicationInfo"); 17 | // Common-Implementation 18 | assertPresent("dev.simplix.core.common.CommonSimplixModule"); 19 | // Database-SQL 20 | assertPresent("dev.simplix.core.database.sql.HikariDataSourceCreator"); 21 | 22 | assertPackageEquals(ApplicationInfo.class, "dev.simplix.core.common"); 23 | } 24 | 25 | private void assertPackageEquals(Class classRef, String packageName) { 26 | assertPackageEquals( 27 | classRef, 28 | packageName, 29 | classRef.getSimpleName() + " should not be relocated"); 30 | 31 | } 32 | 33 | // This method will work since the maven relocation won't run over strings in the tests directory 34 | public void assertPackageEquals( 35 | @NonNull Class classRef, 36 | @NonNull String packageName, 37 | @NonNull String notEqualsMessage) { 38 | Assertions.assertTrue(doesPackageEquals(classRef, packageName), notEqualsMessage); 39 | } 40 | 41 | public boolean doesPackageEquals(@NonNull Class classRef, @NonNull String packageName) { 42 | return classRef.getPackage().getName().equals(packageName); 43 | } 44 | 45 | private void assertPresent(@NonNull String className) { 46 | assertPresent(className, className + " must be present"); 47 | } 48 | 49 | private void assertPresent(@NonNull String className, @NonNull String notPresentMessage) { 50 | Assertions.assertTrue(isPresent(className), notPresentMessage); 51 | } 52 | 53 | private boolean isPresent(@NonNull String className) { 54 | try { 55 | Class.forName(className); 56 | return true; 57 | } catch (final Throwable throwable) { 58 | return false; 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-tests/src/test/java/dev/simplix/core/minecraft/bungeecord/tests/BungeeCordPluginShadeTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.tests; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import lombok.NonNull; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | /** 9 | * Test to shade whether everything was shaded correctly 10 | */ 11 | public class BungeeCordPluginShadeTest { 12 | 13 | @Test 14 | void testClassPresence() { 15 | //Common-Api 16 | assertPresent("dev.simplix.core.common.ApplicationInfo"); 17 | // Common-Implementation 18 | assertPresent("dev.simplix.core.common.CommonSimplixModule"); 19 | // Database-SQL 20 | assertPresent("dev.simplix.core.database.sql.HikariDataSourceCreator"); 21 | 22 | assertPackageEquals(ApplicationInfo.class, "dev.simplix.core.common"); 23 | } 24 | 25 | private void assertPackageEquals(Class classRef, String packageName) { 26 | assertPackageEquals( 27 | classRef, 28 | packageName, 29 | classRef.getSimpleName() + " should not be relocated"); 30 | 31 | } 32 | 33 | // This method will work since the maven relocation won't run over strings in the tests directory 34 | public void assertPackageEquals( 35 | @NonNull Class classRef, 36 | @NonNull String packageName, 37 | @NonNull String notEqualsMessage) { 38 | Assertions.assertTrue(doesPackageEquals(classRef, packageName), notEqualsMessage); 39 | } 40 | 41 | public boolean doesPackageEquals(@NonNull Class classRef, @NonNull String packageName) { 42 | return classRef.getPackage().getName().equals(packageName); 43 | } 44 | 45 | private void assertPresent(@NonNull String className) { 46 | assertPresent(className, className + " must be present"); 47 | } 48 | 49 | private void assertPresent(@NonNull String className, @NonNull String notPresentMessage) { 50 | Assertions.assertTrue(isPresent(className), notPresentMessage); 51 | } 52 | 53 | private boolean isPresent(@NonNull String className) { 54 | try { 55 | Class.forName(className); 56 | return true; 57 | } catch (final Throwable throwable) { 58 | return false; 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-dynamiccommands/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-minecraft-spigot 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-minecraft-spigot-dynamiccommands 13 | 14 | 15 | 16 | 17 | maven-compiler-plugin 18 | 19 | 1.8 20 | 1.8 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-source-plugin 26 | 3.0.1 27 | 28 | 29 | attach-sources 30 | deploy 31 | 32 | jar-no-fork 33 | 34 | 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-javadoc-plugin 40 | 41 | false 42 | 43 | 3.3.1 44 | 45 | 46 | attach-javadocs 47 | 48 | jar 49 | 50 | 51 | 52 | 53 | 54 | maven-deploy-plugin 55 | 56 | 57 | deploy 58 | deploy 59 | 60 | deploy 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-dynamiclisteners/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-minecraft-bungeecord 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-minecraft-bungeecord-dynamiclisteners 13 | 14 | 15 | 16 | 17 | maven-compiler-plugin 18 | 19 | 1.8 20 | 1.8 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-source-plugin 26 | 3.0.1 27 | 28 | 29 | attach-sources 30 | deploy 31 | 32 | jar-no-fork 33 | 34 | 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-javadoc-plugin 40 | 41 | false 42 | 43 | 3.3.1 44 | 45 | 46 | attach-javadocs 47 | 48 | jar 49 | 50 | 51 | 52 | 53 | 54 | maven-deploy-plugin 55 | 56 | 57 | deploy 58 | deploy 59 | 60 | deploy 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/java/dev/simplix/core/minecraft/spigot/plugin/listeners/ApplicationPreInstallListener.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.plugin.listeners; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import dev.simplix.core.common.events.ApplicationPreInstallEvent; 5 | import dev.simplix.core.common.listener.Listener; 6 | import dev.simplix.core.common.listener.Listeners; 7 | import dev.simplix.core.minecraft.spigot.plugin.util.PluginDescriptionUtil; 8 | import java.io.File; 9 | import java.net.URISyntaxException; 10 | import lombok.NonNull; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.bukkit.plugin.PluginDescriptionFile; 13 | 14 | @Slf4j 15 | public final class ApplicationPreInstallListener implements Listener { 16 | 17 | public ApplicationPreInstallListener() { 18 | Listeners.register(this); 19 | } 20 | 21 | @Override 22 | public Class type() { 23 | return ApplicationPreInstallEvent.class; 24 | } 25 | 26 | @Override 27 | public void handleEvent(@NonNull ApplicationPreInstallEvent event) { 28 | if (event.applicationInfo().version().equals("")) { 29 | try { 30 | PluginDescriptionFile pluginDescription = PluginDescriptionUtil.loadPluginYml(new File(event 31 | .applicationClass() 32 | .getProtectionDomain() 33 | .getCodeSource() 34 | .getLocation() 35 | .toURI())); 36 | if (pluginDescription == null) { 37 | log.warn("[Simplix] Cannot fill plugin version to application info of " + event 38 | .applicationInfo() 39 | .name() + ": No plugin description found"); 40 | return; 41 | } 42 | event.applicationInfo(ApplicationInfo.builder() 43 | .name(event.applicationInfo().name()) 44 | .version(pluginDescription.getVersion()) 45 | .authors(event.applicationInfo().authors()) 46 | .dependencies(event.applicationInfo().dependencies()) 47 | .workingDirectory(event.applicationInfo().workingDirectory()) 48 | .build()); 49 | } catch (URISyntaxException exception) { 50 | // Will never happen 51 | } 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-quickstart/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-spigot 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | simplixcore-minecraft-spigot-quickstart 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | maven-compiler-plugin 20 | 21 | 1.8 22 | 1.8 23 | 24 | 25 | 26 | org.apache.maven.plugins 27 | maven-source-plugin 28 | 3.0.1 29 | 30 | 31 | attach-sources 32 | deploy 33 | 34 | jar-no-fork 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-javadoc-plugin 42 | 43 | false 44 | 45 | 3.3.1 46 | 47 | 48 | attach-javadocs 49 | 50 | jar 51 | 52 | 53 | 54 | 55 | 56 | maven-deploy-plugin 57 | 58 | 59 | deploy 60 | deploy 61 | 62 | deploy 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/src/main/java/dev/simplix/core/minecraft/bungeecord/plugin/listeners/ApplicationPreInstallListener.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.plugin.listeners; 2 | 3 | import dev.simplix.core.common.ApplicationInfo; 4 | import dev.simplix.core.common.events.ApplicationPreInstallEvent; 5 | import dev.simplix.core.common.listener.Listener; 6 | import dev.simplix.core.common.listener.Listeners; 7 | import dev.simplix.core.minecraft.bungeecord.plugin.util.PluginDescriptionUtil; 8 | import java.io.File; 9 | import java.net.URISyntaxException; 10 | import lombok.NonNull; 11 | import lombok.extern.slf4j.Slf4j; 12 | import net.md_5.bungee.api.plugin.PluginDescription; 13 | 14 | @Slf4j 15 | public final class ApplicationPreInstallListener implements Listener { 16 | 17 | public ApplicationPreInstallListener() { 18 | Listeners.register(this); 19 | } 20 | 21 | @Override 22 | public Class type() { 23 | return ApplicationPreInstallEvent.class; 24 | } 25 | 26 | @Override 27 | public void handleEvent(@NonNull ApplicationPreInstallEvent event) { 28 | if (event.applicationInfo().version().equals("")) { 29 | try { 30 | PluginDescription pluginDescription = PluginDescriptionUtil.loadPluginYml(new File(event 31 | .applicationClass() 32 | .getProtectionDomain() 33 | .getCodeSource() 34 | .getLocation() 35 | .toURI())); 36 | if (pluginDescription == null) { 37 | log.warn("[Simplix] Cannot fill plugin version to application info of " + event 38 | .applicationInfo() 39 | .name() + ": No plugin description found"); 40 | return; 41 | } 42 | event.applicationInfo(ApplicationInfo.builder() 43 | .name(event.applicationInfo().name()) 44 | .version(pluginDescription.getVersion()) 45 | .authors(event.applicationInfo().authors()) 46 | .dependencies(event.applicationInfo().dependencies()) 47 | .workingDirectory(event.applicationInfo().workingDirectory()) 48 | .build()); 49 | } catch (URISyntaxException exception) { 50 | // Will never happen 51 | } 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-minecraft 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-minecraft-api 13 | 14 | 15 | 16 | dev.simplix.core 17 | simplixcore-common-api 18 | 1.0.0-SNAPSHOT 19 | 20 | 21 | 22 | 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-compiler-plugin 27 | 3.8.0 28 | 29 | 30 | org.apache.maven.plugins 31 | maven-source-plugin 32 | 3.0.1 33 | 34 | 35 | attach-sources 36 | deploy 37 | 38 | jar-no-fork 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-javadoc-plugin 46 | 3.3.1 47 | 48 | 49 | attach-javadocs 50 | 51 | jar 52 | 53 | 54 | 55 | 56 | 57 | maven-deploy-plugin 58 | 59 | 60 | deploy 61 | deploy 62 | 63 | deploy 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-quickstart/src/main/java/dev/simplix/core/minecraft/velocity/quickstart/SimplixQuickStart.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.quickstart; 2 | 3 | import com.velocitypowered.api.command.CommandMeta; 4 | import com.velocitypowered.api.plugin.PluginContainer; 5 | import com.velocitypowered.api.proxy.ProxyServer; 6 | import lombok.NonNull; 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | /** 10 | * This class is used to quickly populate non-simplix environments with a fresh copy of 11 | * SimplixCore. 12 | */ 13 | @Slf4j 14 | public final class SimplixQuickStart { 15 | 16 | public static final String SIMPLIX_DOWNLOAD_URL 17 | = "https://ci.exceptionflug.de/job/SimplixCore/lastSuccessfulBuild/artifact/simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-plugin/target/SimplixCore-Velocity.jar"; 18 | 19 | /** 20 | * Ensures that SimplixCore is installed on this server. 21 | * 22 | * @param plugin The plugin main class of the caller plugin 23 | * @return true if SimplixCore is installed or false otherwise 24 | */ 25 | public static boolean ensureSimplixCore( 26 | @NonNull ProxyServer proxyServer, 27 | @NonNull PluginContainer plugin) { 28 | if (!proxyServer.getPluginManager().getPlugin("simplixcore").isPresent()) { 29 | registerInstaller(proxyServer, plugin); 30 | return false; 31 | } 32 | return true; 33 | } 34 | 35 | private static void registerInstaller(ProxyServer proxyServer, PluginContainer plugin) { 36 | log("[" 37 | + plugin.getDescription().getName() 38 | + "] This plugin needs the SimplixCore in order to work " 39 | + "properly."); 40 | log("[" 41 | + plugin.getDescription().getName() 42 | + "] If you wish to automatically install SimplixCore " 43 | + "type the following command: simplix install"); 44 | log("[" 45 | + plugin.getDescription().getName() 46 | + "] " 47 | + plugin.getDescription().getName() 48 | + " will now halt."); 49 | proxyServer 50 | .getCommandManager() 51 | .register( 52 | proxyServer.getCommandManager().metaBuilder("simplix").build(), 53 | new SimplixCommand(SIMPLIX_DOWNLOAD_URL)); 54 | } 55 | 56 | private static void log(@NonNull String message) { 57 | log.error(message); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/src/main/java/dev/simplix/core/minecraft/spigot/plugin/deploader/PluginTypeHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.plugin.deploader; 2 | 3 | import com.google.common.io.Files; 4 | import dev.simplix.core.common.deploader.Dependency; 5 | import dev.simplix.core.common.deploader.DependencyTypeHandler; 6 | import dev.simplix.core.common.utils.FileUtils; 7 | import java.io.File; 8 | import java.util.concurrent.atomic.AtomicReference; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.bukkit.Bukkit; 11 | 12 | @Slf4j 13 | public class PluginTypeHandler implements DependencyTypeHandler { 14 | 15 | @Override 16 | public void handle(Dependency dependency, File file) { 17 | File target = new File("plugins", file.getName()); 18 | try { 19 | Files.copy(file, target); 20 | Bukkit.getPluginManager().loadPlugin(target); 21 | } catch (Exception exception) { 22 | log.error("[Simplix | DependencyLoader] Unable to load plugin " + file.getName(), exception); 23 | } 24 | } 25 | 26 | @Override 27 | public boolean shouldInstall(Dependency dependency) { 28 | AtomicReference atomicReference = new AtomicReference<>(); 29 | FileUtils 30 | .context(new File("plugins")) 31 | .whenExists(fileContext -> fileContext.subFiles(fc -> fc.whenFile(subFile -> { 32 | File file = subFile.file(); 33 | if (file.getName().startsWith(dependency.artifactId()) 34 | && !file.getName().equals(dependency.artifactId() + "-" + dependency.version())) { 35 | atomicReference.set(file); 36 | } 37 | }))); 38 | if (atomicReference.get() != null) { 39 | log.warn("[Simplix | DependencyLoader] " 40 | + dependency.applicationName() 41 | + ": Version conflict of plugin " 42 | + dependency); 43 | log.warn("[Simplix | DependencyLoader] " 44 | + dependency.applicationName() 45 | + ": This file seems to contain another version of this dependency: " 46 | + atomicReference.get().getAbsolutePath()); 47 | log.warn("[Simplix | DependencyLoader] " 48 | + dependency.applicationName() 49 | + ": SimplixCore will not load multiple versions of the same dependency. " 50 | + "Please resolve this issue."); 51 | return false; 52 | } 53 | return true; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-plugin/src/main/java/dev/simplix/core/minecraft/bungeecord/plugin/BungeeCordListenerImpl.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.plugin; 2 | 3 | import dev.simplix.core.common.event.Events; 4 | import dev.simplix.core.minecraft.api.events.ChatEvent; 5 | import dev.simplix.core.minecraft.api.events.JoinEvent; 6 | import dev.simplix.core.minecraft.api.events.QuitEvent; 7 | import lombok.NonNull; 8 | import net.md_5.bungee.api.connection.ProxiedPlayer; 9 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 10 | import net.md_5.bungee.api.event.PostLoginEvent; 11 | import net.md_5.bungee.api.plugin.Listener; 12 | import net.md_5.bungee.event.EventHandler; 13 | import net.md_5.bungee.event.EventPriority; 14 | 15 | public class BungeeCordListenerImpl implements Listener { 16 | 17 | private BungeeCordListenerImpl() { 18 | } 19 | 20 | public static BungeeCordListenerImpl create() { 21 | return new BungeeCordListenerImpl(); 22 | } 23 | 24 | @EventHandler(priority = EventPriority.LOW) 25 | public void login(@NonNull PostLoginEvent playerPostLoginEvent) { 26 | final JoinEvent joinEvent = Events.call( 27 | JoinEvent.create( 28 | playerPostLoginEvent.getPlayer().getUniqueId(), 29 | playerPostLoginEvent.getPlayer().getName(), 30 | playerPostLoginEvent.getPlayer().getAddress().getAddress())); 31 | 32 | if (!joinEvent.canceled()) { 33 | return; 34 | } 35 | 36 | if (joinEvent.canceled()) { 37 | playerPostLoginEvent.getPlayer() 38 | .disconnect(joinEvent.cancelReason().replace("&", "§")); 39 | } 40 | } 41 | 42 | @EventHandler(priority = EventPriority.LOW) 43 | public void chat(@NonNull net.md_5.bungee.api.event.ChatEvent playerChatEvent) { 44 | final ProxiedPlayer sender = (ProxiedPlayer) playerChatEvent.getSender(); 45 | final ChatEvent chatEvent = Events.call( 46 | ChatEvent.create( 47 | sender.getUniqueId(), 48 | sender.getAddress().getAddress(), 49 | playerChatEvent.getMessage()) 50 | ); 51 | if (chatEvent.canceled()) { 52 | playerChatEvent.setCancelled(true); 53 | } 54 | playerChatEvent.setMessage(chatEvent.message()); 55 | } 56 | 57 | @EventHandler(priority = EventPriority.LOW) 58 | public void quit(@NonNull PlayerDisconnectEvent playerDisconnectEvent) { 59 | Events.call(QuitEvent.create(playerDisconnectEvent.getPlayer().getUniqueId())); 60 | } 61 | } -------------------------------------------------------------------------------- /simplixcore-config/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | simplixcore-config 6 | 7 | 4.0.0 8 | 9 | simplixcore 10 | dev.simplix.core 11 | 1.0.0-SNAPSHOT 12 | 13 | 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | 19 | dev.simplix.core 20 | simplixcore-common-api 21 | 1.0.0-SNAPSHOT 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-source-plugin 30 | 3.0.1 31 | 32 | 33 | attach-sources 34 | deploy 35 | 36 | jar-no-fork 37 | 38 | 39 | 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-javadoc-plugin 44 | 3.3.1 45 | 46 | false 47 | 48 | 49 | 50 | attach-javadocs 51 | 52 | jar 53 | 54 | 55 | 56 | 57 | 58 | maven-deploy-plugin 59 | 60 | 61 | deploy 62 | deploy 63 | 64 | deploy 65 | 66 | 67 | 68 | 69 | 70 | maven-compiler-plugin 71 | 72 | 1.8 73 | 1.8 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-plugin/src/main/java/dev/simplix/core/minecraft/velocity/plugin/VelocityListenerImpl.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.plugin; 2 | 3 | import com.velocitypowered.api.event.Subscribe; 4 | import com.velocitypowered.api.event.connection.DisconnectEvent; 5 | import com.velocitypowered.api.event.connection.PostLoginEvent; 6 | import com.velocitypowered.api.event.player.PlayerChatEvent; 7 | import com.velocitypowered.api.event.player.PlayerChatEvent.ChatResult; 8 | import com.velocitypowered.api.proxy.Player; 9 | import dev.simplix.core.common.event.Events; 10 | import dev.simplix.core.minecraft.api.events.ChatEvent; 11 | import dev.simplix.core.minecraft.api.events.JoinEvent; 12 | import dev.simplix.core.minecraft.api.events.QuitEvent; 13 | import lombok.NonNull; 14 | import net.kyori.adventure.text.Component; 15 | 16 | public class VelocityListenerImpl { 17 | 18 | public static VelocityListenerImpl create() { 19 | return new VelocityListenerImpl(); 20 | } 21 | 22 | private VelocityListenerImpl() { 23 | } 24 | 25 | @Subscribe 26 | public void login(@NonNull PostLoginEvent playerPostLoginEvent) { 27 | final JoinEvent joinEvent = Events.call( 28 | JoinEvent.create( 29 | playerPostLoginEvent.getPlayer().getUniqueId(), 30 | playerPostLoginEvent.getPlayer().getUsername(), 31 | playerPostLoginEvent.getPlayer().getRemoteAddress().getAddress())); 32 | 33 | if (!joinEvent.canceled()) { 34 | return; 35 | } 36 | 37 | if (joinEvent.canceled()) { 38 | playerPostLoginEvent.getPlayer() 39 | .disconnect(Component.text(joinEvent.cancelReason().replace("&", "§"))); 40 | } 41 | } 42 | 43 | @Subscribe 44 | public void chat(@NonNull PlayerChatEvent playerChatEvent) { 45 | final Player sender = playerChatEvent.getPlayer(); 46 | final ChatEvent chatEvent = Events.call( 47 | ChatEvent.create( 48 | sender.getUniqueId(), 49 | sender.getRemoteAddress().getAddress(), 50 | playerChatEvent.getMessage()) 51 | ); 52 | 53 | playerChatEvent.setResult(chatEvent.canceled() 54 | ? ChatResult.denied() : ChatResult.message(chatEvent.message())); 55 | } 56 | 57 | @Subscribe 58 | public void quit(@NonNull DisconnectEvent playerDisconnectEvent) { 59 | final QuitEvent quitEvent = 60 | Events.call( 61 | QuitEvent.create(playerDisconnectEvent.getPlayer().getUniqueId()) 62 | ); 63 | } 64 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/i18n/SimpleLocalizationManager.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.i18n; 2 | 3 | import java.util.Collections; 4 | import java.util.Locale; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import lombok.NonNull; 8 | 9 | public class SimpleLocalizationManager implements LocalizationManager { 10 | 11 | private final Map> translations; 12 | private Locale fallbackLocale, defaultLocale = Locale.ENGLISH; 13 | private String fallbackString = "N/A"; 14 | 15 | SimpleLocalizationManager(@NonNull Map> translations) { 16 | this.translations = translations; 17 | } 18 | 19 | @Override 20 | public void fallbackString(@NonNull String string) { 21 | this.fallbackString = string; 22 | } 23 | 24 | @Override 25 | public String fallbackString() { 26 | return this.fallbackString; 27 | } 28 | 29 | @Override 30 | public void fallbackLocale(@NonNull Locale locale) { 31 | this.fallbackLocale = locale; 32 | } 33 | 34 | @Override 35 | public Locale fallbackLocale() { 36 | return this.fallbackLocale; 37 | } 38 | 39 | @Override 40 | public Locale defaultLocale() { 41 | return defaultLocale; 42 | } 43 | 44 | @Override 45 | public void defaultLocale(@NonNull Locale locale) { 46 | this.defaultLocale = locale; 47 | } 48 | 49 | @Override 50 | public String localized(@NonNull String key) { 51 | return localized(key, defaultLocale); 52 | } 53 | 54 | @Override 55 | public String localized(@NonNull String key, @NonNull Locale locale) { 56 | Map trans = this.translations.get(locale); 57 | if (trans == null) { 58 | trans = this.translations.get(fallbackLocale()); 59 | if (trans == null) { 60 | return fallbackString(); 61 | } 62 | } 63 | String out = trans.get(key); 64 | if (out == null) { 65 | out = this.translations.getOrDefault(fallbackLocale(), Collections.emptyMap()).get(key); 66 | if (out == null) { 67 | return fallbackString(); 68 | } 69 | } 70 | return out; 71 | } 72 | 73 | @Override 74 | public Set keys(@NonNull Locale locale) { 75 | return Collections.unmodifiableSet(this.translations 76 | .getOrDefault(locale, Collections.emptyMap()) 77 | .keySet()); 78 | } 79 | 80 | @Override 81 | public Set locales() { 82 | return Collections.unmodifiableSet(this.translations.keySet()); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-quickstart/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-bungeecord 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-bungeecord-quickstart 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | 19 | dev.simplix.core 20 | simplixcore-minecraft-bungeecord-slf4j 21 | 1.0.0-SNAPSHOT 22 | compile 23 | 24 | 25 | 26 | 27 | 28 | 29 | maven-compiler-plugin 30 | 31 | 1.8 32 | 1.8 33 | 34 | 35 | 36 | org.apache.maven.plugins 37 | maven-source-plugin 38 | 3.0.1 39 | 40 | 41 | attach-sources 42 | deploy 43 | 44 | jar-no-fork 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-javadoc-plugin 52 | 3.3.1 53 | 54 | 55 | attach-javadocs 56 | 57 | jar 58 | 59 | 60 | 61 | 62 | 63 | maven-deploy-plugin 64 | 65 | 66 | deploy 67 | deploy 68 | 69 | deploy 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-dynamiclisteners/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-spigot 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | dev.simplix.core 14 | simplixcore-minecraft-spigot-dynamiclisteners 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | 19 | spigot-repo 20 | https://hub.spigotmc.org/nexus/content/repositories/snapshots 21 | 22 | 23 | 24 | 25 | 26 | 27 | maven-compiler-plugin 28 | 29 | 1.8 30 | 1.8 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-source-plugin 36 | 3.0.1 37 | 38 | 39 | attach-sources 40 | deploy 41 | 42 | jar-no-fork 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-javadoc-plugin 50 | 51 | false 52 | 53 | 3.3.1 54 | 55 | 56 | attach-javadocs 57 | 58 | jar 59 | 60 | 61 | 62 | 63 | 64 | maven-deploy-plugin 65 | 66 | 67 | deploy 68 | deploy 69 | 70 | deploy 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | dev.simplix.core 9 | simplixcore-minecraft-spigot 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | simplixcore-minecraft-spigot-tests 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | 18 | dev.simplix.core 19 | simplixcore-minecraft-spigot-implementation 20 | 1.0.0-SNAPSHOT 21 | test 22 | 23 | 24 | org.junit.jupiter 25 | junit-jupiter-engine 26 | 5.7.0 27 | test 28 | 29 | 30 | dev.simplix.core 31 | simplixcore-minecraft-spigot-quickstart 32 | 1.0.0-SNAPSHOT 33 | test 34 | 35 | 36 | dev.simplix.core 37 | simplixcore-minecraft-spigot-plugin 38 | 1.0.${build.number} 39 | test 40 | 41 | 42 | com.github.seeseemelk 43 | MockBukkit-v1.16 44 | 0.5.0 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | maven-compiler-plugin 53 | 54 | 1.8 55 | 1.8 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-surefire-plugin 61 | 3.0.0-M5 62 | 63 | 64 | **/*Spec.* 65 | **/*Test.* 66 | 67 | false 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-velocity/simplixcore-minecraft-velocity-plugin/src/main/java/dev/simplix/core/minecraft/velocity/plugin/listeners/ApplicationPreInstallListener.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.velocity.plugin.listeners; 2 | 3 | import com.velocitypowered.api.plugin.PluginContainer; 4 | import com.velocitypowered.api.plugin.PluginDescription; 5 | import com.velocitypowered.api.proxy.ProxyServer; 6 | import dev.simplix.core.common.ApplicationInfo; 7 | import dev.simplix.core.common.events.ApplicationPreInstallEvent; 8 | import dev.simplix.core.common.listener.Listener; 9 | import dev.simplix.core.common.listener.Listeners; 10 | import java.net.URISyntaxException; 11 | import lombok.NonNull; 12 | import lombok.extern.slf4j.Slf4j; 13 | 14 | @Slf4j 15 | public final class ApplicationPreInstallListener implements Listener { 16 | 17 | private final ProxyServer proxyServer; 18 | 19 | public ApplicationPreInstallListener(@NonNull ProxyServer proxyServer) { 20 | this.proxyServer = proxyServer; 21 | Listeners.register(this); 22 | } 23 | 24 | @Override 25 | public Class type() { 26 | return ApplicationPreInstallEvent.class; 27 | } 28 | 29 | @Override 30 | public void handleEvent(@NonNull ApplicationPreInstallEvent event) { 31 | if (event.applicationInfo().version().equals("")) { 32 | PluginDescription pluginDescription = obtainPluginDescription(event.applicationClass()); 33 | if (pluginDescription == null) { 34 | log.warn("[Simplix] Cannot fill plugin version to application info of " + event 35 | .applicationInfo() 36 | .name() + ": No plugin description found"); 37 | return; 38 | } 39 | event.applicationInfo(ApplicationInfo.builder() 40 | .name(event.applicationInfo().name()) 41 | .version(pluginDescription.getVersion().orElse("")) 42 | .authors(event.applicationInfo().authors()) 43 | .dependencies(event.applicationInfo().dependencies()) 44 | .workingDirectory(event.applicationInfo().workingDirectory()) 45 | .build()); 46 | } 47 | } 48 | 49 | private PluginDescription obtainPluginDescription(@NonNull Class applicationClass) { 50 | for (PluginContainer pluginContainer : proxyServer.getPluginManager().getPlugins()) { 51 | if(pluginContainer.getInstance().isPresent()) { 52 | if(pluginContainer.getInstance().get().getClass().equals(applicationClass)) { 53 | return pluginContainer.getDescription(); 54 | } 55 | } 56 | } 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /simplixcore-http/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | dev.simplix.core 7 | simplixcore-http 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | 13 | simplixcore 14 | dev.simplix.core 15 | 1.0.0-SNAPSHOT 16 | 17 | 18 | 19 | 20 | 21 | dev.simplix.core 22 | simplixcore-common-api 23 | 1.0.0-SNAPSHOT 24 | provided 25 | 26 | 27 | 28 | 29 | de.exceptionflug 30 | moon-core 31 | 1.0-SNAPSHOT 32 | compile 33 | 34 | 35 | 36 | 37 | 38 | 39 | maven-compiler-plugin 40 | 41 | 1.8 42 | 1.8 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-shade-plugin 48 | 3.2.4 49 | 50 | true 51 | 52 | 53 | de.exceptionflug.moon 54 | dev.simplix.core.http 55 | 56 | 57 | 58 | 59 | 60 | make-assembly 61 | package 62 | 63 | shade 64 | 65 | 66 | 67 | 68 | 69 | maven-deploy-plugin 70 | 71 | 72 | deploy 73 | deploy 74 | 75 | deploy 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | simplixcore-common 7 | dev.simplix.core 8 | 1.0.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | simplixcore-common-api 13 | 1.0.0-SNAPSHOT 14 | 15 | 16 | 17 | 18 | com.github.simplix-softworks 19 | simplixstorage 20 | 3.2.3 21 | 22 | 23 | com.google.code.gson 24 | gson 25 | 2.8.6 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-source-plugin 34 | 3.0.1 35 | 36 | 37 | attach-sources 38 | deploy 39 | 40 | jar-no-fork 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-javadoc-plugin 48 | 49 | false 50 | 51 | 3.3.1 52 | 53 | 54 | attach-javadocs 55 | 56 | jar 57 | 58 | 59 | 60 | 61 | 62 | maven-compiler-plugin 63 | 64 | 1.8 65 | 1.8 66 | 67 | 68 | 69 | maven-deploy-plugin 70 | 71 | 72 | deploy 73 | deploy 74 | 75 | deploy 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-quickstart/src/main/java/dev/simplix/core/minecraft/spigot/quickstart/SimplixCommand.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.quickstart; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | import java.io.IOException; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | import java.net.URLConnection; 10 | import lombok.NonNull; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.bukkit.command.Command; 13 | import org.bukkit.command.CommandSender; 14 | 15 | @Slf4j 16 | public final class SimplixCommand extends Command { 17 | 18 | private final String downloadAddress; 19 | 20 | public SimplixCommand(String downloadAddress) { 21 | super("simplix"); 22 | this.downloadAddress = downloadAddress; 23 | } 24 | 25 | @Override 26 | public boolean execute(CommandSender commandSender, String commandLabel, String[] strings) { 27 | if (!commandSender.hasPermission("simplix.install")) { 28 | return false; 29 | } 30 | if (strings.length == 0) { 31 | commandSender.sendMessage("Use command \"simplix install\" to install SimplixCore."); 32 | } else { 33 | if (!strings[0].equalsIgnoreCase("install")) { 34 | return false; 35 | } 36 | commandSender.sendMessage("Going to install SimplixCore to your Spigot server!"); 37 | try { 38 | download(new URL(this.downloadAddress), new File("./plugins/SimplixCore-Spigot.jar")); 39 | commandSender.sendMessage("Installation done. Please restart your Spigot server."); 40 | } catch (Exception exception) { 41 | commandSender.sendMessage( 42 | "§cException while downloading SimplixCore! Check console for details."); 43 | log.error("Exception while downloading SimplixCore", exception); 44 | } 45 | } 46 | return false; 47 | } 48 | 49 | private void download(@NonNull URL url, @NonNull File file) throws IOException { 50 | URLConnection urlConnection = url.openConnection(); 51 | if (!(urlConnection instanceof HttpURLConnection)) { 52 | throw new IllegalArgumentException("Unsupported protocol " + url.getProtocol()); 53 | } 54 | file.getParentFile().mkdirs(); 55 | HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection; 56 | if (file.exists()) { 57 | return; 58 | } 59 | if (!file.createNewFile()) { 60 | throw new IOException("File could not be overridden"); 61 | } 62 | try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { 63 | fileOutputStream.write(ByteStreams.toByteArray(httpURLConnection.getInputStream())); 64 | fileOutputStream.flush(); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-bungeecord/simplixcore-minecraft-bungeecord-quickstart/src/main/java/dev/simplix/core/minecraft/bungeecord/quickstart/SimplixCommand.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.bungeecord.quickstart; 2 | 3 | import com.google.common.io.ByteStreams; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | import java.io.IOException; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | import java.net.URLConnection; 10 | import java.util.logging.Level; 11 | import lombok.NonNull; 12 | import net.md_5.bungee.api.CommandSender; 13 | import net.md_5.bungee.api.ProxyServer; 14 | import net.md_5.bungee.api.plugin.Command; 15 | 16 | public final class SimplixCommand extends Command { 17 | 18 | private final String downloadAddress; 19 | 20 | public SimplixCommand(@NonNull String downloadAddress) { 21 | super("simplix"); 22 | this.downloadAddress = downloadAddress; 23 | } 24 | 25 | @Override 26 | public void execute(CommandSender commandSender, String[] strings) { 27 | if (!commandSender.hasPermission("simplix.install")) { 28 | return; 29 | } 30 | if (strings.length == 0) { 31 | commandSender.sendMessage("Use command \"simplix install\" to install SimplixCore."); 32 | } else { 33 | if (strings[0].equalsIgnoreCase("install")) { 34 | commandSender.sendMessage("Going to install SimplixCore to your BungeeCord server!"); 35 | try { 36 | download(new URL(this.downloadAddress), new File("./plugins/SimplixCore-BungeeCord.jar")); 37 | commandSender.sendMessage("SimplixCore was installed successfully."); 38 | } catch (Exception exception) { 39 | commandSender.sendMessage( 40 | "§cException while downloading SimplixCore! Check console for details."); 41 | ProxyServer 42 | .getInstance() 43 | .getLogger() 44 | .log(Level.SEVERE, "Exception while downloading SimplixCore", exception); 45 | } 46 | } 47 | } 48 | } 49 | 50 | private void download(@NonNull URL url, @NonNull File file) throws IOException { 51 | URLConnection urlConnection = url.openConnection(); 52 | if (!(urlConnection instanceof HttpURLConnection)) { 53 | throw new IllegalArgumentException("Unsupported protocol " + url.getProtocol()); 54 | } 55 | 56 | HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection; 57 | if (file.exists()) { 58 | return; 59 | } 60 | if (!file.createNewFile()) { 61 | throw new IOException("File could not be overridden"); 62 | } 63 | try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { 64 | fileOutputStream.write(ByteStreams.toByteArray(httpURLConnection.getInputStream())); 65 | fileOutputStream.flush(); 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-quickstart/src/main/java/dev/simplix/core/minecraft/spigot/quickstart/SimplixQuickStart.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.minecraft.spigot.quickstart; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.logging.Level; 5 | import lombok.NonNull; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandMap; 9 | import org.bukkit.plugin.java.JavaPlugin; 10 | 11 | /** 12 | * This class is used to quickly populate non-simplix environments with a fresh copy of 13 | * SimplixCore. 14 | * 15 | * Please note that you have to add the command "simplix" in your plugin.yml 16 | */ 17 | public final class SimplixQuickStart { 18 | 19 | public static final String SIMPLIX_DOWNLOAD_URL 20 | = "https://ci.exceptionflug.de/job/SimplixCore/lastSuccessfulBuild/artifact/simplixcore-minecraft/simplixcore-minecraft-spigot/simplixcore-minecraft-spigot-plugin/target/SimplixCore-Spigot.jar"; 21 | 22 | /** 23 | * Ensures that SimplixCore is installed on this server. 24 | * 25 | * @param plugin The plugin main class of the caller plugin 26 | * @return true if SimplixCore is installed or false otherwise 27 | */ 28 | public static boolean ensureSimplixCore(@NonNull JavaPlugin plugin) { 29 | if (Bukkit.getPluginManager().getPlugin("SimplixCore") == null) { 30 | registerInstaller(plugin); 31 | return false; 32 | } 33 | return true; 34 | } 35 | 36 | private static void registerInstaller(@NonNull JavaPlugin plugin) { 37 | log("[" 38 | + plugin.getDescription().getName() 39 | + "] This plugin needs the SimplixCore in order to work " 40 | + "properly."); 41 | log("[" 42 | + plugin.getDescription().getName() 43 | + "] If you wish to automatically install SimplixCore " 44 | + "type the following command: simplix install"); 45 | log("[" 46 | + plugin.getDescription().getName() 47 | + "] " 48 | + plugin.getDescription().getName() 49 | + " will now halt."); 50 | 51 | registerCommand(new SimplixCommand(SIMPLIX_DOWNLOAD_URL)); 52 | } 53 | 54 | private static void log(@NonNull String string) { 55 | Bukkit.getLogger().severe(string); 56 | } 57 | 58 | public static void registerCommand(@NonNull final Command command) { 59 | try { 60 | final Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap"); 61 | commandMapField.setAccessible(true); 62 | 63 | final CommandMap commandMap = (CommandMap) commandMapField.get(Bukkit.getServer()); 64 | commandMap.register(command.getLabel(), command); 65 | } catch (final Throwable throwable) { 66 | Bukkit.getLogger().log(Level.SEVERE, "Unable to register command", throwable); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-implementation/src/main/java/dev/simplix/core/common/libloader/SharedLibraryTypeHandler.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.libloader; 2 | 3 | import com.google.common.io.Files; 4 | import dev.simplix.core.common.deploader.Dependency; 5 | import dev.simplix.core.common.deploader.DependencyTypeHandler; 6 | import dev.simplix.core.common.inject.SimplixInstaller; 7 | import dev.simplix.core.common.utils.FileUtils; 8 | import dev.simplix.core.common.utils.FileUtils.FileContext; 9 | import java.io.File; 10 | import java.util.concurrent.atomic.AtomicReference; 11 | import lombok.NonNull; 12 | import lombok.extern.slf4j.Slf4j; 13 | 14 | @Slf4j 15 | public class SharedLibraryTypeHandler implements DependencyTypeHandler { 16 | 17 | private static final FileContext LIBRARIES_CONTEXT = FileUtils.context(new File("libraries")); 18 | 19 | @Override 20 | public void handle(@NonNull Dependency dependency, @NonNull File file) { 21 | File target = LIBRARIES_CONTEXT 22 | .subFile(file.getName()) 23 | .makeParentDirectories() 24 | .file(); 25 | try { 26 | Files.copy(file, target); 27 | SimplixInstaller 28 | .instance() 29 | .libraryLoader() 30 | .loadLibrary(target); 31 | } catch (Exception e) { 32 | log.error("[SimplixCore | DependencyLoader] Cannot install " 33 | + dependency 34 | + " as shared library!"); 35 | } 36 | } 37 | 38 | @Override 39 | public boolean shouldInstall(@NonNull Dependency dependency) { 40 | AtomicReference atomicReference = new AtomicReference<>(); 41 | LIBRARIES_CONTEXT.whenExists(fileContext -> fileContext.subFiles(fc -> fc.whenFile(subFile -> { 42 | File file = fileContext.file(); 43 | if (file.getName().startsWith(dependency.artifactId() + "-") 44 | && !file.getName().equals(dependency.artifactId() + "-" + dependency.version())) { 45 | atomicReference.set(file); 46 | } 47 | }))); 48 | if (atomicReference.get() != null) { 49 | log.warn("[Simplix | DependencyLoader] " 50 | + dependency.applicationName() 51 | + ": Version conflict of shared library " 52 | + dependency.toString()); 53 | log.warn("[Simplix | DependencyLoader] " 54 | + dependency.applicationName() 55 | + ": This file seems to contain another version of this dependency: " 56 | + atomicReference.get().getAbsolutePath()); 57 | log.warn("[Simplix | DependencyLoader] " 58 | + dependency.applicationName() 59 | + ": SimplixCore will not load multiple versions of the same dependency. " 60 | + "Please resolve this issue or consider using encapsulated libraries instead."); 61 | return false; 62 | } 63 | return true; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-tests/src/test/java/dev/simplix/core/common/inject/SimplixInstallerTest.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.inject; 2 | 3 | import com.google.inject.Injector; 4 | import dev.simplix.core.common.aop.SimplixApplication; 5 | import dev.simplix.core.common.deploader.DependencyLoader; 6 | import dev.simplix.core.common.libloader.LibraryLoader; 7 | import dev.simplix.core.common.platform.Platform; 8 | import dev.simplix.core.common.updater.Updater; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.BeforeAll; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.slf4j.LoggerFactory; 14 | 15 | @SimplixApplication(name = "TestApplication", version = "1.0.0-SNAPSHOT", authors = "SimplixSoftworks") 16 | class SimplixInstallerTest { 17 | 18 | @Test 19 | @BeforeAll 20 | static void instance() { 21 | SimplixInstaller.init(LoggerFactory.getLogger(SimplixInstaller.class)); 22 | 23 | Assertions.assertNotNull( 24 | SimplixInstaller.instance(), 25 | "SimplixInstaller instance mustn't be null"); 26 | } 27 | 28 | @Test 29 | static void injector() { 30 | final Injector injector = SimplixInstaller.instance().injector(SimplixInstaller.class); 31 | Assertions.assertNotNull(injector, "Injector mustn't be null"); 32 | Assertions.assertEquals("com.google.inject", injector.getClass().getName()); 33 | } 34 | 35 | @BeforeEach 36 | void register() { 37 | SimplixInstaller.instance().register(this.getClass()); 38 | } 39 | 40 | @Test 41 | void registered() { 42 | Assertions.assertTrue(SimplixInstaller.instance().registered("TestApplication")); 43 | } 44 | 45 | @Test 46 | void dependencyLoader() { 47 | final DependencyLoader dependencyLoader = SimplixInstaller.instance().dependencyLoader(); 48 | Assertions.assertNotNull(dependencyLoader, "Dependency-Loader mustn't be null"); 49 | } 50 | 51 | @Test 52 | void updater() { 53 | final Updater updater = SimplixInstaller.instance().updater(); 54 | Assertions.assertNotNull(updater, "Updater mustn't be null"); 55 | } 56 | 57 | @Test 58 | void libraryLoader() { 59 | final LibraryLoader libraryLoader = SimplixInstaller.instance().libraryLoader(); 60 | Assertions.assertNotNull(libraryLoader, "LibraryLoader mustn't be null"); 61 | } 62 | 63 | @Test 64 | void install() { 65 | try { 66 | SimplixInstaller.instance().install(Platform.STANDALONE); 67 | } catch (Throwable throwable) { 68 | Assertions.fail(throwable); 69 | } 70 | } 71 | 72 | @Test 73 | void applicationClass() { 74 | final Class testApplication = SimplixInstaller 75 | .instance() 76 | .applicationClass("TestApplication"); 77 | Assertions.assertNotNull(testApplication, "TestApplication must not be null"); 78 | Assertions.assertEquals(testApplication, this.getClass(), "Invalid class result"); 79 | } 80 | } -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.utils; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.function.Consumer; 6 | 7 | public final class FileUtils { 8 | 9 | private FileUtils() { 10 | } 11 | 12 | public static FileContext context(File file) { 13 | return new FileContext(file); 14 | } 15 | 16 | public static class FileContext { 17 | 18 | private final File file; 19 | 20 | private FileContext(File file) { 21 | this.file = file; 22 | } 23 | 24 | public FileContext whenDirectory(Consumer fileConsumer) { 25 | if (this.file.isDirectory()) { 26 | fileConsumer.accept(this); 27 | } 28 | return this; 29 | } 30 | 31 | public FileContext whenFile(Consumer fileConsumer) { 32 | if (this.file.isFile()) { 33 | fileConsumer.accept(this); 34 | } 35 | return this; 36 | } 37 | 38 | public FileContext whenExists(Consumer fileConsumer) { 39 | if (this.file.exists()) { 40 | fileConsumer.accept(this); 41 | } 42 | return this; 43 | } 44 | 45 | public FileContext whenNotExists(Consumer fileConsumer) { 46 | if (!this.file.exists()) { 47 | fileConsumer.accept(this); 48 | } 49 | return this; 50 | } 51 | 52 | public FileContext createNewFile(boolean override) { 53 | Consumer consumer = fileContext -> { 54 | try { 55 | fileContext.file().createNewFile(); 56 | } catch (IOException e) { 57 | throw new FileContextException(e); 58 | } 59 | }; 60 | if (!override) { 61 | return whenNotExists(consumer); 62 | } 63 | consumer.accept(this); 64 | return this; 65 | } 66 | 67 | public FileContext subFiles(Consumer fileConsumer) { 68 | File[] files = this.file.listFiles(); 69 | if (files == null) { 70 | return this; 71 | } 72 | for (File file : files) { 73 | fileConsumer.accept(new FileContext(file)); 74 | } 75 | return this; 76 | } 77 | 78 | public FileContext makeParentDirectories() { 79 | File parentFile = this.file.getParentFile(); 80 | if (parentFile != null) { 81 | parentFile.mkdirs(); 82 | } 83 | return this; 84 | } 85 | 86 | public FileContext subFile(String relPath) { 87 | return new FileContext(new File(this.file, relPath)); 88 | } 89 | 90 | public File file() { 91 | return this.file; 92 | } 93 | 94 | } 95 | 96 | public static class FileContextException extends RuntimeException { 97 | 98 | public FileContextException(IOException cause) { 99 | super(cause); 100 | } 101 | 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /simplixcore-common/simplixcore-common-api/src/main/java/dev/simplix/core/common/aop/AbstractSimplixModule.java: -------------------------------------------------------------------------------- 1 | package dev.simplix.core.common.aop; 2 | 3 | import com.google.inject.Binder; 4 | import com.google.inject.Injector; 5 | import com.google.inject.Module; 6 | import com.google.inject.Scopes; 7 | import com.google.inject.binder.AnnotatedBindingBuilder; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import lombok.NoArgsConstructor; 12 | import lombok.NonNull; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | /** 16 | * A {@link Module} which allows the registration of {@link ComponentInterceptor}s. 17 | */ 18 | @NoArgsConstructor 19 | @SuppressWarnings({"rawtypes", "unchecked"}) 20 | public abstract class AbstractSimplixModule implements com.google.inject.Module { 21 | 22 | private final Map components = new HashMap<>(); 23 | private final Map, ComponentInterceptor> interceptorMap = new HashMap<>(); 24 | 25 | @Override 26 | public void configure(Binder binder) { 27 | this.components.keySet().forEach(clazz -> { 28 | Component component = this.components.get(clazz); 29 | if (!component.parent().equals(Object.class)) { 30 | AnnotatedBindingBuilder bindingBuilder = binder 31 | .withSource(clazz) 32 | .bind(component.parent()); 33 | if (isPrivate()) { 34 | bindingBuilder.annotatedWith(getClass().getAnnotation(Private.class)); 35 | } 36 | bindingBuilder.to(clazz).in(Scopes.SINGLETON); 37 | } else { 38 | AnnotatedBindingBuilder bindingBuilder = binder.withSource(clazz).bind(clazz); 39 | if (isPrivate()) { 40 | bindingBuilder.annotatedWith(getClass().getAnnotation(Private.class)); 41 | } 42 | bindingBuilder.in(Scopes.SINGLETON); 43 | } 44 | }); 45 | } 46 | 47 | public void intercept(@NonNull Injector injector) { 48 | this.components.keySet().forEach(clazz -> { 49 | Component component = this.components.get(clazz); 50 | ComponentInterceptor componentInterceptor = findAssignable(clazz); 51 | if (componentInterceptor != null) { 52 | if (component.parent().equals(Object.class)) { 53 | componentInterceptor.intercept(injector.getInstance(clazz)); 54 | } else { 55 | componentInterceptor.intercept(injector.getInstance(component.parent())); 56 | } 57 | } 58 | }); 59 | } 60 | 61 | @Nullable 62 | private ComponentInterceptor findAssignable(@NonNull Class clazz) { 63 | for (Entry, ComponentInterceptor> entry : this.interceptorMap.entrySet()) { 64 | if (entry.getKey().isAssignableFrom(clazz)) { 65 | return entry.getValue(); 66 | } 67 | } 68 | return null; 69 | } 70 | 71 | public Map components() { 72 | return this.components; 73 | } 74 | 75 | public void registerComponentInterceptor( 76 | Class clazz, 77 | ComponentInterceptor interceptor) { 78 | this.interceptorMap.put(clazz, interceptor); 79 | } 80 | 81 | public boolean isPrivate() { 82 | return getClass().isAnnotationPresent(Private.class); 83 | } 84 | 85 | } 86 | --------------------------------------------------------------------------------