├── .gitattributes ├── .gitignore ├── LICENSE ├── api ├── .gitignore └── build.gradle.kts ├── build.gradle.kts ├── bukkit-loader ├── .gitignore ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── momirealms │ │ └── sparrow │ │ └── bukkit │ │ └── loader │ │ └── BukkitLoaderPlugin.java │ └── resources │ └── plugin.yml ├── bukkit ├── .gitignore ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── momirealms │ │ └── sparrow │ │ └── bukkit │ │ ├── SparrowBukkitBootstrap.java │ │ ├── SparrowBukkitPlugin.java │ │ ├── SparrowBukkitSchedulerAdapter.java │ │ ├── SparrowBukkitSenderFactory.java │ │ ├── SparrowNMSProxy.java │ │ ├── command │ │ ├── BukkitCommandFeature.java │ │ ├── SparrowBukkitCommandManager.java │ │ ├── feature │ │ │ ├── container │ │ │ │ ├── AnvilAdminCommand.java │ │ │ │ ├── AnvilPlayerCommand.java │ │ │ │ ├── CartographyTableAdminCommand.java │ │ │ │ ├── CartographyTablePlayerCommand.java │ │ │ │ ├── EnchantmentTableAdminCommand.java │ │ │ │ ├── EnchantmentTablePlayerCommand.java │ │ │ │ ├── EnderChestAdminCommand.java │ │ │ │ ├── EnderChestPlayerCommand.java │ │ │ │ ├── GrindStoneAdminCommand.java │ │ │ │ ├── GrindStonePlayerCommand.java │ │ │ │ ├── LoomAdminCommand.java │ │ │ │ ├── LoomPlayerCommand.java │ │ │ │ ├── SmithingTableAdminCommand.java │ │ │ │ ├── SmithingTablePlayerCommand.java │ │ │ │ ├── StoneCutterAdminCommand.java │ │ │ │ ├── StoneCutterPlayerCommand.java │ │ │ │ ├── WorkbenchAdminCommand.java │ │ │ │ └── WorkbenchPlayerCommand.java │ │ │ ├── entity │ │ │ │ ├── BurnAdminCommand.java │ │ │ │ ├── ExtinguishAdminCommand.java │ │ │ │ ├── HealAdminCommand.java │ │ │ │ └── HealPlayerCommand.java │ │ │ ├── internal │ │ │ │ └── ReloadAdminCommand.java │ │ │ ├── item │ │ │ │ ├── ColorPlayerCommand.java │ │ │ │ ├── DyeAdminCommand.java │ │ │ │ ├── DyePlayerCommand.java │ │ │ │ ├── EnchantAdminCommand.java │ │ │ │ ├── HeadAdminCommand.java │ │ │ │ ├── HeadPlayerCommand.java │ │ │ │ ├── ItemDataPlayerCommand.java │ │ │ │ ├── MoreAdminCommand.java │ │ │ │ ├── MorePlayerCommand.java │ │ │ │ ├── URLHeadAdminCommand.java │ │ │ │ └── editor │ │ │ │ │ ├── ItemCustomModelDataPlayerCommand.java │ │ │ │ │ ├── ItemDisplayNamePlayerCommand.java │ │ │ │ │ └── ItemLorePlayerCommand.java │ │ │ ├── message │ │ │ │ ├── ActionBarAdminCommand.java │ │ │ │ ├── BroadcastAdminCommand.java │ │ │ │ ├── TitleAdminCommand.java │ │ │ │ └── ToastAdminCommand.java │ │ │ ├── misc │ │ │ │ ├── CreditsAdminCommand.java │ │ │ │ ├── CreditsPlayerCommand.java │ │ │ │ ├── DemoAdminCommand.java │ │ │ │ ├── DemoPlayerCommand.java │ │ │ │ ├── ServerAdminCommand.java │ │ │ │ ├── ServerPlayerCommand.java │ │ │ │ └── TotemAdminCommand.java │ │ │ ├── player │ │ │ │ ├── FeedAdminCommand.java │ │ │ │ ├── FeedPlayerCommand.java │ │ │ │ ├── FlyAdminCommand.java │ │ │ │ ├── FlyPlayerCommand.java │ │ │ │ ├── FlySpeedAdminCommand.java │ │ │ │ ├── FlySpeedPlayerCommand.java │ │ │ │ ├── LookAdminCommand.java │ │ │ │ ├── LookPlayerCommand.java │ │ │ │ ├── PatrolAdminCommand.java │ │ │ │ ├── SudoAdminCommand.java │ │ │ │ ├── SuicidePlayerCommand.java │ │ │ │ ├── TpOfflineAdminCommand.java │ │ │ │ ├── TpOfflinePlayerCommand.java │ │ │ │ ├── WalkSpeedAdminCommand.java │ │ │ │ └── WalkSpeedPlayerCommand.java │ │ │ └── world │ │ │ │ ├── DistancePlayerCommand.java │ │ │ │ ├── HighlightAdminCommand.java │ │ │ │ ├── HighlightPlayerCommand.java │ │ │ │ ├── TopBlockAdminCommand.java │ │ │ │ ├── TopBlockPlayerCommand.java │ │ │ │ ├── WorldAdminCommand.java │ │ │ │ └── WorldPlayerCommand.java │ │ ├── key │ │ │ └── SparrowBukkitArgumentKeys.java │ │ ├── parser │ │ │ ├── BackendServerParser.java │ │ │ └── HeavyOfflinePlayerParser.java │ │ └── processor │ │ │ └── SelectorPostProcessor.java │ │ ├── feature │ │ ├── enchant │ │ │ └── SparrowBukkitEnchantManager.java │ │ ├── item │ │ │ ├── SparrowBukkitItemFactory.java │ │ │ └── impl │ │ │ │ ├── ComponentItemFactory.java │ │ │ │ └── UniversalItemFactory.java │ │ ├── patrol │ │ │ └── SparrowBukkitPatrolManager.java │ │ ├── proxy │ │ │ └── SparrowBukkitBungeeManager.java │ │ └── skull │ │ │ ├── SparrowBukkitSkullManager.java │ │ │ └── fetcher │ │ │ ├── OnlinePlayerFetcher.java │ │ │ └── OnlinePlayerFetcherProvider.java │ │ ├── user │ │ ├── BukkitOfflineUser.java │ │ ├── BukkitOnlineUser.java │ │ └── BukkitUserManager.java │ │ └── util │ │ ├── EntityUtils.java │ │ ├── ItemStackUtils.java │ │ ├── LocationUtils.java │ │ ├── PlaceholderUtils.java │ │ ├── PlayerUtils.java │ │ └── PluginUtils.java │ └── resources │ └── commands.yml ├── common ├── .gitignore ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── momirealms │ │ └── sparrow │ │ └── common │ │ ├── command │ │ ├── AbstractCommandFeature.java │ │ ├── AbstractSparrowCommandManager.java │ │ ├── CommandBuilder.java │ │ ├── CommandConfig.java │ │ ├── CommandFeature.java │ │ ├── SparrowCommandManager.java │ │ ├── key │ │ │ ├── SparrowArgumentKeys.java │ │ │ ├── SparrowFlagKeys.java │ │ │ └── SparrowMetaKeys.java │ │ └── parser │ │ │ ├── NamedTextColorParser.java │ │ │ ├── TimeParser.java │ │ │ └── URLParser.java │ │ ├── config │ │ ├── ConfigManager.java │ │ └── ConfigManagerImpl.java │ │ ├── dependency │ │ ├── Dependency.java │ │ ├── DependencyDownloadException.java │ │ ├── DependencyManager.java │ │ ├── DependencyManagerImpl.java │ │ ├── DependencyProperties.java │ │ ├── DependencyRegistry.java │ │ ├── DependencyRepository.java │ │ ├── classloader │ │ │ └── IsolatedClassLoader.java │ │ └── relocation │ │ │ ├── Relocation.java │ │ │ ├── RelocationHandler.java │ │ │ └── RelocationHelper.java │ │ ├── event │ │ ├── Cancellable.java │ │ ├── EventConfig.java │ │ ├── EventConfigImpl.java │ │ ├── EventConsumer.java │ │ ├── EventManager.java │ │ ├── EventManagerImpl.java │ │ ├── EventSubscriber.java │ │ ├── EventSubscription.java │ │ ├── Param.java │ │ ├── SparrowEvent.java │ │ ├── bus │ │ │ ├── EventBus.java │ │ │ └── SimpleEventBus.java │ │ ├── gen │ │ │ ├── AbstractSparrowEvent.java │ │ │ └── EventGenerator.java │ │ ├── registry │ │ │ ├── EventRegistry.java │ │ │ ├── Internals.java │ │ │ └── SimpleEventRegistry.java │ │ └── type │ │ │ └── CommandFeedbackEvent.java │ │ ├── feature │ │ ├── enchant │ │ │ └── EnchantManager.java │ │ ├── item │ │ │ ├── AbstractItem.java │ │ │ ├── ComponentKeys.java │ │ │ ├── ItemFactory.java │ │ │ └── SparrowItem.java │ │ ├── patrol │ │ │ ├── PatrolManager.java │ │ │ └── Patrolable.java │ │ ├── skull │ │ │ ├── AbstractSkullManager.java │ │ │ ├── SkullData.java │ │ │ ├── SkullDataImpl.java │ │ │ ├── SkullFetchException.java │ │ │ ├── SkullManager.java │ │ │ ├── argument │ │ │ │ ├── NameSkullArgument.java │ │ │ │ ├── SkullArgument.java │ │ │ │ ├── URLSkullArgument.java │ │ │ │ └── UUIDSkullArgument.java │ │ │ ├── fetcher │ │ │ │ ├── FetcherProviderRegistry.java │ │ │ │ ├── FetcherProviderRegistryImpl.java │ │ │ │ ├── SkullFetcher.java │ │ │ │ ├── impl │ │ │ │ │ ├── APIFetcher.java │ │ │ │ │ └── MineskinFetcher.java │ │ │ │ └── provider │ │ │ │ │ ├── APIFetcherProvider.java │ │ │ │ │ ├── FetcherProvider.java │ │ │ │ │ └── MineSkinFetcherProvider.java │ │ │ └── mineskin │ │ │ │ ├── MineskinClient.java │ │ │ │ ├── SkinOptions.java │ │ │ │ ├── Variant.java │ │ │ │ ├── Visibility.java │ │ │ │ └── data │ │ │ │ ├── DelayInfo.java │ │ │ │ ├── MineskinException.java │ │ │ │ ├── Skin.java │ │ │ │ ├── SkinData.java │ │ │ │ └── Texture.java │ │ └── toast │ │ │ └── AdvancementType.java │ │ ├── helper │ │ ├── AdventureHelper.java │ │ └── GsonHelper.java │ │ ├── locale │ │ ├── MessageConstants.java │ │ ├── MiniMessageTranslationRegistry.java │ │ ├── MiniMessageTranslationRegistryImpl.java │ │ ├── MiniMessageTranslator.java │ │ ├── MiniMessageTranslatorImpl.java │ │ ├── SparrowCaptionFormatter.java │ │ ├── SparrowCaptionKeys.java │ │ ├── SparrowCaptionProvider.java │ │ └── TranslationManager.java │ │ ├── plugin │ │ ├── AbstractSparrowPlugin.java │ │ ├── Platform.java │ │ ├── SparrowPlugin.java │ │ ├── bootstrap │ │ │ ├── BootstrappedWithLoader.java │ │ │ └── SparrowBootstrap.java │ │ ├── classpath │ │ │ ├── ClassPathAppender.java │ │ │ ├── JarInJarClassPathAppender.java │ │ │ ├── ReflectionClassPathAppender.java │ │ │ └── URLClassLoaderAccess.java │ │ ├── logging │ │ │ ├── JavaPluginLogger.java │ │ │ ├── Log4jPluginLogger.java │ │ │ ├── PluginLogger.java │ │ │ └── Slf4jPluginLogger.java │ │ └── scheduler │ │ │ ├── AbstractJavaScheduler.java │ │ │ ├── RegionExecutor.java │ │ │ ├── SchedulerAdapter.java │ │ │ └── SchedulerTask.java │ │ ├── script │ │ └── exception │ │ │ └── ScriptReaderException.java │ │ ├── sender │ │ ├── AbstractSender.java │ │ ├── DummyConsoleSender.java │ │ ├── Sender.java │ │ └── SenderFactory.java │ │ ├── storage │ │ ├── StorageFactory.java │ │ ├── StorageType.java │ │ └── impl │ │ │ └── StorageInterface.java │ │ ├── user │ │ ├── User.java │ │ └── UserManager.java │ │ └── util │ │ ├── ArrayUtils.java │ │ ├── Commons.java │ │ ├── Either.java │ │ ├── EitherImpl.java │ │ ├── FileUtils.java │ │ ├── Location.java │ │ ├── MapUtils.java │ │ ├── NetWorkUtils.java │ │ ├── Pair.java │ │ ├── RandomUtils.java │ │ ├── ThrowableFunction.java │ │ ├── Tristate.java │ │ ├── Tuple.java │ │ └── UUIDUtils.java │ └── resources │ ├── config.yml │ ├── library-version.properties │ └── translations │ ├── en.yml │ └── zh_cn.yml ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── loader ├── .gitignore ├── build.gradle.kts └── src │ └── main │ └── java │ └── net │ └── momirealms │ └── sparrow │ └── loader │ ├── JarInJarClassLoader.java │ ├── LoaderBootstrap.java │ └── LoadingException.java └── settings.gradle.kts /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | 26 | .idea 27 | .gradle 28 | .vscode 29 | build -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 XiaoMoMi 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 | -------------------------------------------------------------------------------- /api/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | java { 2 | sourceCompatibility = JavaVersion.VERSION_17 3 | targetCompatibility = JavaVersion.VERSION_17 4 | toolchain { 5 | languageVersion = JavaLanguageVersion.of(17) 6 | } 7 | } 8 | 9 | tasks.withType { 10 | options.encoding = "UTF-8" 11 | options.release.set(17) 12 | dependsOn(tasks.clean) 13 | } -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import java.io.ByteArrayOutputStream 2 | 3 | plugins { 4 | id("java") 5 | } 6 | 7 | val commitID : String = versionBanner() 8 | ext["commitID"] = commitID 9 | 10 | subprojects { 11 | 12 | apply(plugin = "java") 13 | apply(plugin = "java-library") 14 | 15 | repositories { 16 | mavenCentral() 17 | } 18 | 19 | tasks.processResources { 20 | filteringCharset = "UTF-8" 21 | 22 | filesMatching(arrayListOf("library-version.properties")) { 23 | expand(rootProject.properties) 24 | } 25 | 26 | filesMatching(arrayListOf("plugin.yml", "*.yml", "*/*.yml")) { 27 | expand( 28 | Pair("git_version", commitID), 29 | Pair("project_version", rootProject.properties["project_version"]), 30 | Pair("config_version", rootProject.properties["config_version"]) 31 | ) 32 | } 33 | } 34 | } 35 | 36 | fun versionBanner(): String { 37 | val os = ByteArrayOutputStream() 38 | project.exec { 39 | commandLine = "git rev-parse --short=8 HEAD".split(" ") 40 | standardOutput = os 41 | } 42 | return String(os.toByteArray()).trim() 43 | } -------------------------------------------------------------------------------- /bukkit-loader/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /bukkit-loader/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val commitID: String by project 2 | 3 | plugins { 4 | id("io.github.goooler.shadow") version "8.1.7" 5 | } 6 | 7 | repositories { 8 | mavenCentral() 9 | maven("https://repo.papermc.io/repository/maven-public/") 10 | maven("https://jitpack.io/") 11 | } 12 | 13 | dependencies { 14 | implementation(project(":loader")) 15 | implementation(project(":common")) 16 | implementation(project(":bukkit")) 17 | 18 | compileOnly("io.papermc.paper:paper-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT") 19 | } 20 | 21 | tasks { 22 | shadowJar { 23 | archiveFileName = "Sparrow-Bukkit-${rootProject.properties["project_version"]}-${commitID}.jar" 24 | destinationDirectory.set(file("$rootDir/target")) 25 | relocate("net.kyori", "net.momirealms.sparrow.libraries") 26 | relocate("org.incendo", "net.momirealms.sparrow.libraries") 27 | relocate("dev.dejvokep", "net.momirealms.sparrow.libraries") 28 | relocate("net.bytebuddy", "net.momirealms.sparrow.libraries.bytebuddy") 29 | relocate ("org.apache.commons.pool2", "net.momirealms.sparrow.libraries.commonspool2") 30 | relocate ("com.mysql", "net.momirealms.sparrow.libraries.mysql") 31 | relocate ("org.mariadb", "net.momirealms.sparrow.libraries.mariadb") 32 | relocate ("com.zaxxer.hikari", "net.momirealms.sparrow.libraries.hikari") 33 | relocate ("com.mongodb", "net.momirealms.sparrow.libraries.mongodb") 34 | relocate ("org.bson", "net.momirealms.sparrow.libraries.bson") 35 | relocate ("org.bstats", "net.momirealms.sparrow.libraries.bstats") 36 | relocate ("io.lettuce", "net.momirealms.sparrow.libraries.lettuce") 37 | relocate ("io.leangen.geantyref", "net.momirealms.sparrow.libraries.geantyref") 38 | relocate ("com.github.benmanes.caffeine", "net.momirealms.sparrow.libraries.caffeine") 39 | relocate ("net.momirealms.sparrow.heart", "net.momirealms.sparrow.bukkit.nms") 40 | relocate ("com.saicone.rtag", "net.momirealms.sparrow.libraries.rtag") 41 | } 42 | } 43 | 44 | artifacts { 45 | archives(tasks.shadowJar) 46 | } 47 | 48 | java { 49 | sourceCompatibility = JavaVersion.VERSION_17 50 | targetCompatibility = JavaVersion.VERSION_17 51 | toolchain { 52 | languageVersion = JavaLanguageVersion.of(17) 53 | } 54 | } 55 | 56 | tasks.withType { 57 | options.encoding = "UTF-8" 58 | options.release.set(17) 59 | dependsOn(tasks.clean) 60 | } -------------------------------------------------------------------------------- /bukkit-loader/src/main/java/net/momirealms/sparrow/bukkit/loader/BukkitLoaderPlugin.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.loader; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowBukkitBootstrap; 4 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 5 | import net.momirealms.sparrow.loader.JarInJarClassLoader; 6 | import net.momirealms.sparrow.loader.LoaderBootstrap; 7 | import org.bukkit.plugin.java.JavaPlugin; 8 | 9 | public class BukkitLoaderPlugin extends JavaPlugin { 10 | 11 | private final LoaderBootstrap plugin; 12 | 13 | public BukkitLoaderPlugin() { 14 | plugin = new SparrowBukkitBootstrap(this); 15 | } 16 | 17 | @Override 18 | public void onLoad() { 19 | this.plugin.onLoad(); 20 | } 21 | 22 | @Override 23 | public void onEnable() { 24 | this.plugin.onEnable(); 25 | } 26 | 27 | @Override 28 | public void onDisable() { 29 | this.plugin.onDisable(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit-loader/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Sparrow 2 | main: net.momirealms.sparrow.bukkit.loader.BukkitLoaderPlugin 3 | version: ${project_version} 4 | author: XiaoMoMi 5 | contributors: 6 | - g2213swo 7 | - jhqwqmc 8 | softdepend: 9 | - PlaceholderAPI 10 | api-version: 1.18 11 | folia-supported: true -------------------------------------------------------------------------------- /bukkit/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /bukkit/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("io.github.goooler.shadow") version "8.1.7" 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven("https://repo.papermc.io/repository/maven-public/") 8 | maven("https://oss.sonatype.org/content/repositories/snapshots/") 9 | maven("https://repo.xenondevs.xyz/releases/") 10 | maven("https://libraries.minecraft.net/") 11 | maven("https://repo.codemc.io/repository/maven-public/") 12 | maven("https://jitpack.io/") 13 | maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") 14 | } 15 | 16 | dependencies { 17 | implementation(project(":common")) 18 | compileOnly(project(":loader")) 19 | 20 | implementation("com.github.Xiao-MoMi:Sparrow-Heart:${rootProject.properties["sparrow_heart_version"]}") 21 | implementation("net.kyori:adventure-platform-bukkit:${rootProject.properties["adventure_platform_version"]}") 22 | implementation("net.kyori:adventure-text-minimessage:${rootProject.properties["adventure_bundle_version"]}") 23 | implementation("com.saicone.rtag:rtag:${rootProject.properties["rtag_version"]}") 24 | implementation("com.saicone.rtag:rtag-item:${rootProject.properties["rtag_version"]}") 25 | 26 | compileOnly("org.incendo:cloud-core:${rootProject.properties["cloud_core_version"]}") 27 | compileOnly("org.incendo:cloud-minecraft-extras:${rootProject.properties["cloud_minecraft_extras_version"]}") 28 | compileOnly("org.incendo:cloud-paper:${rootProject.properties["cloud_paper_version"]}") 29 | compileOnly("dev.dejvokep:boosted-yaml:${rootProject.properties["boosted_yaml_version"]}") 30 | compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT") 31 | compileOnly("com.mojang:brigadier:${rootProject.properties["mojang_brigadier_version"]}") 32 | compileOnly("org.bstats:bstats-bukkit:${rootProject.properties["bstats_version"]}") 33 | compileOnly("me.clip:placeholderapi:${rootProject.properties["placeholder_api_version"]}") 34 | } 35 | 36 | artifacts { 37 | archives(tasks.shadowJar) 38 | } 39 | 40 | java { 41 | sourceCompatibility = JavaVersion.VERSION_17 42 | targetCompatibility = JavaVersion.VERSION_17 43 | toolchain { 44 | languageVersion = JavaLanguageVersion.of(17) 45 | } 46 | } 47 | 48 | tasks.withType { 49 | options.encoding = "UTF-8" 50 | options.release.set(17) 51 | dependsOn(tasks.clean) 52 | } -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/SparrowBukkitSchedulerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.bukkit; 27 | 28 | import net.momirealms.sparrow.common.plugin.scheduler.AbstractJavaScheduler; 29 | import net.momirealms.sparrow.common.plugin.scheduler.RegionExecutor; 30 | import org.bukkit.Location; 31 | 32 | public class SparrowBukkitSchedulerAdapter extends AbstractJavaScheduler { 33 | protected RegionExecutor sync; 34 | 35 | public SparrowBukkitSchedulerAdapter(SparrowBukkitBootstrap bootstrap, RegionExecutor executor) { 36 | super(bootstrap); 37 | this.sync = executor; 38 | } 39 | 40 | @Override 41 | public RegionExecutor sync() { 42 | return this.sync; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/BukkitCommandFeature.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.TranslatableComponent; 5 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 6 | import net.momirealms.sparrow.common.command.AbstractCommandFeature; 7 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 8 | import net.momirealms.sparrow.common.sender.SenderFactory; 9 | import net.momirealms.sparrow.common.util.Pair; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Entity; 12 | import org.incendo.cloud.bukkit.data.Selector; 13 | 14 | import java.util.Collection; 15 | 16 | public abstract class BukkitCommandFeature extends AbstractCommandFeature { 17 | 18 | public BukkitCommandFeature(SparrowCommandManager sparrowCommandManager) { 19 | super(sparrowCommandManager); 20 | } 21 | 22 | @Override 23 | @SuppressWarnings("unchecked") 24 | protected SenderFactory getSenderFactory() { 25 | return (SenderFactory) SparrowBukkitPlugin.getInstance().getSenderFactory(); 26 | } 27 | 28 | public Pair resolveSelector(Selector selector, TranslatableComponent.Builder single, TranslatableComponent.Builder multiple) { 29 | Collection entities = selector.values(); 30 | if (entities.size() == 1) { 31 | return Pair.of(single, Component.text(entities.iterator().next().getName())); 32 | } else { 33 | return Pair.of(multiple, Component.text(entities.size())); 34 | } 35 | } 36 | 37 | public Pair resolveSelector(Collection selector, TranslatableComponent.Builder single, TranslatableComponent.Builder multiple) { 38 | if (selector.size() == 1) { 39 | return Pair.of(single, Component.text(selector.iterator().next().getName())); 40 | } else { 41 | return Pair.of(multiple, Component.text(selector.size())); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/AnvilPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class AnvilPlayerCommand extends BukkitCommandFeature { 12 | 13 | public AnvilPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "anvil_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openAnvil(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_ANVIL_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/CartographyTablePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class CartographyTablePlayerCommand extends BukkitCommandFeature { 12 | 13 | public CartographyTablePlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "cartographytable_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openCartographyTable(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_CARTOGRAPHY_TABLE_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/EnchantmentTablePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.feature.enchant.EnchantManager; 7 | import net.momirealms.sparrow.common.locale.MessageConstants; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | import org.incendo.cloud.Command; 11 | import org.incendo.cloud.CommandManager; 12 | import org.incendo.cloud.parser.standard.IntegerParser; 13 | import org.incendo.cloud.permission.Permission; 14 | 15 | public class EnchantmentTablePlayerCommand extends BukkitCommandFeature { 16 | 17 | public EnchantmentTablePlayerCommand(SparrowCommandManager sparrowCommandManager) { 18 | super(sparrowCommandManager); 19 | } 20 | 21 | @Override 22 | public String getFeatureID() { 23 | return "enchantmenttable_player"; 24 | } 25 | 26 | @Override 27 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 28 | return builder 29 | .senderType(Player.class) 30 | .flag(manager.flagBuilder("shelves").withComponent(IntegerParser.integerParser(0)).withPermission(Permission.permission(EnchantManager.SHELVES_FLAG_PERMISSION)).build()) 31 | .handler(commandContext -> { 32 | boolean customShelves = commandContext.flags().hasFlag("shelves"); 33 | final Player player = commandContext.sender(); 34 | SparrowBukkitPlugin.getInstance().getEnchantManager().openEnchantmentTable(player, customShelves ? (int) commandContext.flags().getValue("shelves").get() : 0); 35 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_ENCHANTMENT_TABLE_SUCCESS); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/EnderChestPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.SparrowNMSProxy; 5 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.helper.AdventureHelper; 8 | import net.momirealms.sparrow.common.locale.MessageConstants; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.entity.Player; 11 | import org.incendo.cloud.Command; 12 | import org.incendo.cloud.CommandManager; 13 | 14 | public class EnderChestPlayerCommand extends BukkitCommandFeature { 15 | 16 | public EnderChestPlayerCommand(SparrowCommandManager sparrowCommandManager) { 17 | super(sparrowCommandManager); 18 | } 19 | 20 | @Override 21 | public String getFeatureID() { 22 | return "enderchest_player"; 23 | } 24 | 25 | @Override 26 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 27 | return builder 28 | .senderType(Player.class) 29 | .handler(commandContext -> { 30 | final Player player = commandContext.sender(); 31 | SparrowNMSProxy.getInstance().openCustomInventory(player, player.getEnderChest(), AdventureHelper.componentToJson(Component.translatable("container.enderchest"))); 32 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_ENDER_CHEST_SUCCESS); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/GrindStonePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class GrindStonePlayerCommand extends BukkitCommandFeature { 12 | 13 | public GrindStonePlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "grindstone_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openGrindstone(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_GRINDSTONE_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/LoomPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class LoomPlayerCommand extends BukkitCommandFeature { 12 | 13 | public LoomPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "loom_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openLoom(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_LOOM_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/SmithingTablePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class SmithingTablePlayerCommand extends BukkitCommandFeature { 12 | 13 | public SmithingTablePlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "smithingtable_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openSmithingTable(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_SMITHING_TABLE_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/StoneCutterPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class StoneCutterPlayerCommand extends BukkitCommandFeature { 12 | 13 | public StoneCutterPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "stonecutter_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openStonecutter(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_STONE_CUTTER_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/container/WorkbenchPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.container; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class WorkbenchPlayerCommand extends BukkitCommandFeature { 12 | 13 | public WorkbenchPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "workbench_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().openWorkbench(null, true); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_WORKBENCH_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/entity/ExtinguishAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.entity; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 7 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 8 | import net.momirealms.sparrow.common.locale.MessageConstants; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.entity.Entity; 11 | import org.incendo.cloud.Command; 12 | import org.incendo.cloud.CommandManager; 13 | import org.incendo.cloud.bukkit.data.Selector; 14 | import org.incendo.cloud.bukkit.parser.selector.MultipleEntitySelectorParser; 15 | 16 | public class ExtinguishAdminCommand extends BukkitCommandFeature { 17 | 18 | public ExtinguishAdminCommand(SparrowCommandManager sparrowCommandManager) { 19 | super(sparrowCommandManager); 20 | } 21 | 22 | @Override 23 | public String getFeatureID() { 24 | return "extinguish_admin"; 25 | } 26 | 27 | @Override 28 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 29 | return builder 30 | .required(SparrowBukkitArgumentKeys.ENTITY_SELECTOR, MultipleEntitySelectorParser.multipleEntitySelectorParser()) 31 | .meta(SparrowMetaKeys.ALLOW_EMPTY_ENTITY_SELECTOR, false) 32 | .flag(SparrowFlagKeys.SILENT_FLAG) 33 | .handler(commandContext -> { 34 | Selector selector = commandContext.get(SparrowBukkitArgumentKeys.ENTITY_SELECTOR); 35 | var entities = selector.values(); 36 | for (Entity entity : entities) { 37 | entity.setFireTicks(0); 38 | } 39 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_EXTINGUISH_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_EXTINGUISH_SUCCESS_MULTIPLE); 40 | handleFeedback(commandContext, pair.left(), pair.right()); 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/entity/HealAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.entity; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 5 | import net.momirealms.sparrow.bukkit.util.EntityUtils; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Entity; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.Selector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultipleEntitySelectorParser; 16 | 17 | public class HealAdminCommand extends BukkitCommandFeature { 18 | 19 | public HealAdminCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "heal_admin"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .required(SparrowBukkitArgumentKeys.ENTITY_SELECTOR, MultipleEntitySelectorParser.multipleEntitySelectorParser()) 32 | .meta(SparrowMetaKeys.ALLOW_EMPTY_ENTITY_SELECTOR, false) 33 | .flag(SparrowFlagKeys.SILENT_FLAG) 34 | .handler(commandContext -> { 35 | Selector selector = commandContext.get(SparrowBukkitArgumentKeys.ENTITY_SELECTOR); 36 | var entities = selector.values(); 37 | for (Entity entity : entities) { 38 | EntityUtils.heal(entity); 39 | } 40 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_HEAL_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_HEAL_SUCCESS_MULTIPLE); 41 | handleFeedback(commandContext, pair.left(), pair.right()); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/entity/HealPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.entity; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.util.EntityUtils; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | 12 | public class HealPlayerCommand extends BukkitCommandFeature { 13 | 14 | public HealPlayerCommand(SparrowCommandManager sparrowCommandManager) { 15 | super(sparrowCommandManager); 16 | } 17 | 18 | @Override 19 | public String getFeatureID() { 20 | return "heal_player"; 21 | } 22 | 23 | @Override 24 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 25 | return builder 26 | .senderType(Player.class) 27 | .handler(commandContext -> { 28 | EntityUtils.heal(commandContext.sender()); 29 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_HEAL_SUCCESS); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/internal/ReloadAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.internal; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 5 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.locale.MessageConstants; 9 | import org.bukkit.command.CommandSender; 10 | import org.incendo.cloud.Command; 11 | import org.incendo.cloud.CommandManager; 12 | 13 | public class ReloadAdminCommand extends BukkitCommandFeature { 14 | 15 | public ReloadAdminCommand(SparrowCommandManager sparrowCommandManager) { 16 | super(sparrowCommandManager); 17 | } 18 | 19 | @Override 20 | public String getFeatureID() { 21 | return "reload_admin"; 22 | } 23 | 24 | @Override 25 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 26 | return builder 27 | .flag(SparrowFlagKeys.SILENT_FLAG) 28 | .handler(commandContext -> { 29 | long time1 = System.currentTimeMillis(); 30 | SparrowBukkitPlugin.getInstance().reload(); 31 | String timeTook = String.valueOf(System.currentTimeMillis() - time1); 32 | handleFeedback(commandContext, MessageConstants.COMMANDS_ADMIN_RELOAD_SUCCESS, Component.text(timeTook)); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/misc/CreditsAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.misc; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowNMSProxy; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 16 | 17 | public class CreditsAdminCommand extends BukkitCommandFeature { 18 | 19 | public CreditsAdminCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "credits_admin"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 32 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 33 | .flag(SparrowFlagKeys.SILENT_FLAG) 34 | .handler(commandContext -> { 35 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 36 | var players = selector.values(); 37 | for (Player player : players) { 38 | SparrowNMSProxy.getInstance().sendCredits(player); 39 | } 40 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_CREDITS_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_CREDITS_SUCCESS_MULTIPLE); 41 | handleFeedback(commandContext, pair.left(), pair.right()); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/misc/CreditsPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.misc; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowNMSProxy; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | 12 | public class CreditsPlayerCommand extends BukkitCommandFeature { 13 | 14 | public CreditsPlayerCommand(SparrowCommandManager sparrowCommandManager) { 15 | super(sparrowCommandManager); 16 | } 17 | 18 | @Override 19 | public String getFeatureID() { 20 | return "credits_player"; 21 | } 22 | 23 | @Override 24 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 25 | return builder 26 | .senderType(Player.class) 27 | .handler(commandContext -> { 28 | SparrowNMSProxy.getInstance().sendCredits(commandContext.sender()); 29 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_CREDITS_SUCCESS); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/misc/DemoAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.misc; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowNMSProxy; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 16 | 17 | public class DemoAdminCommand extends BukkitCommandFeature { 18 | 19 | public DemoAdminCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "demo_admin"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 32 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 33 | .flag(SparrowFlagKeys.SILENT_FLAG) 34 | .handler(commandContext -> { 35 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 36 | var players = selector.values(); 37 | for (Player player : players) { 38 | SparrowNMSProxy.getInstance().sendDemo(player); 39 | } 40 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_DEMO_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_DEMO_SUCCESS_MULTIPLE); 41 | handleFeedback(commandContext, pair.left(), pair.right()); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/misc/DemoPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.misc; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowNMSProxy; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | 12 | public class DemoPlayerCommand extends BukkitCommandFeature { 13 | 14 | public DemoPlayerCommand(SparrowCommandManager sparrowCommandManager) { 15 | super(sparrowCommandManager); 16 | } 17 | 18 | @Override 19 | public String getFeatureID() { 20 | return "demo_player"; 21 | } 22 | 23 | @Override 24 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 25 | return builder 26 | .senderType(Player.class) 27 | .handler(commandContext -> { 28 | SparrowNMSProxy.getInstance().sendDemo(commandContext.sender()); 29 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_DEMO_SUCCESS); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/misc/ServerPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.misc; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 5 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.locale.MessageConstants; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | import org.incendo.cloud.Command; 11 | import org.incendo.cloud.CommandManager; 12 | import org.incendo.cloud.parser.standard.StringParser; 13 | 14 | public class ServerPlayerCommand extends BukkitCommandFeature { 15 | 16 | public ServerPlayerCommand(SparrowCommandManager sparrowCommandManager) { 17 | super(sparrowCommandManager); 18 | } 19 | 20 | @Override 21 | public String getFeatureID() { 22 | return "server_player"; 23 | } 24 | 25 | @Override 26 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 27 | return builder 28 | .senderType(Player.class) 29 | .required("server", StringParser.stringParser()) 30 | .handler(commandContext -> { 31 | String server = commandContext.get("server"); 32 | SparrowBukkitPlugin.getInstance().getBungeeManager().connectServer(commandContext.sender(), server); 33 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_SERVER_SUCCESS, Component.text(server)); 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/FeedAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 7 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 8 | import net.momirealms.sparrow.common.locale.MessageConstants; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.entity.Player; 11 | import org.incendo.cloud.Command; 12 | import org.incendo.cloud.CommandManager; 13 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 14 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 15 | 16 | public class FeedAdminCommand extends BukkitCommandFeature { 17 | 18 | public FeedAdminCommand(SparrowCommandManager sparrowCommandManager) { 19 | super(sparrowCommandManager); 20 | } 21 | 22 | @Override 23 | public String getFeatureID() { 24 | return "feed_admin"; 25 | } 26 | 27 | @Override 28 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 29 | return builder 30 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 31 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 32 | .flag(SparrowFlagKeys.SILENT_FLAG) 33 | .handler(commandContext -> { 34 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 35 | var players = selector.values(); 36 | for (Player player : players) { 37 | player.setFoodLevel(20); 38 | player.setSaturation(10f); 39 | } 40 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_FEED_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_FEED_SUCCESS_MULTIPLE); 41 | handleFeedback(commandContext, pair.left(), pair.right()); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/FeedPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class FeedPlayerCommand extends BukkitCommandFeature { 12 | 13 | public FeedPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "feed_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | final Player player = commandContext.sender(); 28 | player.setFoodLevel(20); 29 | player.setSaturation(10f); 30 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_FEED_SUCCESS); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/FlyPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class FlyPlayerCommand extends BukkitCommandFeature { 12 | 13 | public FlyPlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "fly_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | final Player player = commandContext.sender(); 28 | if (player.getAllowFlight()) { 29 | player.setFlying(false); 30 | player.setAllowFlight(false); 31 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_FLY_SUCCESS_OFF); 32 | } else { 33 | player.setAllowFlight(true); 34 | player.setFlying(true); 35 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_FLY_SUCCESS_ON); 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/FlySpeedAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 16 | import org.incendo.cloud.parser.standard.FloatParser; 17 | 18 | public class FlySpeedAdminCommand extends BukkitCommandFeature { 19 | 20 | public FlySpeedAdminCommand(SparrowCommandManager sparrowCommandManager) { 21 | super(sparrowCommandManager); 22 | } 23 | 24 | @Override 25 | public String getFeatureID() { 26 | return "flyspeed_admin"; 27 | } 28 | 29 | @Override 30 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 31 | return builder 32 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 33 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 34 | .required("speed", FloatParser.floatParser(-1, 1)) 35 | .flag(SparrowFlagKeys.SILENT_FLAG) 36 | .handler(commandContext -> { 37 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 38 | float speed = commandContext.get("speed"); 39 | var players = selector.values(); 40 | for (Player player : players) { 41 | player.setFlySpeed(speed); 42 | } 43 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_FLY_SPEED_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_FLY_SPEED_SUCCESS_MULTIPLE); 44 | handleFeedback(commandContext, pair.left(), pair.right(), Component.text(speed)); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/FlySpeedPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | import org.incendo.cloud.parser.standard.FloatParser; 12 | 13 | public class FlySpeedPlayerCommand extends BukkitCommandFeature { 14 | 15 | public FlySpeedPlayerCommand(SparrowCommandManager sparrowCommandManager) { 16 | super(sparrowCommandManager); 17 | } 18 | 19 | @Override 20 | public String getFeatureID() { 21 | return "flyspeed_player"; 22 | } 23 | 24 | @Override 25 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 26 | return builder 27 | .senderType(Player.class) 28 | .required("speed", FloatParser.floatParser(-1, 1)) 29 | .handler(commandContext -> { 30 | float speed = commandContext.get("speed"); 31 | commandContext.sender().setFlySpeed(speed); 32 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_FLY_SPEED_SUCCESS, Component.text(speed)); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/SudoAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 7 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 8 | import net.momirealms.sparrow.common.locale.MessageConstants; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.entity.Player; 11 | import org.incendo.cloud.Command; 12 | import org.incendo.cloud.CommandManager; 13 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 14 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 15 | import org.incendo.cloud.parser.standard.StringParser; 16 | 17 | public class SudoAdminCommand extends BukkitCommandFeature { 18 | 19 | public SudoAdminCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "sudo_admin"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 32 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 33 | .required("command", StringParser.greedyFlagYieldingStringParser()) 34 | .flag(SparrowFlagKeys.SILENT_FLAG) 35 | .handler(commandContext -> { 36 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 37 | String command = commandContext.get("command"); 38 | var players = selector.values(); 39 | for (Player player : players) { 40 | player.performCommand(command); 41 | } 42 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_SUDO_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_SUDO_SUCCESS_MULTIPLE); 43 | handleFeedback(commandContext, pair.left(), pair.right()); 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/SuicidePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 5 | import net.momirealms.sparrow.common.locale.MessageConstants; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.entity.Player; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | 11 | public class SuicidePlayerCommand extends BukkitCommandFeature { 12 | 13 | public SuicidePlayerCommand(SparrowCommandManager sparrowCommandManager) { 14 | super(sparrowCommandManager); 15 | } 16 | 17 | @Override 18 | public String getFeatureID() { 19 | return "suicide_player"; 20 | } 21 | 22 | @Override 23 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 24 | return builder 25 | .senderType(Player.class) 26 | .handler(commandContext -> { 27 | commandContext.sender().setHealth(0); 28 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_SUICIDE_SUCCESS); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/TpOfflinePlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.OfflinePlayer; 9 | import org.bukkit.command.CommandSender; 10 | import org.bukkit.entity.Player; 11 | import org.incendo.cloud.Command; 12 | import org.incendo.cloud.CommandManager; 13 | import org.incendo.cloud.parser.standard.StringParser; 14 | 15 | import java.util.Optional; 16 | 17 | public class TpOfflinePlayerCommand extends BukkitCommandFeature { 18 | 19 | public TpOfflinePlayerCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "tpoffline_player"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .senderType(Player.class) 32 | .required("player", StringParser.stringParser()) 33 | .handler(commandContext -> { 34 | OfflinePlayer player = Bukkit.getOfflinePlayerIfCached(commandContext.get("player")); 35 | if (player == null || player.getLocation() == null) { 36 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_TP_OFFLINE_FAILED_NEVER_PLAYED, Component.text((String) commandContext.get("player"))); 37 | return; 38 | } 39 | 40 | commandContext.sender().teleport(player.getLocation()); 41 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_TP_OFFLINE_SUCCESS, Component.text(Optional.ofNullable(player.getName()).orElse(String.valueOf(player.getUniqueId())))); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/WalkSpeedAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultiplePlayerSelectorParser; 16 | import org.incendo.cloud.parser.standard.FloatParser; 17 | 18 | public class WalkSpeedAdminCommand extends BukkitCommandFeature { 19 | 20 | public WalkSpeedAdminCommand(SparrowCommandManager sparrowCommandManager) { 21 | super(sparrowCommandManager); 22 | } 23 | 24 | @Override 25 | public String getFeatureID() { 26 | return "walkspeed_admin"; 27 | } 28 | 29 | @Override 30 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 31 | return builder 32 | .required(SparrowBukkitArgumentKeys.PLAYER_SELECTOR, MultiplePlayerSelectorParser.multiplePlayerSelectorParser()) 33 | .meta(SparrowMetaKeys.ALLOW_EMPTY_PLAYER_SELECTOR, false) 34 | .required("speed", FloatParser.floatParser(-1, 1)) 35 | .flag(SparrowFlagKeys.SILENT_FLAG) 36 | .handler(commandContext -> { 37 | MultiplePlayerSelector selector = commandContext.get(SparrowBukkitArgumentKeys.PLAYER_SELECTOR); 38 | float speed = commandContext.get("speed"); 39 | var players = selector.values(); 40 | for (Player player : players) { 41 | player.setWalkSpeed(speed); 42 | } 43 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_WALK_SPEED_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_WALK_SPEED_SUCCESS_MULTIPLE); 44 | handleFeedback(commandContext, pair.left(), pair.right(), Component.text(speed)); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/player/WalkSpeedPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.player; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | import org.incendo.cloud.parser.standard.FloatParser; 12 | 13 | public class WalkSpeedPlayerCommand extends BukkitCommandFeature { 14 | 15 | public WalkSpeedPlayerCommand(SparrowCommandManager sparrowCommandManager) { 16 | super(sparrowCommandManager); 17 | } 18 | 19 | @Override 20 | public String getFeatureID() { 21 | return "walkspeed_player"; 22 | } 23 | 24 | @Override 25 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 26 | return builder 27 | .senderType(Player.class) 28 | .required("speed", FloatParser.floatParser(-1, 1)) 29 | .handler(commandContext -> { 30 | float speed = commandContext.get("speed"); 31 | commandContext.sender().setWalkSpeed(speed); 32 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_WALK_SPEED_SUCCESS, Component.text(speed)); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/world/TopBlockAdminCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.world; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.command.key.SparrowBukkitArgumentKeys; 5 | import net.momirealms.sparrow.bukkit.util.EntityUtils; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 8 | import net.momirealms.sparrow.common.command.key.SparrowMetaKeys; 9 | import net.momirealms.sparrow.common.locale.MessageConstants; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Entity; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.data.MultipleEntitySelector; 15 | import org.incendo.cloud.bukkit.parser.selector.MultipleEntitySelectorParser; 16 | 17 | public class TopBlockAdminCommand extends BukkitCommandFeature { 18 | 19 | public TopBlockAdminCommand(SparrowCommandManager sparrowCommandManager) { 20 | super(sparrowCommandManager); 21 | } 22 | 23 | @Override 24 | public String getFeatureID() { 25 | return "topblock_admin"; 26 | } 27 | 28 | @Override 29 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 30 | return builder 31 | .required(SparrowBukkitArgumentKeys.ENTITY_SELECTOR, MultipleEntitySelectorParser.multipleEntitySelectorParser()) 32 | .meta(SparrowMetaKeys.ALLOW_EMPTY_ENTITY_SELECTOR, false) 33 | .flag(SparrowFlagKeys.SILENT_FLAG) 34 | .handler(commandContext -> { 35 | MultipleEntitySelector selector = commandContext.get(SparrowBukkitArgumentKeys.ENTITY_SELECTOR); 36 | var entities = selector.values(); 37 | for (Entity entity : entities) { 38 | EntityUtils.toTopBlockPosition(entity); 39 | } 40 | var pair = resolveSelector(selector, MessageConstants.COMMANDS_ADMIN_TOP_BLOCK_SUCCESS_SINGLE, MessageConstants.COMMANDS_ADMIN_TOP_BLOCK_SUCCESS_MULTIPLE); 41 | handleFeedback(commandContext, pair.left(), pair.right()); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/world/TopBlockPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.world; 2 | 3 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 4 | import net.momirealms.sparrow.bukkit.util.EntityUtils; 5 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 6 | import net.momirealms.sparrow.common.locale.MessageConstants; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | import org.incendo.cloud.Command; 10 | import org.incendo.cloud.CommandManager; 11 | 12 | public class TopBlockPlayerCommand extends BukkitCommandFeature { 13 | 14 | public TopBlockPlayerCommand(SparrowCommandManager sparrowCommandManager) { 15 | super(sparrowCommandManager); 16 | } 17 | 18 | @Override 19 | public String getFeatureID() { 20 | return "topblock_player"; 21 | } 22 | 23 | @Override 24 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 25 | return builder 26 | .senderType(Player.class) 27 | .handler(commandContext -> { 28 | EntityUtils.toTopBlockPosition(commandContext.sender()); 29 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_TOP_BLOCK_SUCCESS); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/feature/world/WorldPlayerCommand.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.feature.world; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.bukkit.command.BukkitCommandFeature; 5 | import net.momirealms.sparrow.bukkit.util.EntityUtils; 6 | import net.momirealms.sparrow.common.command.SparrowCommandManager; 7 | import net.momirealms.sparrow.common.locale.MessageConstants; 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.World; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | import org.incendo.cloud.Command; 13 | import org.incendo.cloud.CommandManager; 14 | import org.incendo.cloud.bukkit.parser.WorldParser; 15 | 16 | import java.util.List; 17 | 18 | public class WorldPlayerCommand extends BukkitCommandFeature { 19 | 20 | public WorldPlayerCommand(SparrowCommandManager sparrowCommandManager) { 21 | super(sparrowCommandManager); 22 | } 23 | 24 | @Override 25 | public String getFeatureID() { 26 | return "world_player"; 27 | } 28 | 29 | @Override 30 | public Command.Builder assembleCommand(CommandManager manager, Command.Builder builder) { 31 | return builder 32 | .senderType(Player.class) 33 | .optional("world", WorldParser.worldParser()) 34 | .handler(commandContext -> { 35 | World world = commandContext.getOrSupplyDefault("world", () -> { 36 | World currentWorld = commandContext.sender().getWorld(); 37 | List worlds = Bukkit.getWorlds(); 38 | for (int i = 0; i < worlds.size(); i++) { 39 | if (currentWorld == worlds.get(i)) { 40 | if (i + 1 < worlds.size()) { 41 | return worlds.get(i + 1); 42 | } else { 43 | return worlds.get(0); 44 | } 45 | } 46 | } 47 | throw new RuntimeException("No world found"); 48 | }); 49 | EntityUtils.changeWorld(commandContext.sender(), world); 50 | handleFeedback(commandContext, MessageConstants.COMMANDS_PLAYER_WORLD_SUCCESS, Component.text(world.getName())); 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/key/SparrowBukkitArgumentKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.key; 2 | 3 | import net.kyori.adventure.text.format.TextColor; 4 | import org.incendo.cloud.bukkit.data.MultipleEntitySelector; 5 | import org.incendo.cloud.bukkit.data.MultiplePlayerSelector; 6 | import org.incendo.cloud.key.CloudKey; 7 | 8 | public class SparrowBukkitArgumentKeys { 9 | public static final CloudKey PLAYER_SELECTOR = CloudKey.of("player_selector", MultiplePlayerSelector.class); 10 | public static final CloudKey ENTITY_SELECTOR = CloudKey.of("entity_selector", MultipleEntitySelector.class); 11 | public static final CloudKey TEXT_COLOR = CloudKey.of("text_color", TextColor.class); 12 | } 13 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/command/parser/BackendServerParser.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.command.parser; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 4 | import org.checkerframework.checker.nullness.qual.NonNull; 5 | import org.incendo.cloud.component.CommandComponent; 6 | import org.incendo.cloud.context.CommandContext; 7 | import org.incendo.cloud.context.CommandInput; 8 | import org.incendo.cloud.parser.ArgumentParseResult; 9 | import org.incendo.cloud.parser.ArgumentParser; 10 | import org.incendo.cloud.parser.ParserDescriptor; 11 | import org.incendo.cloud.suggestion.BlockingSuggestionProvider; 12 | 13 | public class BackendServerParser implements ArgumentParser, 14 | BlockingSuggestionProvider.Strings { 15 | 16 | public static @NonNull ParserDescriptor backendServerParser() { 17 | return ParserDescriptor.of(new BackendServerParser<>(), String.class); 18 | } 19 | 20 | public static CommandComponent.@NonNull Builder backendServerComponent() { 21 | return CommandComponent.builder().parser(backendServerParser()); 22 | } 23 | 24 | @Override 25 | public @NonNull ArgumentParseResult<@NonNull String> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) { 26 | return ArgumentParseResult.success(commandInput.readString()); 27 | } 28 | 29 | @Override 30 | public @NonNull Iterable<@NonNull String> stringSuggestions(@NonNull CommandContext commandContext, @NonNull CommandInput input) { 31 | return SparrowBukkitPlugin.getInstance().getBungeeManager().getBackendServers(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/feature/item/SparrowBukkitItemFactory.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.feature.item; 2 | 3 | import com.saicone.rtag.RtagItem; 4 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 5 | import net.momirealms.sparrow.bukkit.feature.item.impl.ComponentItemFactory; 6 | import net.momirealms.sparrow.bukkit.feature.item.impl.UniversalItemFactory; 7 | import net.momirealms.sparrow.common.feature.item.ItemFactory; 8 | import net.momirealms.sparrow.common.feature.item.SparrowItem; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import java.util.Objects; 12 | 13 | public abstract class SparrowBukkitItemFactory extends ItemFactory { 14 | 15 | protected SparrowBukkitItemFactory(SparrowBukkitPlugin plugin) { 16 | super(plugin); 17 | } 18 | 19 | public static SparrowBukkitItemFactory create(SparrowBukkitPlugin plugin) { 20 | Objects.requireNonNull(plugin, "plugin"); 21 | switch (plugin.getBootstrap().getServerVersion()) { 22 | case "1.17", "1.17.1", 23 | "1.18", "1.18.1", "1.18.2", 24 | "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", 25 | "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4" -> { 26 | return new UniversalItemFactory(plugin); 27 | } 28 | case "1.20.5", "1.20.6", 29 | "1.21", "1.21.1", "1.21.2", "1.21.3", "1.21.4" -> { 30 | return new ComponentItemFactory(plugin); 31 | } 32 | default -> throw new IllegalStateException("Unsupported server version: " + plugin.getBootstrap().getServerVersion()); 33 | } 34 | } 35 | 36 | public SparrowItem wrap(ItemStack item) { 37 | Objects.requireNonNull(item, "item"); 38 | return wrap(new RtagItem(item)); 39 | } 40 | 41 | @Override 42 | protected void update(RtagItem item) { 43 | item.update(); 44 | } 45 | 46 | @Override 47 | protected ItemStack load(RtagItem item) { 48 | return item.load(); 49 | } 50 | 51 | @Override 52 | protected ItemStack getItem(RtagItem item) { 53 | return item.getItem(); 54 | } 55 | 56 | @Override 57 | protected ItemStack loadCopy(RtagItem item) { 58 | return item.loadCopy(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/feature/patrol/SparrowBukkitPatrolManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.feature.patrol; 2 | 3 | import net.momirealms.sparrow.bukkit.user.BukkitOnlineUser; 4 | import net.momirealms.sparrow.bukkit.user.BukkitUserManager; 5 | import net.momirealms.sparrow.common.feature.patrol.PatrolManager; 6 | import net.momirealms.sparrow.common.feature.patrol.Patrolable; 7 | import net.momirealms.sparrow.common.user.UserManager; 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.entity.Player; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.TreeSet; 14 | import java.util.function.Function; 15 | 16 | public class SparrowBukkitPatrolManager implements PatrolManager { 17 | private static SparrowBukkitPatrolManager instance; 18 | private final UserManager userManager = BukkitUserManager.getInstance(); 19 | private final TreeSet patrolableUsers = new TreeSet<>(); 20 | 21 | private SparrowBukkitPatrolManager() { 22 | for (Player player : Bukkit.getOnlinePlayers()) { 23 | BukkitOnlineUser user = userManager.getUser(player.getUniqueId()); 24 | addPatrolable(user); 25 | } 26 | } 27 | 28 | public static SparrowBukkitPatrolManager getInstance() { 29 | if (instance == null) { 30 | instance = new SparrowBukkitPatrolManager(); 31 | } 32 | return instance; 33 | } 34 | 35 | @Override 36 | public @Nullable Patrolable selectNextPatrolable(@NotNull Function filter) { 37 | for (Patrolable patrolable : patrolableUsers) { 38 | if (filter.apply(patrolable)) { 39 | return patrolable; 40 | } 41 | } 42 | return null; 43 | } 44 | 45 | @Override 46 | public void finishPatrol(Patrolable patrolable) { 47 | removePatrolable(patrolable); 48 | patrolable.setLastPatrolTime(System.currentTimeMillis()); 49 | addPatrolable(patrolable); 50 | } 51 | 52 | @Override 53 | public void addPatrolable(@NotNull Patrolable patrolable) { 54 | if (this.patrolableUsers.contains(patrolable)) { 55 | return; 56 | } 57 | this.patrolableUsers.add(patrolable); 58 | } 59 | 60 | @Override 61 | public boolean removePatrolable(@NotNull Patrolable patrolable) { 62 | return this.patrolableUsers.remove(patrolable); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/feature/skull/SparrowBukkitSkullManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.feature.skull; 2 | 3 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 4 | import net.momirealms.sparrow.bukkit.feature.skull.fetcher.OnlinePlayerFetcherProvider; 5 | import net.momirealms.sparrow.common.feature.skull.AbstractSkullManager; 6 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.APIFetcherProvider; 7 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.FetcherProvider; 8 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.MineSkinFetcherProvider; 9 | import net.momirealms.sparrow.common.util.Pair; 10 | import org.bukkit.Bukkit; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public final class SparrowBukkitSkullManager extends AbstractSkullManager { 16 | 17 | private final SparrowBukkitPlugin plugin; 18 | 19 | public SparrowBukkitSkullManager(SparrowBukkitPlugin plugin) { 20 | super(plugin); 21 | this.plugin = plugin; 22 | } 23 | 24 | @Override 25 | protected List> getProviders() { 26 | ArrayList> providers = new ArrayList<>(); 27 | if (Bukkit.getServer().getOnlineMode()) { 28 | try { 29 | Class.forName("com.destroystokyo.paper.profile.PlayerProfile"); 30 | providers.add(Pair.of("online", new OnlinePlayerFetcherProvider())); 31 | } catch (Exception ignore) { 32 | } 33 | } 34 | providers.add(Pair.of("mineskin", new MineSkinFetcherProvider())); 35 | providers.add(Pair.of("api", new APIFetcherProvider())); 36 | return providers; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/feature/skull/fetcher/OnlinePlayerFetcher.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.feature.skull.fetcher; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 5 | import org.bukkit.entity.Player; 6 | 7 | import java.util.concurrent.CompletableFuture; 8 | 9 | public class OnlinePlayerFetcher implements SkullFetcher { 10 | 11 | private final SkullData skullData; 12 | 13 | public OnlinePlayerFetcher(Player player) { 14 | this.skullData = player.getPlayerProfile() 15 | .getProperties() 16 | .stream() 17 | .filter(profileProperty -> profileProperty.getName().equals("textures")) 18 | .findAny() 19 | .map(profileProperty -> SkullData.builder().owner(player.getName()).uuid(player.getUniqueId()).textureBase64(profileProperty.getValue()).build()) 20 | .orElse(null); 21 | } 22 | 23 | @Override 24 | public CompletableFuture fetchData() { 25 | return CompletableFuture.completedFuture(skullData); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/feature/skull/fetcher/OnlinePlayerFetcherProvider.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.feature.skull.fetcher; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.NameSkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 5 | import net.momirealms.sparrow.common.feature.skull.argument.UUIDSkullArgument; 6 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 7 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.FetcherProvider; 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.entity.Player; 10 | 11 | import java.util.Optional; 12 | 13 | public class OnlinePlayerFetcherProvider implements FetcherProvider { 14 | 15 | @Override 16 | public Optional getOrEmpty(SkullArgument skullArgument) { 17 | Player player = null; 18 | if (skullArgument instanceof NameSkullArgument nameSkullArgument) { 19 | player = Bukkit.getPlayer(nameSkullArgument.name()); 20 | } else if (skullArgument instanceof UUIDSkullArgument uuidSkullArgument) { 21 | player = Bukkit.getPlayer(uuidSkullArgument.uniqueId()); 22 | } 23 | if (player == null || !player.isOnline()) { 24 | return Optional.empty(); 25 | } 26 | return Optional.of(new OnlinePlayerFetcher(player)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/user/BukkitOfflineUser.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.user; 2 | 3 | import net.momirealms.sparrow.common.user.User; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.OfflinePlayer; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Objects; 9 | import java.util.UUID; 10 | 11 | public class BukkitOfflineUser implements User { 12 | 13 | protected final UUID uniqueId; 14 | 15 | public BukkitOfflineUser(UUID uniqueId) { 16 | this.uniqueId = uniqueId; 17 | } 18 | 19 | @Override 20 | public OfflinePlayer getPlayer() { 21 | return Bukkit.getOfflinePlayer(uniqueId); 22 | } 23 | 24 | @Override 25 | public boolean isOnline() { 26 | return getPlayer().isOnline(); 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return getPlayer().getName(); 32 | } 33 | 34 | @NotNull 35 | @Override 36 | public UUID getUniqueId() { 37 | return uniqueId; 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (this == o) return true; 43 | if (o == null || getClass() != o.getClass()) return false; 44 | BukkitOfflineUser that = (BukkitOfflineUser) o; 45 | return Objects.equals(uniqueId, that.uniqueId); 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | return Objects.hash(uniqueId); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/user/BukkitOnlineUser.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.user; 2 | 3 | import net.momirealms.sparrow.common.feature.patrol.Patrolable; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.UUID; 9 | 10 | public class BukkitOnlineUser extends BukkitOfflineUser implements Patrolable { 11 | 12 | private long lastPatrolTime; 13 | 14 | BukkitOnlineUser(UUID uniqueId) { 15 | super(uniqueId); 16 | } 17 | 18 | @Nullable 19 | @Override 20 | public Player getPlayer() { 21 | return Bukkit.getPlayer(getUniqueId()); 22 | } 23 | 24 | @Override 25 | public boolean isOnline() { 26 | return getPlayer() != null; 27 | } 28 | 29 | @Override 30 | public long getLastPatrolTime() { 31 | return lastPatrolTime; 32 | } 33 | 34 | @Override 35 | public void setLastPatrolTime(long lastPatrolTime) { 36 | this.lastPatrolTime = lastPatrolTime; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/user/BukkitUserManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.user; 2 | 3 | import net.momirealms.sparrow.common.user.UserManager; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.UUID; 9 | 10 | public class BukkitUserManager implements UserManager { 11 | 12 | private final Map users = new HashMap<>(); 13 | 14 | private BukkitUserManager() {} 15 | 16 | private static class SingletonHolder { 17 | private static final BukkitUserManager INSTANCE = new BukkitUserManager(); 18 | } 19 | 20 | public static BukkitUserManager getInstance() { 21 | return SingletonHolder.INSTANCE; 22 | } 23 | 24 | public @NotNull BukkitOnlineUser getUser(UUID uniqueId) { 25 | return users.computeIfAbsent(uniqueId, BukkitOnlineUser::new); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/util/ItemStackUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.util; 2 | 3 | import com.saicone.rtag.RtagMirror; 4 | import com.saicone.rtag.item.ItemObject; 5 | import com.saicone.rtag.tag.TagCompound; 6 | import net.momirealms.sparrow.bukkit.SparrowBukkitPlugin; 7 | import net.momirealms.sparrow.common.feature.skull.SkullData; 8 | import org.bukkit.inventory.ItemStack; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | import java.util.Map; 13 | 14 | public final class ItemStackUtils { 15 | private ItemStackUtils() { 16 | } 17 | 18 | public static void applySkull(@NotNull ItemStack skull, @Nullable SkullData skullData) { 19 | try { 20 | SparrowBukkitPlugin.getInstance().getItemFactory().wrap(skull) 21 | .skull(skullData) 22 | .load(); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | 28 | public static Map toReadableMap(ItemStack item) { 29 | return toMap(item); 30 | } 31 | 32 | private static Map toMap(ItemStack object) { 33 | return TagCompound.getValue(RtagMirror.INSTANCE, toCompound(object)); 34 | } 35 | 36 | private static Object toCompound(ItemStack object) { 37 | if (object == null) { 38 | return null; 39 | } else { 40 | Object compound = extract(object); 41 | return TagCompound.isTagCompound(compound) ? compound : null; 42 | } 43 | } 44 | 45 | private static Object extract(ItemStack object) { 46 | return ItemObject.save(ItemObject.asNMSCopy(object)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/util/LocationUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.util; 2 | 3 | import org.bukkit.Location; 4 | 5 | public final class LocationUtils { 6 | 7 | private LocationUtils() {} 8 | 9 | public static double euclideanDistance(Location location1, Location location2) { 10 | double sum = 0; 11 | sum += Math.pow(location1.getX() - location2.getX(), 2); 12 | sum += Math.pow(location1.getY() - location2.getY(), 2); 13 | sum += Math.pow(location1.getZ() - location2.getZ(), 2); 14 | return Math.sqrt(sum); 15 | } 16 | 17 | public static double manhattanDistance(Location location1, Location location2) { 18 | double sum = 0; 19 | sum += Math.abs(location1.getX() - location2.getX()); 20 | sum += Math.abs(location1.getY() - location2.getY()); 21 | sum += Math.abs(location1.getZ() - location2.getZ()); 22 | return sum; 23 | } 24 | 25 | public static Location toBlockCenter(Location location) { 26 | Location centerLoc = location.clone(); 27 | centerLoc.setX(location.getBlockX() + 0.5); 28 | centerLoc.setY(location.getBlockY() + 0.5); 29 | centerLoc.setZ(location.getBlockZ() + 0.5); 30 | return centerLoc; 31 | } 32 | 33 | public static Location toBlockLocation(Location location) { 34 | Location blockLoc = location.clone(); 35 | blockLoc.setX(location.getBlockX()); 36 | blockLoc.setY(location.getBlockY()); 37 | blockLoc.setZ(location.getBlockZ()); 38 | return blockLoc; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/util/PlaceholderUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.util; 2 | 3 | import me.clip.placeholderapi.PlaceholderAPI; 4 | import org.bukkit.OfflinePlayer; 5 | import org.bukkit.entity.Player; 6 | 7 | public class PlaceholderUtils { 8 | 9 | public static String parse(OfflinePlayer player, String text) { 10 | return PlaceholderAPI.setPlaceholders(player, text); 11 | } 12 | 13 | public static String parse(Player p1, Player p2, String text) { 14 | return PlaceholderAPI.setRelationalPlaceholders(p1, p2, text); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/util/PlayerUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.util; 2 | 3 | import net.momirealms.sparrow.common.util.RandomUtils; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Item; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.util.Vector; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import static java.util.Objects.requireNonNull; 12 | 13 | public class PlayerUtils { 14 | 15 | public static void dropItem(@NotNull Player player, @NotNull ItemStack itemStack, boolean retainOwnership, boolean noPickUpDelay, boolean throwRandomly) { 16 | requireNonNull(player, "player"); 17 | requireNonNull(itemStack, "itemStack"); 18 | Location location = player.getLocation().clone(); 19 | Item item = player.getWorld().dropItem(player.getEyeLocation().clone().subtract(new Vector(0,0.3,0)), itemStack); 20 | item.setPickupDelay(noPickUpDelay ? 0 : 40); 21 | if (retainOwnership) { 22 | item.setThrower(player.getUniqueId()); 23 | } 24 | if (throwRandomly) { 25 | double d1 = RandomUtils.generateRandomDouble(0,1) * 0.5f; 26 | double d2 = RandomUtils.generateRandomDouble(0,1) * (Math.PI * 2); 27 | item.setVelocity(new Vector(-Math.sin(d2) * d1, 0.2f, Math.cos(d2) * d1)); 28 | } else { 29 | double d1 = Math.sin(location.getPitch() * (Math.PI/180)); 30 | double d2 = RandomUtils.generateRandomDouble(0, 0.02); 31 | double d3 = RandomUtils.generateRandomDouble(0,1) * (Math.PI * 2); 32 | Vector vector = location.getDirection().multiply(0.3).setY(-d1 * 0.3 + 0.1 + (RandomUtils.generateRandomDouble(0,1) - RandomUtils.generateRandomDouble(0,1)) * 0.1); 33 | vector.add(new Vector(Math.cos(d3) * d2, 0, Math.sin(d3) * d2)); 34 | item.setVelocity(vector); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/momirealms/sparrow/bukkit/util/PluginUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.bukkit.util; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | public final class PluginUtils { 6 | private PluginUtils() { 7 | } 8 | 9 | public static boolean isPluginEnabled(String pluginName) { 10 | return Bukkit.getPluginManager().getPlugin(pluginName) != null; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | repositories { 2 | maven("https://repo.codemc.io/repository/maven-public/") 3 | maven("https://jitpack.io/") 4 | } 5 | 6 | dependencies { 7 | compileOnly(project(":loader")) 8 | 9 | compileOnly("net.kyori:adventure-api:${rootProject.properties["adventure_bundle_version"]}") { 10 | exclude(module = "adventure-bom") 11 | exclude(module = "checker-qual") 12 | exclude(module = "annotations") 13 | } 14 | compileOnly("org.incendo:cloud-core:${rootProject.properties["cloud_core_version"]}") 15 | compileOnly("org.incendo:cloud-minecraft-extras:${rootProject.properties["cloud_minecraft_extras_version"]}") 16 | compileOnly("dev.dejvokep:boosted-yaml:${rootProject.properties["boosted_yaml_version"]}") 17 | compileOnly("org.jetbrains:annotations:${rootProject.properties["jetbrains_annotations_version"]}") 18 | compileOnly("org.slf4j:slf4j-api:${rootProject.properties["slf4j_version"]}") 19 | compileOnly("org.apache.logging.log4j:log4j-core:${rootProject.properties["log4j_version"]}") 20 | compileOnly("net.kyori:adventure-text-minimessage:${rootProject.properties["adventure_bundle_version"]}") 21 | compileOnly("net.kyori:adventure-text-serializer-gson:${rootProject.properties["adventure_bundle_version"]}") 22 | compileOnly("com.google.code.gson:gson:${rootProject.properties["gson_version"]}") 23 | compileOnly("net.bytebuddy:byte-buddy:${rootProject.properties["byte_buddy_version"]}") 24 | compileOnly("com.github.ben-manes.caffeine:caffeine:${rootProject.properties["caffeine_version"]}") 25 | compileOnly("io.lettuce:lettuce-core:${rootProject.properties["lettuce_version"]}") 26 | compileOnly("com.saicone.rtag:rtag:${rootProject.properties["rtag_version"]}") 27 | } 28 | 29 | java { 30 | sourceCompatibility = JavaVersion.VERSION_17 31 | targetCompatibility = JavaVersion.VERSION_17 32 | toolchain { 33 | languageVersion = JavaLanguageVersion.of(17) 34 | } 35 | } 36 | 37 | tasks.withType { 38 | options.encoding = "UTF-8" 39 | options.release.set(17) 40 | dependsOn(tasks.clean) 41 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/AbstractCommandFeature.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.TranslatableComponent; 5 | import net.momirealms.sparrow.common.command.key.SparrowFlagKeys; 6 | import net.momirealms.sparrow.common.sender.SenderFactory; 7 | import org.incendo.cloud.Command; 8 | import org.incendo.cloud.CommandManager; 9 | import org.incendo.cloud.context.CommandContext; 10 | 11 | public abstract class AbstractCommandFeature implements CommandFeature { 12 | 13 | protected final SparrowCommandManager sparrowCommandManager; 14 | protected CommandConfig commandConfig; 15 | 16 | public AbstractCommandFeature(SparrowCommandManager sparrowCommandManager) { 17 | this.sparrowCommandManager = sparrowCommandManager; 18 | } 19 | 20 | protected abstract SenderFactory getSenderFactory(); 21 | 22 | public abstract Command.Builder assembleCommand(CommandManager manager, Command.Builder builder); 23 | 24 | @Override 25 | @SuppressWarnings("unchecked") 26 | public Command registerCommand(CommandManager manager, Command.Builder builder) { 27 | Command command = (Command) assembleCommand(manager, builder).build(); 28 | manager.command(command); 29 | return command; 30 | } 31 | 32 | @Override 33 | public void registerRelatedFunctions() { 34 | // empty 35 | } 36 | 37 | @Override 38 | public void unregisterRelatedFunctions() { 39 | // empty 40 | } 41 | 42 | @Override 43 | @SuppressWarnings("unchecked") 44 | public void handleFeedback(CommandContext context, TranslatableComponent.Builder key, Component... args) { 45 | if (context.flags().hasFlag(SparrowFlagKeys.SILENT_FLAG)) { 46 | return; 47 | } 48 | sparrowCommandManager.handleCommandFeedback((C) context.sender(), key, args); 49 | } 50 | 51 | @Override 52 | public void handleFeedback(C sender, TranslatableComponent.Builder key, Component... args) { 53 | sparrowCommandManager.handleCommandFeedback(sender, key, args); 54 | } 55 | 56 | @Override 57 | public SparrowCommandManager getSparrowCommandManager() { 58 | return sparrowCommandManager; 59 | } 60 | 61 | @Override 62 | public CommandConfig getCommandConfig() { 63 | return commandConfig; 64 | } 65 | 66 | public void setCommandConfig(CommandConfig commandConfig) { 67 | this.commandConfig = commandConfig; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/CommandBuilder.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command; 2 | 3 | import org.incendo.cloud.Command; 4 | import org.incendo.cloud.CommandManager; 5 | 6 | public interface CommandBuilder { 7 | 8 | CommandBuilder setPermission(String permission); 9 | 10 | CommandBuilder setCommandNode(String... subNodes); 11 | 12 | Command.Builder getBuiltCommandBuilder(); 13 | 14 | class BasicCommandBuilder implements CommandBuilder { 15 | 16 | private Command.Builder commandBuilder; 17 | 18 | public BasicCommandBuilder(CommandManager commandManager, String rootNode) { 19 | this.commandBuilder = commandManager.commandBuilder(rootNode); 20 | } 21 | 22 | @Override 23 | public CommandBuilder setPermission(String permission) { 24 | this.commandBuilder = this.commandBuilder.permission(permission); 25 | return this; 26 | } 27 | 28 | @Override 29 | public CommandBuilder setCommandNode(String... subNodes) { 30 | for (String sub : subNodes) { 31 | this.commandBuilder = this.commandBuilder.literal(sub); 32 | } 33 | return this; 34 | } 35 | 36 | @Override 37 | public Command.Builder getBuiltCommandBuilder() { 38 | return commandBuilder; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/CommandConfig.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class CommandConfig { 7 | 8 | private boolean enable = false; 9 | private List usages = new ArrayList<>(); 10 | private String permission = null; 11 | 12 | private CommandConfig() { 13 | } 14 | 15 | public CommandConfig(boolean enable, List usages, String permission) { 16 | this.enable = enable; 17 | this.usages = usages; 18 | this.permission = permission; 19 | } 20 | 21 | public boolean isEnable() { 22 | return enable; 23 | } 24 | 25 | public List getUsages() { 26 | return usages; 27 | } 28 | 29 | public String getPermission() { 30 | return permission; 31 | } 32 | 33 | public static class Builder { 34 | 35 | private final CommandConfig config; 36 | 37 | public Builder() { 38 | this.config = new CommandConfig<>(); 39 | } 40 | 41 | public Builder usages(List usages) { 42 | config.usages = usages; 43 | return this; 44 | } 45 | 46 | public Builder permission(String permission) { 47 | config.permission = permission; 48 | return this; 49 | } 50 | 51 | public Builder enable(boolean enable) { 52 | config.enable = enable; 53 | return this; 54 | } 55 | 56 | public CommandConfig build() { 57 | return config; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/CommandFeature.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.TranslatableComponent; 5 | import org.incendo.cloud.Command; 6 | import org.incendo.cloud.CommandManager; 7 | import org.incendo.cloud.context.CommandContext; 8 | 9 | public interface CommandFeature { 10 | 11 | Command registerCommand(CommandManager cloudCommandManager, Command.Builder builder); 12 | 13 | String getFeatureID(); 14 | 15 | void registerRelatedFunctions(); 16 | 17 | void unregisterRelatedFunctions(); 18 | 19 | void handleFeedback(CommandContext context, TranslatableComponent.Builder key, Component... args); 20 | 21 | void handleFeedback(C sender, TranslatableComponent.Builder key, Component... args); 22 | 23 | SparrowCommandManager getSparrowCommandManager(); 24 | 25 | CommandConfig getCommandConfig(); 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/SparrowCommandManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command; 2 | 3 | import dev.dejvokep.boostedyaml.YamlDocument; 4 | import net.kyori.adventure.text.Component; 5 | import net.kyori.adventure.text.TranslatableComponent; 6 | import net.kyori.adventure.util.Index; 7 | import org.apache.logging.log4j.util.TriConsumer; 8 | import org.incendo.cloud.Command; 9 | import org.incendo.cloud.CommandManager; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.Collection; 13 | 14 | public interface SparrowCommandManager { 15 | 16 | String commandsFile = "commands.yml"; 17 | 18 | void unregisterFeatures(); 19 | 20 | void registerFeature(CommandFeature feature, CommandConfig config); 21 | 22 | void registerDefaultFeatures(); 23 | 24 | Index> getFeatures(); 25 | 26 | void setFeedbackConsumer(@NotNull TriConsumer feedbackConsumer); 27 | 28 | TriConsumer defaultFeedbackConsumer(); 29 | 30 | CommandConfig getCommandConfig(YamlDocument document, String featureID); 31 | 32 | Collection> buildCommandBuilders(CommandConfig config); 33 | 34 | CommandManager getCommandManager(); 35 | 36 | void handleCommandFeedback(C sender, TranslatableComponent.Builder key, Component... args); 37 | 38 | void handleCommandFeedback(C sender, String node, Component component); 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/key/SparrowArgumentKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command.key; 2 | 3 | import org.incendo.cloud.key.CloudKey; 4 | 5 | public final class SparrowArgumentKeys { 6 | public static final CloudKey TIME = CloudKey.of("time", Long.class); 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/key/SparrowFlagKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command.key; 2 | 3 | import org.incendo.cloud.parser.flag.CommandFlag; 4 | import org.incendo.cloud.parser.standard.StringParser; 5 | 6 | public final class SparrowFlagKeys { 7 | public static final String SILENT = "silent"; 8 | public static final CommandFlag SILENT_FLAG = CommandFlag.builder(SILENT).withAliases("s").build(); 9 | public static final String LEGACY_COLOR = "legacy-color"; 10 | public static final CommandFlag LEGACY_COLOR_FLAG = CommandFlag.builder(LEGACY_COLOR).withAliases("l").build(); 11 | public static final String PARSE = "parse"; 12 | public static final CommandFlag PARSE_FLAG = CommandFlag.builder(PARSE).withAliases("p").build(); 13 | public static final String TITLE = "title"; 14 | public static final CommandFlag TITLE_FLAG = CommandFlag.builder(TITLE).withAliases("t").withComponent(StringParser.greedyFlagYieldingStringParser()).build(); 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/key/SparrowMetaKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command.key; 2 | 3 | import org.incendo.cloud.key.CloudKey; 4 | 5 | public final class SparrowMetaKeys { 6 | public static final CloudKey ALLOW_EMPTY_ENTITY_SELECTOR = CloudKey.of("allow_empty_entity_selector", Boolean.class); 7 | public static final CloudKey ALLOW_EMPTY_PLAYER_SELECTOR = CloudKey.of("allow_empty_player_selector", Boolean.class); 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/command/parser/URLParser.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.command.parser; 2 | 3 | import net.momirealms.sparrow.common.locale.SparrowCaptionKeys; 4 | import org.checkerframework.checker.nullness.qual.NonNull; 5 | import org.incendo.cloud.caption.CaptionVariable; 6 | import org.incendo.cloud.context.CommandContext; 7 | import org.incendo.cloud.exception.parsing.ParserException; 8 | import org.incendo.cloud.parser.ArgumentParseResult; 9 | import org.incendo.cloud.parser.MappedArgumentParser; 10 | 11 | import java.net.URI; 12 | import java.net.URL; 13 | import java.util.concurrent.CompletableFuture; 14 | 15 | public class URLParser implements MappedArgumentParser.Mapper{ 16 | 17 | @Override 18 | public @NonNull CompletableFuture> map(@NonNull CommandContext context, @NonNull ArgumentParseResult input) { 19 | if (input.failure().isPresent()) { 20 | return ArgumentParseResult.failureFuture(input.failure().get()); 21 | } 22 | 23 | final String inputString = input.parsedValue().orElse(""); 24 | 25 | final URL url; 26 | try { 27 | url = URI.create(inputString).toURL(); 28 | } catch (Exception e) { 29 | return ArgumentParseResult.failureFuture(new URIParseException(inputString, context)); 30 | } 31 | 32 | return ArgumentParseResult.successFuture(url); 33 | } 34 | 35 | public static final class URIParseException extends ParserException { 36 | 37 | private final String input; 38 | 39 | public URIParseException( 40 | final @NonNull String input, 41 | final @NonNull CommandContext context 42 | ) { 43 | super( 44 | URLParser.class, 45 | context, 46 | SparrowCaptionKeys.ARGUMENT_PARSE_FAILURE_URL, 47 | CaptionVariable.of("input", input) 48 | ); 49 | this.input = input; 50 | } 51 | 52 | public @NonNull String input() { 53 | return this.input; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/config/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.config; 2 | 3 | import dev.dejvokep.boostedyaml.YamlDocument; 4 | 5 | public interface ConfigManager { 6 | 7 | YamlDocument loadConfig(String filePath); 8 | 9 | YamlDocument loadConfig(String filePath, char routeSeparator); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/DependencyDownloadException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.dependency; 27 | 28 | /** 29 | * Exception thrown if a dependency cannot be downloaded. 30 | */ 31 | public class DependencyDownloadException extends Exception { 32 | 33 | public DependencyDownloadException() { 34 | 35 | } 36 | 37 | public DependencyDownloadException(String message) { 38 | super(message); 39 | } 40 | 41 | public DependencyDownloadException(String message, Throwable cause) { 42 | super(message, cause); 43 | } 44 | 45 | public DependencyDownloadException(Throwable cause) { 46 | super(cause); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/DependencyManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.dependency; 27 | 28 | import java.util.Collection; 29 | import java.util.Set; 30 | 31 | /** 32 | * Loads and manages runtime dependencies for the plugin. 33 | */ 34 | public interface DependencyManager extends AutoCloseable { 35 | 36 | /** 37 | * Loads dependencies. 38 | * 39 | * @param dependencies the dependencies to load 40 | */ 41 | void loadDependencies(Collection dependencies); 42 | 43 | /** 44 | * Obtains an isolated classloader containing the given dependencies. 45 | * 46 | * @param dependencies the dependencies 47 | * @return the classloader 48 | */ 49 | ClassLoader obtainClassLoaderWith(Set dependencies); 50 | 51 | @Override 52 | void close(); 53 | } 54 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/DependencyProperties.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.dependency; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.Properties; 8 | 9 | public class DependencyProperties { 10 | 11 | private final HashMap versionMap; 12 | 13 | private DependencyProperties(HashMap versionMap) { 14 | this.versionMap = versionMap; 15 | } 16 | 17 | public static String getDependencyVersion(String dependencyID) { 18 | if (!SingletonHolder.INSTANCE.versionMap.containsKey(dependencyID)) { 19 | throw new RuntimeException("Unknown dependency: " + dependencyID); 20 | } 21 | return SingletonHolder.INSTANCE.versionMap.get(dependencyID); 22 | } 23 | 24 | private static class SingletonHolder { 25 | 26 | private static final DependencyProperties INSTANCE = getInstance(); 27 | 28 | private static DependencyProperties getInstance() { 29 | try (InputStream inputStream = DependencyProperties.class.getClassLoader().getResourceAsStream("library-version.properties")) { 30 | HashMap versionMap = new HashMap<>(); 31 | Properties properties = new Properties(); 32 | properties.load(inputStream); 33 | for (Map.Entry entry : properties.entrySet()) { 34 | if (entry.getKey() instanceof String key && entry.getValue() instanceof String value) { 35 | versionMap.put(key, value); 36 | } 37 | } 38 | return new DependencyProperties(versionMap); 39 | } catch (IOException e) { 40 | throw new RuntimeException(e); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/DependencyRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.dependency; 27 | 28 | import com.google.gson.JsonElement; 29 | 30 | /** 31 | * Applies Sparrow specific behaviour for {@link Dependency}s. 32 | */ 33 | public class DependencyRegistry { 34 | 35 | public boolean shouldAutoLoad(Dependency dependency) { 36 | return switch (dependency) { 37 | // all used within 'isolated' classloaders, and are therefore not 38 | // relocated. 39 | case ASM, ASM_COMMONS, JAR_RELOCATOR, H2_DRIVER, SQLITE_DRIVER -> false; 40 | default -> true; 41 | }; 42 | } 43 | 44 | @SuppressWarnings("ConstantConditions") 45 | public static boolean isGsonRelocated() { 46 | return JsonElement.class.getName().startsWith("net.momirealms"); 47 | } 48 | 49 | private static boolean classExists(String className) { 50 | try { 51 | Class.forName(className); 52 | return true; 53 | } catch (ClassNotFoundException e) { 54 | return false; 55 | } 56 | } 57 | 58 | private static boolean slf4jPresent() { 59 | return classExists("org.slf4j.Logger") && classExists("org.slf4j.LoggerFactory"); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/classloader/IsolatedClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.dependency.classloader; 27 | 28 | import java.net.URL; 29 | import java.net.URLClassLoader; 30 | 31 | /** 32 | * A classloader "isolated" from the rest of the Minecraft server. 33 | * 34 | *

Used to load specific Sparrow dependencies without causing conflicts 35 | * with other plugins, or libraries provided by the server implementation.

36 | */ 37 | public class IsolatedClassLoader extends URLClassLoader { 38 | static { 39 | ClassLoader.registerAsParallelCapable(); 40 | } 41 | 42 | public IsolatedClassLoader(URL[] urls) { 43 | /* 44 | * ClassLoader#getSystemClassLoader returns the AppClassLoader 45 | * 46 | * Calling #getParent on this returns the ExtClassLoader (Java 8) or 47 | * the PlatformClassLoader (Java 9). Since we want this classloader to 48 | * be isolated from the Minecraft server (the app), we set the parent 49 | * to be the platform class loader. 50 | */ 51 | super(urls, ClassLoader.getSystemClassLoader().getParent()); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/dependency/relocation/RelocationHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.dependency.relocation; 27 | 28 | public final class RelocationHelper { 29 | 30 | // screw maven shade 31 | public static final String OKIO_STRING = String.valueOf(new char[]{'o', 'k', 'i', 'o'}); 32 | public static final String OKHTTP3_STRING = String.valueOf(new char[]{'o', 'k', 'h', 't', 't', 'p', '3'}); 33 | 34 | private RelocationHelper() { 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/Cancellable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event; 26 | 27 | public interface Cancellable { 28 | 29 | /** 30 | * Gets the cancelled state. 31 | */ 32 | boolean cancelled(); 33 | 34 | /** 35 | * Sets the cancelled state. 36 | */ 37 | void cancelled(final boolean cancelled); 38 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/EventConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event; 26 | 27 | @FunctionalInterface 28 | public interface EventConsumer { 29 | 30 | /** 31 | * Invokes this event consumer. 32 | */ 33 | void onEvent(final E event) throws Throwable; 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/EventManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.event; 2 | 3 | import net.momirealms.sparrow.common.event.bus.EventBus; 4 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 5 | 6 | import java.util.OptionalInt; 7 | 8 | public interface EventManager { 9 | 10 | class SingletonHolder { 11 | private static EventManager INSTANCE = null; 12 | } 13 | 14 | static EventManager create(SparrowPlugin plugin) { 15 | if (SingletonHolder.INSTANCE == null) { 16 | SingletonHolder.INSTANCE = new EventManagerImpl(plugin); 17 | } 18 | return SingletonHolder.INSTANCE; 19 | } 20 | 21 | EventSubscription subscribe(Class event, EventSubscriber subscriber); 22 | 23 | EventSubscription subscribe(Class event, EventConfig config, EventSubscriber subscriber); 24 | 25 | SparrowEvent dispatch(Class eventClass, Object... params); 26 | 27 | @SuppressWarnings("OptionalUsedAsFieldOrParameterType") 28 | SparrowEvent dispatch(Class eventClass, OptionalInt order, Object... params); 29 | 30 | EventBus getEventBus(); 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/EventSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event; 26 | 27 | public interface EventSubscriber extends EventConsumer { 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/EventSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event; 26 | 27 | public interface EventSubscription { 28 | 29 | /** 30 | * Gets the event type. 31 | */ 32 | Class event(); 33 | 34 | /** 35 | * Gets the configuration. 36 | */ 37 | EventConfig config(); 38 | 39 | /** 40 | * Gets the subscriber. 41 | */ 42 | EventSubscriber subscriber(); 43 | 44 | /** 45 | * Disposes this subscription. 46 | * 47 | *

The subscriber held by this subscription will no longer receive events.

48 | */ 49 | void dispose(); 50 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/Param.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.event; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * Represents the position of a parameter within an event. 35 | * 36 | *

This is an implementation detail and should not be relied upon.

37 | */ 38 | @Target(ElementType.METHOD) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | public @interface Param { 41 | 42 | /** 43 | * Gets the index of the parameter. 44 | * 45 | * @return the index 46 | */ 47 | int value(); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/SparrowEvent.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.event; 2 | 3 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface SparrowEvent { 7 | 8 | /** 9 | * Get the plugin instance this event was dispatched from 10 | */ 11 | @NotNull 12 | SparrowPlugin getSparrowPlugin(); 13 | 14 | /** 15 | * Gets the type of the event. 16 | * 17 | * @return the type of the event 18 | */ 19 | @NotNull 20 | Class getEventType(); 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/bus/EventBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event.bus; 26 | 27 | import net.momirealms.sparrow.common.event.EventSubscription; 28 | 29 | import java.util.OptionalInt; 30 | 31 | public interface EventBus { 32 | 33 | default void post(final E event) { 34 | this.post(event, OptionalInt.empty()); 35 | } 36 | 37 | @SuppressWarnings("OptionalUsedAsFieldOrParameterType") 38 | void post(final E event, final OptionalInt order); 39 | 40 | @FunctionalInterface 41 | interface EventExceptionHandler { 42 | /** 43 | * Handles a caught exception. 44 | */ 45 | void eventExceptionCaught(final EventBus bus, final EventSubscription subscription, final E event, final Throwable throwable); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/gen/AbstractSparrowEvent.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.event.gen; 2 | 3 | import net.momirealms.sparrow.common.event.SparrowEvent; 4 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.lang.invoke.MethodHandles; 8 | 9 | public abstract class AbstractSparrowEvent implements SparrowEvent { 10 | 11 | private final SparrowPlugin plugin; 12 | 13 | protected AbstractSparrowEvent(SparrowPlugin plugin) { 14 | this.plugin = plugin; 15 | } 16 | 17 | @NotNull 18 | @Override 19 | public SparrowPlugin getSparrowPlugin() { 20 | return plugin; 21 | } 22 | 23 | public MethodHandles.Lookup mhl() { 24 | throw new UnsupportedOperationException(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/registry/Internals.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of event, licensed under the MIT License. 3 | * 4 | * Copyright (c) 2021-2023 Seiama 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package net.momirealms.sparrow.common.event.registry; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | final class Internals { 31 | private Internals() { 32 | } 33 | 34 | @SuppressWarnings("unchecked") 35 | static List> ancestors(final Class type) { 36 | final List> types = new ArrayList<>(); 37 | types.add(type); 38 | for (int i = 0; i < types.size(); i++) { 39 | final Class next = types.get(i); 40 | final Class superclass = next.getSuperclass(); 41 | if (superclass != null) { 42 | types.add((Class) superclass); 43 | } 44 | final Class[] interfaces = next.getInterfaces(); 45 | for (final Class iface : interfaces) { 46 | // we have a list because we want to preserve order, but we don't want duplicates 47 | if (!types.contains(iface)) { 48 | types.add((Class) iface); 49 | } 50 | } 51 | } 52 | return types; 53 | } 54 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/event/type/CommandFeedbackEvent.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.event.type; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.momirealms.sparrow.common.event.Cancellable; 5 | import net.momirealms.sparrow.common.event.Param; 6 | import net.momirealms.sparrow.common.event.SparrowEvent; 7 | 8 | public interface CommandFeedbackEvent extends SparrowEvent, Cancellable { 9 | 10 | @Param(0) 11 | C sender(); 12 | 13 | @Param(1) 14 | String key(); 15 | 16 | @Param(2) 17 | Component message(); 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/enchant/EnchantManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.enchant; 2 | 3 | public interface EnchantManager { 4 | 5 | String SHELVES_META_KEY = "sparrow_shelves"; 6 | String SHELVES_FLAG_PERMISSION = "sparrow.command.player.enchantmenttable.flag.shelves"; 7 | 8 | void openEnchantmentTable(T player, int shelves); 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/item/AbstractItem.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.item; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 5 | 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | public class AbstractItem implements SparrowItem { 10 | 11 | private final SparrowPlugin plugin; 12 | private final ItemFactory factory; 13 | private final R item; 14 | 15 | AbstractItem(SparrowPlugin plugin, ItemFactory factory, R item) { 16 | this.plugin = plugin; 17 | this.factory = factory; 18 | this.item = item; 19 | } 20 | 21 | @Override 22 | public SparrowItem customModelData(Integer data) { 23 | factory.customModelData(item, data); 24 | return this; 25 | } 26 | 27 | @Override 28 | public Optional customModelData() { 29 | return factory.customModelData(item); 30 | } 31 | 32 | @Override 33 | public Optional displayName() { 34 | return factory.displayName(item); 35 | } 36 | 37 | @Override 38 | public SparrowItem lore(List lore) { 39 | factory.lore(item, lore); 40 | return this; 41 | } 42 | 43 | @Override 44 | public Optional> lore() { 45 | return factory.lore(item); 46 | } 47 | 48 | @Override 49 | public SparrowItem displayName(String displayName) { 50 | factory.displayName(item, displayName); 51 | return this; 52 | } 53 | 54 | @Override 55 | public SparrowItem skull(SkullData data) { 56 | factory.skull(item, data); 57 | return this; 58 | } 59 | 60 | @Override 61 | public I getItem() { 62 | return factory.getItem(item); 63 | } 64 | 65 | @Override 66 | public I load() { 67 | return factory.load(item); 68 | } 69 | 70 | @Override 71 | public I loadCopy() { 72 | return factory.loadCopy(item); 73 | } 74 | 75 | @Override 76 | public void update() { 77 | factory.update(item); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/item/ComponentKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.item; 2 | 3 | import net.kyori.adventure.key.Key; 4 | 5 | public class ComponentKeys { 6 | 7 | public static final String CUSTOM_MODEL_DATA = Key.key("minecraft", "custom_model_data").asString(); 8 | public static final String CUSTOM_NAME = Key.key("minecraft", "custom_name").asString(); 9 | public static final String LORE = Key.key("minecraft", "lore").asString(); 10 | public static final String DAMAGE = Key.key("minecraft", "damage").asString(); 11 | public static final String ENCHANTMENT_GLINT_OVERRIDE = Key.key("minecraft", "enchantment_glint_override").asString(); 12 | public static final String HIDE_TOOLTIP = Key.key("minecraft", "hide_tooltip").asString(); 13 | public static final String MAX_STACK_SIZE = Key.key("minecraft", "max_stack_size").asString(); 14 | public static final String PROFILE = Key.key("minecraft", "profile").asString(); 15 | public static final String UNBREAKABLE = Key.key("minecraft", "unbreakable").asString(); 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/item/ItemFactory.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.item; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 5 | 6 | import java.util.List; 7 | import java.util.Objects; 8 | import java.util.Optional; 9 | 10 | public abstract class ItemFactory

{ 11 | 12 | protected final P plugin; 13 | 14 | protected ItemFactory(P plugin) { 15 | this.plugin = plugin; 16 | } 17 | 18 | public SparrowItem wrap(R item) { 19 | Objects.requireNonNull(item, "item"); 20 | return new AbstractItem<>(this.plugin, this, item); 21 | } 22 | 23 | protected abstract void update(R item); 24 | 25 | protected abstract I load(R item); 26 | 27 | protected abstract I getItem(R item); 28 | 29 | protected abstract I loadCopy(R item); 30 | 31 | protected abstract void customModelData(R rtag, Integer data); 32 | 33 | protected abstract Optional customModelData(R rtag); 34 | 35 | protected abstract void displayName(R rtag, String json); 36 | 37 | protected abstract Optional displayName(R rtag); 38 | 39 | protected abstract void skull(R rtag, SkullData skullData); 40 | 41 | protected abstract Optional> lore(R item); 42 | 43 | protected abstract void lore(R item, List lore); 44 | 45 | protected abstract boolean unbreakable(R item); 46 | 47 | protected abstract void unbreakable(R item, boolean unbreakable); 48 | 49 | protected abstract Optional glint(R item); 50 | 51 | protected abstract void glint(R item, Boolean glint); 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/item/SparrowItem.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.item; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | public interface SparrowItem { 9 | 10 | SparrowItem customModelData(Integer data); 11 | 12 | Optional customModelData(); 13 | 14 | SparrowItem displayName(String displayName); 15 | 16 | Optional displayName(); 17 | 18 | SparrowItem lore(List lore); 19 | 20 | Optional> lore(); 21 | 22 | SparrowItem skull(SkullData data); 23 | 24 | I getItem(); 25 | 26 | I load(); 27 | 28 | I loadCopy(); 29 | 30 | void update(); 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/patrol/PatrolManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.patrol; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import java.util.function.Function; 7 | 8 | public interface PatrolManager { 9 | 10 | @Nullable 11 | Patrolable selectNextPatrolable(@NotNull Function filter); 12 | 13 | void finishPatrol(Patrolable patrolable); 14 | 15 | void addPatrolable(@NotNull Patrolable patrolable); 16 | 17 | boolean removePatrolable(@NotNull Patrolable patrolable); 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/patrol/Patrolable.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.patrol; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface Patrolable extends Comparable { 8 | 9 | UUID getUniqueId(); 10 | 11 | long getLastPatrolTime(); 12 | 13 | void setLastPatrolTime(long time); 14 | 15 | @Override 16 | default int compareTo(@NotNull Patrolable o) { 17 | if (getLastPatrolTime() < o.getLastPatrolTime()) { 18 | return -1; 19 | } else if (getLastPatrolTime() > o.getLastPatrolTime()) { 20 | return 1; 21 | } 22 | return Integer.compare(getUniqueId().hashCode(), o.getUniqueId().hashCode()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/SkullData.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface SkullData { 8 | 9 | String defaultOwner = ""; 10 | String defaultTextureBase64 = ""; 11 | UUID defaultUUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); 12 | 13 | @NotNull 14 | String getTextureBase64(); 15 | 16 | @NotNull 17 | String getOwner(); 18 | 19 | @NotNull 20 | UUID getUUID(); 21 | 22 | static Builder builder() { 23 | return new SkullDataImpl.Builder(); 24 | } 25 | 26 | interface Builder { 27 | 28 | SkullData.Builder textureBase64(final String base64); 29 | 30 | SkullData.Builder owner(final String owner); 31 | 32 | SkullData.Builder uuid(final UUID uuid); 33 | 34 | SkullData build(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/SkullDataImpl.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public record SkullDataImpl( 8 | String owner, 9 | UUID uuid, 10 | String textureBase64 11 | ) implements SkullData { 12 | 13 | @NotNull 14 | @Override 15 | public String getTextureBase64() { 16 | return textureBase64; 17 | } 18 | 19 | @NotNull 20 | @Override 21 | public String getOwner() { 22 | return owner; 23 | } 24 | 25 | @NotNull 26 | @Override 27 | public UUID getUUID() { 28 | return uuid; 29 | } 30 | 31 | public static class Builder implements SkullData.Builder { 32 | 33 | private String owner = SkullData.defaultOwner; 34 | private String textureBase64 = SkullData.defaultTextureBase64; 35 | private UUID uuid = SkullData.defaultUUID; 36 | 37 | @Override 38 | public SkullData.Builder textureBase64(String base64) { 39 | this.textureBase64 = base64; 40 | return this; 41 | } 42 | 43 | @Override 44 | public SkullData.Builder owner(String owner) { 45 | this.owner = owner; 46 | return this; 47 | } 48 | 49 | @Override 50 | public SkullData.Builder uuid(UUID uuid) { 51 | this.uuid = uuid; 52 | return this; 53 | } 54 | 55 | @Override 56 | public SkullData build() { 57 | return new SkullDataImpl(owner, uuid, textureBase64); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/SkullFetchException.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull; 2 | 3 | public class SkullFetchException extends RuntimeException { 4 | 5 | private final Reason reason; 6 | 7 | public SkullFetchException(Reason reason, String message) { 8 | super(message); 9 | this.reason = reason; 10 | } 11 | 12 | public SkullFetchException(Reason reason, String message, Throwable t) { 13 | super(message, t); 14 | this.reason = reason; 15 | } 16 | 17 | public Reason getReason() { 18 | return reason; 19 | } 20 | 21 | public enum Reason { 22 | 23 | THROTTLED, 24 | INVALID, 25 | INTERNAL, 26 | UNKNOWN, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/SkullManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.FetcherProviderRegistry; 5 | import net.momirealms.sparrow.common.util.Either; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.UUID; 9 | import java.util.concurrent.CompletableFuture; 10 | 11 | public interface SkullManager { 12 | 13 | CompletableFuture getSkull(@NotNull Either either); 14 | 15 | CompletableFuture getSkull(@NotNull SkullArgument argument); 16 | 17 | FetcherProviderRegistry getProviderRegistry(); 18 | 19 | void disable(); 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/argument/NameSkullArgument.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.argument; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public record NameSkullArgument(@NotNull String name) implements SkullArgument { 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/argument/SkullArgument.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.argument; 2 | 3 | public interface SkullArgument { 4 | } 5 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/argument/URLSkullArgument.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.argument; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.net.URL; 6 | 7 | public record URLSkullArgument(@NotNull URL url) implements SkullArgument { 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/argument/UUIDSkullArgument.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.argument; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public record UUIDSkullArgument(@NotNull UUID uniqueId) implements SkullArgument { 8 | } 9 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/FetcherProviderRegistry.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.FetcherProvider; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public interface FetcherProviderRegistry { 8 | 9 | static FetcherProviderRegistry create() { 10 | return new FetcherProviderRegistryImpl(); 11 | } 12 | 13 | void register(@NotNull String key, @NotNull FetcherProvider provider); 14 | 15 | void unregister(@NotNull String key); 16 | 17 | SkullFetcher getSkullFetcher(@NotNull SkullArgument argument); 18 | 19 | void close(); 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/FetcherProviderRegistryImpl.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.provider.FetcherProvider; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.LinkedHashMap; 8 | import java.util.Optional; 9 | 10 | public class FetcherProviderRegistryImpl implements FetcherProviderRegistry { 11 | 12 | private final LinkedHashMap registeredProviders = new LinkedHashMap<>(); 13 | 14 | @Override 15 | public void register(@NotNull String key, @NotNull FetcherProvider provider) { 16 | this.registeredProviders.put(key, provider); 17 | } 18 | 19 | @Override 20 | public void unregister(@NotNull String key) { 21 | this.registeredProviders.remove(key); 22 | } 23 | 24 | @Override 25 | public void close() { 26 | this.registeredProviders.clear(); 27 | } 28 | 29 | @Override 30 | public SkullFetcher getSkullFetcher(@NotNull SkullArgument argument) { 31 | for (FetcherProvider provider : this.registeredProviders.values()) { 32 | Optional fetcher = provider.getOrEmpty(argument); 33 | if (fetcher.isPresent()) { 34 | return fetcher.get(); 35 | } 36 | } 37 | throw new IllegalStateException("No SkullFetcher found for argument: " + argument); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/SkullFetcher.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | 5 | import java.util.concurrent.CompletableFuture; 6 | 7 | public interface SkullFetcher { 8 | 9 | CompletableFuture fetchData(); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/impl/MineskinFetcher.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher.impl; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.SkullData; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 5 | import net.momirealms.sparrow.common.feature.skull.mineskin.MineskinClient; 6 | import net.momirealms.sparrow.common.feature.skull.mineskin.SkinOptions; 7 | import net.momirealms.sparrow.common.feature.skull.mineskin.Variant; 8 | import net.momirealms.sparrow.common.feature.skull.mineskin.Visibility; 9 | 10 | import java.net.URL; 11 | import java.util.concurrent.CompletableFuture; 12 | 13 | public class MineskinFetcher implements SkullFetcher { 14 | 15 | private final CompletableFuture futureSkull; 16 | 17 | public MineskinFetcher(URL url) { 18 | this.futureSkull = fetchSkull(url); 19 | } 20 | 21 | @Override 22 | public CompletableFuture fetchData() { 23 | return futureSkull; 24 | } 25 | 26 | private static CompletableFuture fetchSkull(URL url) { 27 | MineskinClient client = new MineskinClient("anonymous"); 28 | return client.generateUrl(url.toString(), SkinOptions.create("", Variant.AUTO, Visibility.PRIVATE)) 29 | .thenApplyAsync(skin -> SkullData.builder() 30 | .owner(skin.name) 31 | .uuid(skin.data.uuid) 32 | .textureBase64(skin.data.texture.value) 33 | .build() 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/provider/APIFetcherProvider.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher.provider; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.NameSkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 5 | import net.momirealms.sparrow.common.feature.skull.argument.UUIDSkullArgument; 6 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 7 | import net.momirealms.sparrow.common.feature.skull.fetcher.impl.APIFetcher; 8 | import net.momirealms.sparrow.common.util.Either; 9 | 10 | import java.util.Optional; 11 | 12 | public class APIFetcherProvider implements FetcherProvider { 13 | 14 | @Override 15 | public Optional getOrEmpty(SkullArgument skullArgument) { 16 | if (skullArgument instanceof NameSkullArgument nameSkullArgument) { 17 | return Optional.of(new APIFetcher(Either.ofPrimary(nameSkullArgument.name()))); 18 | } else if (skullArgument instanceof UUIDSkullArgument uuidSkullArgument) { 19 | return Optional.of(new APIFetcher(Either.ofFallback(uuidSkullArgument.uniqueId()))); 20 | } 21 | return Optional.empty(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/provider/FetcherProvider.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher.provider; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 5 | 6 | import java.util.Optional; 7 | 8 | public interface FetcherProvider { 9 | 10 | Optional getOrEmpty(SkullArgument skullArgument); 11 | } 12 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/fetcher/provider/MineSkinFetcherProvider.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.fetcher.provider; 2 | 3 | import net.momirealms.sparrow.common.feature.skull.argument.SkullArgument; 4 | import net.momirealms.sparrow.common.feature.skull.argument.URLSkullArgument; 5 | import net.momirealms.sparrow.common.feature.skull.fetcher.SkullFetcher; 6 | import net.momirealms.sparrow.common.feature.skull.fetcher.impl.MineskinFetcher; 7 | 8 | import java.util.Optional; 9 | 10 | public class MineSkinFetcherProvider implements FetcherProvider { 11 | 12 | @Override 13 | public Optional getOrEmpty(SkullArgument skullArgument) { 14 | if (skullArgument instanceof URLSkullArgument urlSkullArgument) { 15 | return Optional.of(new MineskinFetcher(urlSkullArgument.url())); 16 | } 17 | return Optional.empty(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/SkinOptions.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | public class SkinOptions { 6 | 7 | private static final String URL_FORMAT = "name=%s&model=%s&visibility=%s"; 8 | 9 | private final String name; 10 | private final Variant variant; 11 | private final Visibility visibility; 12 | 13 | private SkinOptions(String name, Variant variant, Visibility visibility) { 14 | this.name = name; 15 | this.variant = variant; 16 | this.visibility = visibility; 17 | } 18 | 19 | protected JsonObject toJson() { 20 | JsonObject json = new JsonObject(); 21 | if (name != null && !name.isEmpty()) { 22 | json.addProperty("name", name); 23 | } 24 | if (variant != null && variant != Variant.AUTO) { 25 | json.addProperty("variant", variant.getName()); 26 | } 27 | if (visibility != null) { 28 | json.addProperty("visibility", visibility.getCode()); 29 | } 30 | return json; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public static SkinOptions create(String name, Variant variant, Visibility visibility) { 38 | return new SkinOptions(name, variant, visibility); 39 | } 40 | 41 | public static SkinOptions name(String name) { 42 | return new SkinOptions(name, Variant.AUTO, Visibility.PUBLIC); 43 | } 44 | 45 | public static SkinOptions none() { 46 | return new SkinOptions("", Variant.AUTO, Visibility.PUBLIC); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/Variant.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin; 2 | 3 | public enum Variant { 4 | 5 | AUTO(""), 6 | CLASSIC("classic"), 7 | SLIM("slim"); 8 | 9 | private final String name; 10 | 11 | Variant(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/Visibility.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin; 2 | 3 | public enum Visibility { 4 | 5 | PUBLIC(0), 6 | PRIVATE(1); 7 | 8 | private final int code; 9 | 10 | Visibility(int code) { 11 | this.code = code; 12 | } 13 | 14 | public int getCode() { 15 | return code; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/data/DelayInfo.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin.data; 2 | 3 | public class DelayInfo { 4 | 5 | public int millis; 6 | public int seconds; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/data/MineskinException.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin.data; 2 | 3 | public class MineskinException extends RuntimeException { 4 | 5 | public MineskinException() { 6 | } 7 | 8 | public MineskinException(String message) { 9 | super(message); 10 | } 11 | 12 | public MineskinException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public MineskinException(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public MineskinException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 21 | super(message, cause, enableSuppression, writableStackTrace); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/data/Skin.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin.data; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class Skin { 6 | 7 | public int id; 8 | public String uuid; 9 | public String name; 10 | public SkinData data; 11 | public long timestamp; 12 | @SerializedName("private") 13 | public boolean prvate; 14 | public int views; 15 | public int accountId; 16 | public DelayInfo delayInfo; 17 | } 18 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/data/SkinData.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin.data; 2 | 3 | import java.util.UUID; 4 | 5 | public class SkinData { 6 | 7 | public UUID uuid; 8 | public Texture texture; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/skull/mineskin/data/Texture.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.skull.mineskin.data; 2 | 3 | public class Texture { 4 | 5 | public String value; 6 | public String signature; 7 | public String url; 8 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/feature/toast/AdvancementType.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.feature.toast; 2 | 3 | public enum AdvancementType { 4 | TASK, 5 | GOAL, 6 | CHALLENGE 7 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/helper/GsonHelper.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.helper; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | public class GsonHelper { 7 | 8 | private final Gson gson; 9 | 10 | public GsonHelper() { 11 | this.gson = new GsonBuilder() 12 | .create(); 13 | } 14 | 15 | public Gson getGson() { 16 | return gson; 17 | } 18 | 19 | public static Gson get() { 20 | return SingletonHolder.INSTANCE.getGson(); 21 | } 22 | 23 | private static class SingletonHolder { 24 | private static final GsonHelper INSTANCE = new GsonHelper(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/locale/MiniMessageTranslationRegistry.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.locale; 2 | 3 | import net.kyori.adventure.key.Key; 4 | import net.kyori.adventure.text.minimessage.MiniMessage; 5 | import net.kyori.adventure.translation.Translator; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Locale; 9 | import java.util.Map; 10 | import java.util.Set; 11 | import java.util.function.Function; 12 | 13 | import static java.util.Objects.requireNonNull; 14 | 15 | public interface MiniMessageTranslationRegistry extends Translator { 16 | 17 | static @NotNull MiniMessageTranslationRegistry create(final Key name, final MiniMessage miniMessage) { 18 | return new MiniMessageTranslationRegistryImpl(requireNonNull(name, "name"), requireNonNull(miniMessage, "MiniMessage")); 19 | } 20 | 21 | void register(@NotNull String key, @NotNull Locale locale, @NotNull String format); 22 | 23 | void unregister(@NotNull String key); 24 | 25 | boolean contains(@NotNull String key); 26 | 27 | void defaultLocale(@NotNull Locale defaultLocale); 28 | 29 | default void registerAll(final @NotNull Locale locale, final @NotNull Map bundle) { 30 | this.registerAll(locale, bundle.keySet(), bundle::get); 31 | } 32 | 33 | default void registerAll(final @NotNull Locale locale, final @NotNull Set keys, final Function function) { 34 | IllegalArgumentException firstError = null; 35 | int errorCount = 0; 36 | for (final String key : keys) { 37 | try { 38 | this.register(key, locale, function.apply(key)); 39 | } catch (final IllegalArgumentException e) { 40 | if (firstError == null) { 41 | firstError = e; 42 | } 43 | errorCount++; 44 | } 45 | } 46 | if (firstError != null) { 47 | if (errorCount == 1) { 48 | throw firstError; 49 | } else if (errorCount > 1) { 50 | throw new IllegalArgumentException(String.format("Invalid key (and %d more)", errorCount - 1), firstError); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/locale/MiniMessageTranslator.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.locale; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.renderer.TranslatableComponentRenderer; 5 | import net.kyori.adventure.translation.Translator; 6 | import net.kyori.examination.Examinable; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Locale; 10 | 11 | public interface MiniMessageTranslator extends Translator, Examinable { 12 | 13 | static @NotNull MiniMessageTranslator translator() { 14 | return MiniMessageTranslatorImpl.INSTANCE; 15 | } 16 | 17 | static @NotNull TranslatableComponentRenderer renderer() { 18 | return MiniMessageTranslatorImpl.INSTANCE.renderer; 19 | } 20 | 21 | static @NotNull Component render(final @NotNull Component component, final @NotNull Locale locale) { 22 | return renderer().render(component, locale); 23 | } 24 | 25 | @NotNull Iterable sources(); 26 | 27 | boolean addSource(final @NotNull Translator source); 28 | 29 | boolean removeSource(final @NotNull Translator source); 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/locale/SparrowCaptionFormatter.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.locale; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import org.checkerframework.checker.nullness.qual.NonNull; 5 | import org.incendo.cloud.caption.Caption; 6 | import org.incendo.cloud.caption.CaptionVariable; 7 | import org.incendo.cloud.minecraft.extras.caption.ComponentCaptionFormatter; 8 | 9 | import java.util.List; 10 | 11 | public class SparrowCaptionFormatter implements ComponentCaptionFormatter { 12 | 13 | @Override 14 | public @NonNull Component formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull List<@NonNull CaptionVariable> variables) { 15 | Component component = ComponentCaptionFormatter.translatable().formatCaption(captionKey, recipient, caption, variables); 16 | return TranslationManager.render(component); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/locale/SparrowCaptionKeys.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.locale; 2 | 3 | import org.incendo.cloud.caption.Caption; 4 | 5 | public final class SparrowCaptionKeys { 6 | 7 | public static final Caption ARGUMENT_PARSE_FAILURE_TIME = Caption.of("argument.parse.failure.time"); 8 | public static final Caption ARGUMENT_PARSE_FAILURE_URL = Caption.of("argument.parse.failure.url"); 9 | public static final Caption ARGUMENT_PARSE_FAILURE_NAMEDTEXTCOLOR = Caption.of("argument.parse.failure.namedtextcolor"); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/locale/SparrowCaptionProvider.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.locale; 2 | 3 | import org.checkerframework.checker.nullness.qual.NonNull; 4 | import org.incendo.cloud.caption.CaptionProvider; 5 | import org.incendo.cloud.caption.DelegatingCaptionProvider; 6 | 7 | public final class SparrowCaptionProvider extends DelegatingCaptionProvider { 8 | 9 | private static final CaptionProvider PROVIDER = CaptionProvider.constantProvider() 10 | .putCaption(SparrowCaptionKeys.ARGUMENT_PARSE_FAILURE_URL, "") 11 | .putCaption(SparrowCaptionKeys.ARGUMENT_PARSE_FAILURE_TIME, "") 12 | .putCaption(SparrowCaptionKeys.ARGUMENT_PARSE_FAILURE_NAMEDTEXTCOLOR, "") 13 | .build(); 14 | 15 | @SuppressWarnings("unchecked") 16 | @Override 17 | public @NonNull CaptionProvider delegate() { 18 | return (CaptionProvider) PROVIDER; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/Platform.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.plugin; 2 | 3 | public enum Platform { 4 | BUKKIT("Bukkit"), 5 | BUNGEECORD("BungeeCord"), 6 | VELOCITY("Velocity"); 7 | 8 | private final String platform; 9 | 10 | Platform(String platform) { 11 | this.platform = platform; 12 | } 13 | 14 | public String getPlatformName() { 15 | return platform; 16 | } 17 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/SparrowPlugin.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.plugin; 2 | 3 | import net.momirealms.sparrow.common.config.ConfigManager; 4 | import net.momirealms.sparrow.common.dependency.DependencyManager; 5 | import net.momirealms.sparrow.common.event.EventManager; 6 | import net.momirealms.sparrow.common.locale.TranslationManager; 7 | import net.momirealms.sparrow.common.plugin.bootstrap.SparrowBootstrap; 8 | 9 | public interface SparrowPlugin { 10 | 11 | DependencyManager getDependencyManager(); 12 | 13 | SparrowBootstrap getBootstrap(); 14 | 15 | TranslationManager getTranslationManager(); 16 | 17 | ConfigManager getConfigManager(); 18 | 19 | EventManager getEventManager(); 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/bootstrap/BootstrappedWithLoader.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.plugin.bootstrap; 2 | 3 | public interface BootstrappedWithLoader { 4 | 5 | /** 6 | * Gets the loader object that did the bootstrapping. 7 | * 8 | * @return the loader 9 | */ 10 | Object getLoader(); 11 | 12 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/classpath/ClassPathAppender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.classpath; 27 | 28 | import java.nio.file.Path; 29 | 30 | /** 31 | * Interface which allows access to add URLs to the plugin classpath at runtime. 32 | */ 33 | public interface ClassPathAppender extends AutoCloseable { 34 | 35 | void addJarToClasspath(Path file); 36 | 37 | @Override 38 | default void close() { 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/logging/JavaPluginLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.logging; 27 | 28 | import java.util.logging.Level; 29 | import java.util.logging.Logger; 30 | 31 | public class JavaPluginLogger implements PluginLogger { 32 | private final Logger logger; 33 | 34 | public JavaPluginLogger(Logger logger) { 35 | this.logger = logger; 36 | } 37 | 38 | @Override 39 | public void info(String s) { 40 | this.logger.info(s); 41 | } 42 | 43 | @Override 44 | public void warn(String s) { 45 | this.logger.warning(s); 46 | } 47 | 48 | @Override 49 | public void warn(String s, Throwable t) { 50 | this.logger.log(Level.WARNING, s, t); 51 | } 52 | 53 | @Override 54 | public void severe(String s) { 55 | this.logger.severe(s); 56 | } 57 | 58 | @Override 59 | public void severe(String s, Throwable t) { 60 | this.logger.log(Level.SEVERE, s, t); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/logging/Log4jPluginLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.logging; 27 | 28 | import org.apache.logging.log4j.Logger; 29 | 30 | public class Log4jPluginLogger implements PluginLogger { 31 | private final Logger logger; 32 | 33 | public Log4jPluginLogger(Logger logger) { 34 | this.logger = logger; 35 | } 36 | 37 | @Override 38 | public void info(String s) { 39 | this.logger.info(s); 40 | } 41 | 42 | @Override 43 | public void warn(String s) { 44 | this.logger.warn(s); 45 | } 46 | 47 | @Override 48 | public void warn(String s, Throwable t) { 49 | this.logger.warn(s, t); 50 | } 51 | 52 | @Override 53 | public void severe(String s) { 54 | this.logger.error(s); 55 | } 56 | 57 | @Override 58 | public void severe(String s, Throwable t) { 59 | this.logger.error(s, t); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/logging/PluginLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.logging; 27 | 28 | /** 29 | * Represents the logger instance being used by Sparrow on the platform. 30 | * 31 | *

Messages sent using the logger are sent prefixed with the Sparrow tag, 32 | * and on some implementations will be colored depending on the message type.

33 | */ 34 | public interface PluginLogger { 35 | 36 | void info(String s); 37 | 38 | void warn(String s); 39 | 40 | void warn(String s, Throwable t); 41 | 42 | void severe(String s); 43 | 44 | void severe(String s, Throwable t); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/logging/Slf4jPluginLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.logging; 27 | 28 | import org.slf4j.Logger; 29 | 30 | public class Slf4jPluginLogger implements PluginLogger { 31 | private final Logger logger; 32 | 33 | public Slf4jPluginLogger(Logger logger) { 34 | this.logger = logger; 35 | } 36 | 37 | @Override 38 | public void info(String s) { 39 | this.logger.info(s); 40 | } 41 | 42 | @Override 43 | public void warn(String s) { 44 | this.logger.warn(s); 45 | } 46 | 47 | @Override 48 | public void warn(String s, Throwable t) { 49 | this.logger.warn(s, t); 50 | } 51 | 52 | @Override 53 | public void severe(String s) { 54 | this.logger.error(s); 55 | } 56 | 57 | @Override 58 | public void severe(String s, Throwable t) { 59 | this.logger.error(s, t); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/scheduler/RegionExecutor.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.plugin.scheduler; 2 | 3 | public interface RegionExecutor { 4 | 5 | void execute(Runnable r, T l); 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/plugin/scheduler/SchedulerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.plugin.scheduler; 27 | 28 | /** 29 | * Represents a scheduled task 30 | */ 31 | public interface SchedulerTask { 32 | 33 | /** 34 | * Cancels the task. 35 | */ 36 | void cancel(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/script/exception/ScriptReaderException.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.script.exception; 2 | 3 | public class ScriptReaderException extends RuntimeException { 4 | 5 | public ScriptReaderException(String message) { 6 | super(message); 7 | } 8 | 9 | public ScriptReaderException(String message, Throwable cause) { 10 | super(message, cause); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/sender/DummyConsoleSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.common.sender; 27 | 28 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 29 | 30 | import java.util.UUID; 31 | 32 | public abstract class DummyConsoleSender implements Sender { 33 | private final SparrowPlugin platform; 34 | 35 | public DummyConsoleSender(SparrowPlugin plugin) { 36 | this.platform = plugin; 37 | } 38 | 39 | @Override 40 | public void performCommand(String commandLine) { 41 | } 42 | 43 | @Override 44 | public boolean isConsole() { 45 | return true; 46 | } 47 | 48 | @Override 49 | public SparrowPlugin getPlugin() { 50 | return this.platform; 51 | } 52 | 53 | @Override 54 | public UUID getUniqueId() { 55 | return Sender.CONSOLE_UUID; 56 | } 57 | 58 | @Override 59 | public String getName() { 60 | return Sender.CONSOLE_NAME; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/storage/StorageFactory.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.storage; 2 | 3 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 4 | 5 | public class StorageFactory { 6 | 7 | private SparrowPlugin plugin; 8 | 9 | public StorageFactory(SparrowPlugin plugin) { 10 | this.plugin = plugin; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/storage/StorageType.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.storage; 2 | 3 | public enum StorageType { 4 | 5 | H2, 6 | MYSQL, 7 | MARIADB, 8 | MONGODB, 9 | YAML, 10 | JSON, 11 | POSTGRESQL, 12 | CUSTOM 13 | } 14 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/storage/impl/StorageInterface.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.storage.impl; 2 | 3 | import net.momirealms.sparrow.common.plugin.SparrowPlugin; 4 | import net.momirealms.sparrow.common.storage.StorageType; 5 | 6 | public interface StorageInterface { 7 | SparrowPlugin getPlugin(); 8 | 9 | StorageType getType(); 10 | 11 | void init(); 12 | 13 | void shutdown(); 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/user/User.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.user; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Represents a user. 9 | * @param The type of the user. 10 | */ 11 | public interface User { 12 | 13 | T getPlayer(); 14 | 15 | boolean isOnline(); 16 | 17 | String getName(); 18 | 19 | @NotNull 20 | UUID getUniqueId(); 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/user/UserManager.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.user; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface UserManager> { 8 | 9 | @NotNull T getUser(UUID uniqueId); 10 | } 11 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import java.lang.reflect.Array; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class ArrayUtils { 8 | 9 | private ArrayUtils() {} 10 | 11 | public static T[] subArray(T[] array, int index) { 12 | if (index < 0) { 13 | throw new IllegalArgumentException("Index should be a value no lower than 0"); 14 | } 15 | if (array.length <= index) { 16 | @SuppressWarnings("unchecked") 17 | T[] emptyArray = (T[]) Array.newInstance(array.getClass().getComponentType(), 0); 18 | return emptyArray; 19 | } 20 | @SuppressWarnings("unchecked") 21 | T[] subArray = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length - index); 22 | System.arraycopy(array, index, subArray, 0, array.length - index); 23 | return subArray; 24 | } 25 | 26 | public static List splitArray(T[] array, int chunkSize) { 27 | List result = new ArrayList<>(); 28 | for (int i = 0; i < array.length; i += chunkSize) { 29 | int end = Math.min(array.length, i + chunkSize); 30 | @SuppressWarnings("unchecked") 31 | T[] chunk = (T[]) Array.newInstance(array.getClass().getComponentType(), end - i); 32 | System.arraycopy(array, i, chunk, 0, end - i); 33 | result.add(chunk); 34 | } 35 | return result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/Commons.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.nio.charset.StandardCharsets; 6 | 7 | public class Commons { 8 | 9 | public static String readInput(InputStream inputStream) throws IOException { 10 | var input = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); 11 | inputStream.close(); 12 | return input; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/Either.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import java.util.Optional; 7 | import java.util.function.Function; 8 | 9 | import static java.util.Objects.requireNonNull; 10 | 11 | public interface Either { 12 | 13 | static @NotNull Either ofPrimary(final @NotNull U value) { 14 | return EitherImpl.of(requireNonNull(value, "value"), null); 15 | } 16 | 17 | static @NotNull Either ofFallback(final @NotNull V value) { 18 | return EitherImpl.of(null, requireNonNull(value, "value")); 19 | } 20 | 21 | @NotNull 22 | Optional primary(); 23 | 24 | @NotNull 25 | Optional fallback(); 26 | 27 | default @Nullable U primaryOrMapFallback(final @NotNull Function mapFallback) { 28 | return this.primary().orElseGet(() -> mapFallback.apply(this.fallback().get())); 29 | } 30 | 31 | default @Nullable V fallbackOrMapPrimary(final @NotNull Function mapPrimary) { 32 | return this.fallback().orElseGet(() -> mapPrimary.apply(this.primary().get())); 33 | } 34 | 35 | default @NotNull R mapEither( 36 | final @NotNull Function mapPrimary, 37 | final @NotNull Function mapFallback 38 | ) { 39 | return this.primary() 40 | .map(mapPrimary) 41 | .orElseGet(() -> this.fallback().map(mapFallback).get()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.DirectoryStream; 5 | import java.nio.file.FileAlreadyExistsException; 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | 9 | public class FileUtils { 10 | 11 | private FileUtils() {} 12 | 13 | public static Path createFileIfNotExists(Path path) throws IOException { 14 | if (!Files.exists(path)) { 15 | Files.createFile(path); 16 | } 17 | return path; 18 | } 19 | 20 | public static Path createDirectoryIfNotExists(Path path) throws IOException { 21 | if (Files.exists(path) && (Files.isDirectory(path) || Files.isSymbolicLink(path))) { 22 | return path; 23 | } 24 | 25 | try { 26 | Files.createDirectory(path); 27 | } catch (FileAlreadyExistsException e) { 28 | // ignore 29 | } 30 | 31 | return path; 32 | } 33 | 34 | public static Path createDirectoriesIfNotExists(Path path) throws IOException { 35 | if (Files.exists(path) && (Files.isDirectory(path) || Files.isSymbolicLink(path))) { 36 | return path; 37 | } 38 | 39 | try { 40 | Files.createDirectories(path); 41 | } catch (FileAlreadyExistsException e) { 42 | // ignore 43 | } 44 | 45 | return path; 46 | } 47 | 48 | public static void deleteDirectory(Path path) throws IOException { 49 | if (!Files.exists(path) || !Files.isDirectory(path)) { 50 | return; 51 | } 52 | 53 | try (DirectoryStream contents = Files.newDirectoryStream(path)) { 54 | for (Path file : contents) { 55 | if (Files.isDirectory(file)) { 56 | deleteDirectory(file); 57 | } else { 58 | Files.delete(file); 59 | } 60 | } 61 | } 62 | 63 | Files.delete(path); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/Location.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | public class Location { 4 | 5 | private final double x; 6 | private final double y; 7 | private final double z; 8 | private final String world; 9 | 10 | public static Location of(double x, double y, double z, String world) { 11 | return new Location(x, y, z, world); 12 | } 13 | 14 | public Location(double x, double y, double z, String world) { 15 | this.x = x; 16 | this.y = y; 17 | this.z = z; 18 | this.world = world; 19 | } 20 | 21 | public double getX() { 22 | return x; 23 | } 24 | 25 | public double getY() { 26 | return y; 27 | } 28 | 29 | public double getZ() { 30 | return z; 31 | } 32 | 33 | public String getWorld() { 34 | return world; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/MapUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | public class MapUtils { 4 | 5 | 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/NetWorkUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.IOException; 7 | import java.io.InputStreamReader; 8 | import java.net.HttpURLConnection; 9 | import java.net.URL; 10 | 11 | public final class NetWorkUtils { 12 | private NetWorkUtils() { 13 | } 14 | 15 | @NotNull 16 | public static String getUrlResponse(@NotNull URL url) throws IOException { 17 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 18 | connection.setRequestMethod("GET"); 19 | 20 | BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); 21 | String line; 22 | StringBuilder responseContent = new StringBuilder(); 23 | while ((line = reader.readLine()) != null) { 24 | responseContent.append(line); 25 | } 26 | reader.close(); 27 | return responseContent.toString(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) <2022> 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.momirealms.sparrow.common.util; 19 | 20 | public record Pair(L left, R right) { 21 | 22 | public static Pair of(final L left, final R right) { 23 | return new Pair<>(left, right); 24 | } 25 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/RandomUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import java.util.Random; 4 | import java.util.concurrent.ThreadLocalRandom; 5 | 6 | public class RandomUtils { 7 | 8 | private final Random random; 9 | 10 | private RandomUtils() { 11 | random = ThreadLocalRandom.current(); 12 | } 13 | 14 | private static class SingletonHolder { 15 | private static final RandomUtils INSTANCE = new RandomUtils(); 16 | } 17 | 18 | private static RandomUtils getInstance() { 19 | return SingletonHolder.INSTANCE; 20 | } 21 | 22 | public static int generateRandomInt(int min, int max) { 23 | return getInstance().random.nextInt(max - min + 1) + min; 24 | } 25 | 26 | public static double generateRandomDouble(double min, double max) { 27 | return min + (max - min) * getInstance().random.nextDouble(); 28 | } 29 | 30 | public static boolean generateRandomBoolean() { 31 | return getInstance().random.nextBoolean(); 32 | } 33 | 34 | public static T getRandomElementFromArray(T[] array) { 35 | int index = getInstance().random.nextInt(array.length); 36 | return array[index]; 37 | } 38 | 39 | public static T[] getRandomElementsFromArray(T[] array, int count) { 40 | if (count > array.length) { 41 | throw new IllegalArgumentException("Count cannot be greater than array length"); 42 | } 43 | 44 | @SuppressWarnings("unchecked") 45 | T[] result = (T[]) new Object[count]; 46 | 47 | for (int i = 0; i < count; i++) { 48 | int index = getInstance().random.nextInt(array.length - i); 49 | result[i] = array[index]; 50 | array[index] = array[array.length - i - 1]; 51 | } 52 | 53 | return result; 54 | } 55 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/ThrowableFunction.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | public interface ThrowableFunction { 4 | 5 | V apply(T t) throws E; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/Tuple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) <2022> 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.momirealms.sparrow.common.util; 19 | 20 | public class Tuple { 21 | 22 | private L left; 23 | private M mid; 24 | private R right; 25 | 26 | public Tuple(L left, M mid, R right) { 27 | this.left = left; 28 | this.mid = mid; 29 | this.right = right; 30 | } 31 | 32 | public static Tuple of(final L left, final M mid, final R right) { 33 | return new Tuple<>(left, mid, right); 34 | } 35 | 36 | public L getLeft() { 37 | return left; 38 | } 39 | 40 | public void setLeft(L left) { 41 | this.left = left; 42 | } 43 | 44 | public M getMid() { 45 | return mid; 46 | } 47 | 48 | public void setMid(M mid) { 49 | this.mid = mid; 50 | } 51 | 52 | public R getRight() { 53 | return right; 54 | } 55 | 56 | public void setRight(R right) { 57 | this.right = right; 58 | } 59 | } -------------------------------------------------------------------------------- /common/src/main/java/net/momirealms/sparrow/common/util/UUIDUtils.java: -------------------------------------------------------------------------------- 1 | package net.momirealms.sparrow.common.util; 2 | 3 | import java.math.BigInteger; 4 | import java.util.UUID; 5 | 6 | public class UUIDUtils { 7 | 8 | public static UUID fromUnDashedUUID(String id) { 9 | return id == null ? null : new UUID( 10 | new BigInteger(id.substring(0, 16), 16).longValue(), 11 | new BigInteger(id.substring(16, 32), 16).longValue() 12 | ); 13 | } 14 | 15 | public static String toUnDashedUUID(UUID uuid) { 16 | return uuid.toString().replace("-", ""); 17 | } 18 | 19 | public static UUID uuidFromIntArray(int[] array) { 20 | return new UUID((long)array[0] << 32 | (long)array[1] & 4294967295L, (long)array[2] << 32 | (long)array[3] & 4294967295L); 21 | } 22 | 23 | public static int[] uuidToIntArray(UUID uuid) { 24 | long l = uuid.getMostSignificantBits(); 25 | long m = uuid.getLeastSignificantBits(); 26 | return leastMostToIntArray(l, m); 27 | } 28 | 29 | private static int[] leastMostToIntArray(long uuidMost, long uuidLeast) { 30 | return new int[]{(int)(uuidMost >> 32), (int)uuidMost, (int)(uuidLeast >> 32), (int)uuidLeast}; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/resources/library-version.properties: -------------------------------------------------------------------------------- 1 | asm=${asm_version} 2 | asm-commons=${asm_commons_version} 3 | jar-relocator=${jar_relocator_version} 4 | h2-driver=${h2_driver_version} 5 | sqlite-driver=${sqlite_driver_version} 6 | cloud-core=${cloud_core_version} 7 | cloud-brigadier=${cloud_brigadier_version} 8 | cloud-services=${cloud_services_version} 9 | cloud-bukkit=${cloud_bukkit_version} 10 | cloud-paper=${cloud_paper_version} 11 | cloud-minecraft-extras=${cloud_minecraft_extras_version} 12 | boosted-yaml=${boosted_yaml_version} 13 | byte-buddy=${byte_buddy_version} 14 | mongodb-driver-core=${mongodb_driver_version} 15 | mariadb-java-client=${mariadb_driver_version} 16 | mysql-connector-j=${mysql_driver_version} 17 | hikari-cp=${hikari_version} 18 | commons-pool=${commons_pool_version} 19 | bstats-base=${bstats_version} 20 | geantyref=${geantyref_version} 21 | gson=${gson_version} 22 | caffeine=${caffeine_version} 23 | lettuce-core=${lettuce_version} -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project settings 2 | # Rule: [major update].[feature update].[bug fix] 3 | project_version=1.12.0 4 | config_version=2 5 | project_group=net.momirealms 6 | 7 | # Dependency settings 8 | paper_version=1.20.4 9 | jetbrains_annotations_version=24.0.0 10 | slf4j_version=2.0.16 11 | log4j_version=2.24.1 12 | gson_version=2.11.0 13 | asm_version=9.7.1 14 | asm_commons_version=9.7.1 15 | jar_relocator_version=1.7 16 | h2_driver_version=2.3.232 17 | sqlite_driver_version=3.48.0.0 18 | adventure_bundle_version=4.18.0 19 | adventure_platform_version=4.3.4 20 | sparrow_heart_version=0.49 21 | cloud_core_version=2.0.0 22 | cloud_services_version=2.0.0 23 | cloud_brigadier_version=2.0.0-beta.10 24 | cloud_bukkit_version=2.0.0-beta.10 25 | cloud_paper_version=2.0.0-beta.10 26 | cloud_minecraft_extras_version=2.0.0-beta.10 27 | boosted_yaml_version=1.3.7 28 | byte_buddy_version=1.14.18 29 | mojang_brigadier_version=1.0.18 30 | mongodb_driver_version=5.3.1 31 | mariadb_driver_version=3.5.1 32 | mysql_driver_version=9.2.0 33 | hikari_version=5.1.0 34 | commons_pool_version=2.12.0 35 | bstats_version=3.0.2 36 | geantyref_version=1.3.16 37 | caffeine_version=3.1.8 38 | lettuce_version=6.3.2.RELEASE 39 | rtag_version=1.5.9 40 | placeholder_api_version=2.11.6 41 | 42 | # Proxy settings 43 | systemProp.socks.proxyHost=127.0.0.1 44 | systemProp.socks.proxyPort=7890 45 | systemProp.http.proxyHost=127.0.0.1 46 | systemProp.http.proxyPort=7890 47 | systemProp.https.proxyHost=127.0.0.1 48 | systemProp.https.proxyPort=7890 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 27 00:59:14 SGT 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /loader/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /loader/build.gradle.kts: -------------------------------------------------------------------------------- 1 | java { 2 | sourceCompatibility = JavaVersion.VERSION_17 3 | targetCompatibility = JavaVersion.VERSION_17 4 | toolchain { 5 | languageVersion = JavaLanguageVersion.of(17) 6 | } 7 | } 8 | 9 | tasks.withType { 10 | options.encoding = "UTF-8" 11 | options.release.set(17) 12 | dependsOn(tasks.clean) 13 | } -------------------------------------------------------------------------------- /loader/src/main/java/net/momirealms/sparrow/loader/LoaderBootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.loader; 27 | 28 | public interface LoaderBootstrap { 29 | 30 | void onLoad(); 31 | 32 | default void onEnable() {} 33 | 34 | default void onDisable() {} 35 | 36 | } -------------------------------------------------------------------------------- /loader/src/main/java/net/momirealms/sparrow/loader/LoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of LuckPerms, licensed under the MIT License. 3 | * 4 | * Copyright (c) lucko (Luck) 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | package net.momirealms.sparrow.loader; 27 | 28 | public class LoadingException extends RuntimeException { 29 | 30 | public LoadingException(String message) { 31 | super(message); 32 | } 33 | 34 | public LoadingException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "Sparrow" 2 | include("bukkit") 3 | include("loader") 4 | include("api") 5 | include("common") 6 | include("bukkit-loader") 7 | --------------------------------------------------------------------------------