├── .checkstyle ├── checkstyle.xml └── suppressions.xml ├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── assets │ └── Carbon_Banner.png └── workflows │ ├── build.yml │ └── smoketest.yml ├── .gitignore ├── LICENSE ├── LICENSE_HEADER ├── README.md ├── api ├── build.gradle.kts └── src │ └── main │ └── java │ └── net │ └── draycia │ └── carbon │ └── api │ ├── CarbonChat.java │ ├── CarbonChatProvider.java │ ├── CarbonServer.java │ ├── channels │ ├── ChannelPermissionResult.java │ ├── ChannelPermissionResultImpl.java │ ├── ChannelPermissions.java │ ├── ChannelRegistry.java │ └── ChatChannel.java │ ├── event │ ├── Cancellable.java │ ├── CarbonEvent.java │ ├── CarbonEventHandler.java │ ├── CarbonEventSubscriber.java │ ├── CarbonEventSubscription.java │ └── events │ │ ├── CarbonChannelRegisterEvent.java │ │ ├── CarbonChatEvent.java │ │ ├── CarbonPrivateChatEvent.java │ │ ├── ChannelSwitchEvent.java │ │ ├── PartyJoinEvent.java │ │ └── PartyLeaveEvent.java │ ├── users │ ├── CarbonPlayer.java │ ├── Party.java │ └── UserManager.java │ └── util │ ├── ChatComponentRenderer.java │ ├── InventorySlot.java │ ├── KeyedRenderer.java │ └── KeyedRendererImpl.java ├── build-logic ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ ├── CarbonPermissionsExtension.kt │ ├── CarbonPlatformExtension.kt │ ├── ConfigurablePluginsExt.kt │ ├── FileCopyTask.kt │ ├── carbon.base-conventions.gradle.kts │ ├── carbon.build-logic.gradle.kts │ ├── carbon.configurable-plugins.gradle.kts │ ├── carbon.permissions.gradle.kts │ ├── carbon.platform-conventions.gradle.kts │ ├── carbon.publishing-conventions.gradle.kts │ ├── carbon.shadow-platform.gradle.kts │ ├── constants.kt │ └── extensions.kt ├── build.gradle.kts ├── common ├── build.gradle.kts └── src │ └── main │ ├── java │ ├── com │ │ └── google │ │ │ └── inject │ │ │ └── assistedinject │ │ │ └── FactoryProvider3.java │ └── net │ │ └── draycia │ │ └── carbon │ │ └── common │ │ ├── CarbonChatInternal.java │ │ ├── CarbonCommonModule.java │ │ ├── CarbonPlatformModule.java │ │ ├── DataDirectory.java │ │ ├── PeriodicTasks.java │ │ ├── PlatformScheduler.java │ │ ├── RawChat.java │ │ ├── channels │ │ ├── CarbonChannelRegistry.java │ │ ├── ChannelPermissionsImpl.java │ │ ├── ConfigChannelSettings.java │ │ ├── ConfigChatChannel.java │ │ ├── PartyChatChannel.java │ │ └── messages │ │ │ ├── ConfigChannelMessageSource.java │ │ │ └── ConfigChannelMessages.java │ │ ├── command │ │ ├── CarbonCommand.java │ │ ├── CommandSettings.java │ │ ├── Commander.java │ │ ├── ExecutionCoordinatorHolder.java │ │ ├── ParserFactory.java │ │ ├── PlayerCommander.java │ │ ├── argument │ │ │ ├── CarbonPlayerParser.java │ │ │ └── PlayerSuggestions.java │ │ ├── commands │ │ │ ├── ClearChatCommand.java │ │ │ ├── ContinueCommand.java │ │ │ ├── DebugCommand.java │ │ │ ├── FilterCommand.java │ │ │ ├── HelpCommand.java │ │ │ ├── IgnoreCommand.java │ │ │ ├── IgnoreListCommand.java │ │ │ ├── JoinCommand.java │ │ │ ├── LeaveCommand.java │ │ │ ├── MuteCommand.java │ │ │ ├── MuteInfoCommand.java │ │ │ ├── NicknameCommand.java │ │ │ ├── PartyCommands.java │ │ │ ├── ReloadCommand.java │ │ │ ├── ReplyCommand.java │ │ │ ├── SpyCommand.java │ │ │ ├── ToggleMessagesCommand.java │ │ │ ├── UnignoreCommand.java │ │ │ ├── UnmuteCommand.java │ │ │ ├── UpdateUsernameCommand.java │ │ │ └── WhisperCommand.java │ │ └── exception │ │ │ ├── CommandCompleted.java │ │ │ └── ComponentException.java │ │ ├── config │ │ ├── ClearChatSettings.java │ │ ├── CommandConfig.java │ │ ├── ConfigHeader.java │ │ ├── ConfigManager.java │ │ ├── DatabaseSettings.java │ │ ├── IntegrationConfigContainer.java │ │ ├── MessagingSettings.java │ │ ├── PingSettings.java │ │ └── PrimaryConfig.java │ │ ├── event │ │ ├── CancellableImpl.java │ │ ├── CarbonEventHandlerImpl.java │ │ ├── CarbonEventSubscriptionImpl.java │ │ └── events │ │ │ ├── CarbonChatEventImpl.java │ │ │ ├── CarbonEarlyChatEvent.java │ │ │ ├── CarbonPrivateChatEventImpl.java │ │ │ ├── CarbonReloadEvent.java │ │ │ ├── ChannelRegisterEventImpl.java │ │ │ └── ChannelSwitchEventImpl.java │ │ ├── integration │ │ ├── Integration.java │ │ └── miniplaceholders │ │ │ └── MiniPlaceholdersExpansion.java │ │ ├── listeners │ │ ├── ChatListenerInternal.java │ │ ├── DeafenHandler.java │ │ ├── FilterHandler.java │ │ ├── HyperlinkHandler.java │ │ ├── IgnoreHandler.java │ │ ├── ItemLinkHandler.java │ │ ├── Listener.java │ │ ├── MessagePacketHandler.java │ │ ├── MuteHandler.java │ │ ├── PartyChatSpyHandler.java │ │ ├── PartyPingHandler.java │ │ ├── PingHandler.java │ │ └── RadiusListener.java │ │ ├── messages │ │ ├── CarbonMessageRenderer.java │ │ ├── CarbonMessageSender.java │ │ ├── CarbonMessageSource.java │ │ ├── CarbonMessages.java │ │ ├── NotPlaceholder.java │ │ ├── Option.java │ │ ├── OptionTagResolver.java │ │ ├── PrefixedDelegateIterator.java │ │ ├── RenderForTagResolver.java │ │ ├── SourcedAudience.java │ │ ├── SourcedAudienceImpl.java │ │ ├── SourcedMessageSender.java │ │ ├── SourcedReceiverResolver.java │ │ ├── StandardPlaceholderResolverStrategyButDifferent.java │ │ ├── TagPermissions.java │ │ └── placeholders │ │ │ ├── BooleanPlaceholderResolver.java │ │ │ ├── ComponentPlaceholderResolver.java │ │ │ ├── IntPlaceholderResolver.java │ │ │ ├── KeyPlaceholderResolver.java │ │ │ ├── LongPlaceholderResolver.java │ │ │ ├── OptionPlaceholderResolver.java │ │ │ ├── StringPlaceholderResolver.java │ │ │ └── UUIDPlaceholderResolver.java │ │ ├── messaging │ │ ├── CarbonChatPacketHandler.java │ │ ├── MessagingManager.java │ │ ├── ServerId.java │ │ └── packets │ │ │ ├── CarbonPacket.java │ │ │ ├── ChatMessagePacket.java │ │ │ ├── DisbandPartyPacket.java │ │ │ ├── InvalidatePartyInvitePacket.java │ │ │ ├── LocalPlayerChangePacket.java │ │ │ ├── LocalPlayersPacket.java │ │ │ ├── PacketFactory.java │ │ │ ├── PartyChangePacket.java │ │ │ ├── PartyInvitePacket.java │ │ │ ├── SaveCompletedPacket.java │ │ │ └── WhisperPacket.java │ │ ├── serialisation │ │ └── gson │ │ │ ├── ChatChannelSerializerGson.java │ │ │ ├── LocaleSerializerConfigurate.java │ │ │ └── UUIDSerializerGson.java │ │ ├── users │ │ ├── Backing.java │ │ ├── CachingUserManager.java │ │ ├── CarbonPlayerCommon.java │ │ ├── ConsoleCarbonPlayer.java │ │ ├── MojangProfileResolver.java │ │ ├── NetworkUsers.java │ │ ├── PartyImpl.java │ │ ├── PartyInvites.java │ │ ├── PersistentUserProperty.java │ │ ├── PlatformUserManager.java │ │ ├── PlayerUtils.java │ │ ├── ProfileCache.java │ │ ├── ProfileResolver.java │ │ ├── UserManagerInternal.java │ │ ├── WrappedCarbonPlayer.java │ │ ├── db │ │ │ ├── DatabaseUserManager.java │ │ │ ├── QueriesLocator.java │ │ │ ├── argument │ │ │ │ ├── BinaryUUIDArgumentFactory.java │ │ │ │ ├── ComponentArgumentFactory.java │ │ │ │ └── KeyArgumentFactory.java │ │ │ └── mapper │ │ │ │ ├── BinaryUUIDColumnMapper.java │ │ │ │ ├── ComponentColumnMapper.java │ │ │ │ ├── KeyColumnMapper.java │ │ │ │ ├── NativeUUIDColumnMapper.java │ │ │ │ ├── PartyRowMapper.java │ │ │ │ └── PlayerRowMapper.java │ │ └── json │ │ │ └── JSONUserManager.java │ │ └── util │ │ ├── CarbonDependencies.java │ │ ├── ChannelUtils.java │ │ ├── CloudUtils.java │ │ ├── ColorUtils.java │ │ ├── ConcurrentUtil.java │ │ ├── DiscordRecipient.java │ │ ├── EmptyAudienceWithPointers.java │ │ ├── ExceptionLoggingScheduledThreadPoolExecutor.java │ │ ├── Exceptions.java │ │ ├── FastUuidSansHyphens.java │ │ ├── FileUtil.java │ │ ├── Pagination.java │ │ ├── PaginationHelper.java │ │ ├── SQLDrivers.java │ │ ├── Strings.java │ │ └── UpdateChecker.java │ └── resources │ ├── carbon-permissions.yml │ ├── locale │ ├── messages-en_US.properties │ ├── messages-ja_JP.properties │ ├── messages-nl_NL.properties │ ├── messages-tr_TR.properties │ ├── messages-zh_CN.properties │ └── messages-zh_TW.properties │ └── queries │ ├── clear-ignores.sql │ ├── clear-leftchannels.sql │ ├── clear-party-members.sql │ ├── drop-party-member.sql │ ├── drop-party.sql │ ├── insert-party-member.sql │ ├── insert-party.sql │ ├── insert-player.sql │ ├── migrations │ ├── h2 │ │ ├── V1__create_tables.sql │ │ ├── V2__increase_nickname_size.sql │ │ ├── V3__parties.sql │ │ ├── V4__filters.sql │ │ ├── V5__tempmute.sql │ │ └── V6__tempmute.sql │ ├── mysql │ │ ├── V10__tempmute.sql │ │ ├── V1__create_tables.sql │ │ ├── V2__create_tables.sql │ │ ├── V3__fix_leftchannels.sql │ │ ├── V4__drop_usernames.sql │ │ ├── V5__add_dmtoggle.sql │ │ ├── V6__increase_nickname_size.sql │ │ ├── V7__parties.sql │ │ ├── V8__filters.sql │ │ └── V9__tempmute.sql │ └── postgresql │ │ ├── V10__tempmute.sql │ │ ├── V1__create_tables.sql │ │ ├── V2__create_tables.sql │ │ ├── V3__fix_leftchannels.sql │ │ ├── V4__drop_usernames.sql │ │ ├── V5__add_dmtoggle.sql │ │ ├── V6__increase_nickname_size.sql │ │ ├── V7__parties.sql │ │ ├── V8__filters.sql │ │ └── V9__tempmute.sql │ ├── save-ignores.sql │ ├── save-leftchannels.sql │ ├── select-ignores.sql │ ├── select-leftchannels.sql │ ├── select-party-members.sql │ ├── select-party.sql │ ├── select-player.sql │ └── update-player.sql ├── crowdin.yml ├── fabric ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── draycia │ │ └── carbon │ │ └── fabric │ │ ├── CarbonChatFabric.java │ │ ├── CarbonChatFabricModule.java │ │ ├── CarbonFabricBootstrap.java │ │ ├── CarbonServerFabric.java │ │ ├── FabricMessageRenderer.java │ │ ├── FabricScheduler.java │ │ ├── MinecraftServerHolder.java │ │ ├── command │ │ ├── FabricCommander.java │ │ └── FabricPlayerCommander.java │ │ ├── listeners │ │ ├── FabricChatHandler.java │ │ └── FabricJoinQuitListener.java │ │ └── users │ │ ├── CarbonPlayerFabric.java │ │ └── FabricProfileResolver.java │ └── resources │ ├── carbonchat.mixins.json │ ├── data │ └── carbonchat │ │ └── chat_type │ │ └── chat.json │ └── pack.mcmeta ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── paper ├── build.gradle.kts └── src │ └── main │ └── java │ └── net │ └── draycia │ └── carbon │ └── paper │ ├── CarbonChatPaper.java │ ├── CarbonChatPaperModule.java │ ├── CarbonPaperBootstrap.java │ ├── CarbonPaperLoader.java │ ├── CarbonServerPaper.java │ ├── PaperScheduler.java │ ├── command │ ├── PaperCommander.java │ └── PaperPlayerCommander.java │ ├── hooks │ ├── CarbonPAPIPlaceholders.java │ └── PAPIChatHook.java │ ├── integration │ ├── dsrv │ │ ├── DSRVIntegration.java │ │ └── DSRVListener.java │ ├── essxd │ │ ├── EssXDIntegration.java │ │ └── EssXDListener.java │ ├── fuuid │ │ ├── AbstractFactionsChannel.java │ │ ├── AllianceChannel.java │ │ ├── FactionChannel.java │ │ ├── FactionModChannel.java │ │ ├── FactionsIntegration.java │ │ └── TruceChannel.java │ ├── mcmmo │ │ ├── McmmoIntegration.java │ │ └── McmmoPartyChannel.java │ ├── plotsquared │ │ ├── PlotChannel.java │ │ └── PlotSquaredIntegration.java │ └── towny │ │ ├── AllianceChannel.java │ │ ├── NationChannel.java │ │ ├── ResidentListChannel.java │ │ ├── TownChannel.java │ │ └── TownyIntegration.java │ ├── listeners │ ├── PaperChatListener.java │ └── PaperPlayerJoinListener.java │ ├── messages │ ├── PaperMessageRenderer.java │ └── PlaceholderAPIMiniMessageParser.java │ └── users │ ├── CarbonPlayerPaper.java │ └── PaperProfileResolver.java ├── renovate.json ├── settings.gradle.kts ├── sponge ├── build.gradle.kts └── src │ └── main │ └── java │ └── net │ └── draycia │ └── carbon │ └── sponge │ ├── CarbonChatSponge.java │ ├── CarbonChatSpongeModule.java │ ├── CarbonServerSponge.java │ ├── SpongeMessageRenderer.java │ ├── SpongeUserManager.java │ ├── command │ ├── SpongeCommander.java │ └── SpongePlayerCommander.java │ ├── listeners │ ├── SpongeChatListener.java │ ├── SpongePlayerJoinListener.java │ └── SpongeReloadListener.java │ └── users │ └── CarbonPlayerSponge.java └── velocity ├── build.gradle.kts └── src └── main └── java └── net └── draycia └── carbon └── velocity ├── CarbonChatVelocity.java ├── CarbonChatVelocityModule.java ├── CarbonServerVelocity.java ├── CarbonVelocityBootstrap.java ├── VelocityMessageRenderer.java ├── command ├── VelocityCommander.java └── VelocityPlayerCommander.java ├── listeners ├── VelocityChatListener.java ├── VelocityListener.java ├── VelocityPlayerJoinListener.java └── VelocityPlayerLeaveListener.java └── users ├── CarbonPlayerVelocity.java └── VelocityProfileResolver.java /.editorconfig: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2017-2020 KyoriPowered 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 | 23 | root = true 24 | 25 | [*] 26 | charset = utf-8 27 | indent_size = 4 28 | indent_style = space 29 | insert_final_newline = true 30 | max_line_length = off 31 | 32 | [*.java] 33 | ij_java_imports_layout = *, |, $* 34 | ij_java_class_count_to_use_import_on_demand = 999 35 | ij_java_names_count_to_use_import_on_demand = 999 36 | 37 | [{*.kt,*.kts,*.yml}] 38 | indent_size = 2 39 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [Draycia, jpenilla] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41E Bug report" 3 | about: Describe a bug in Carbon 4 | title: "[Bug]" 5 | labels: unconfirmed bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Bug Description: 13 | 14 | ### What is not working as it should? 15 | 16 | ### Steps to reproduce: 17 | 18 | 24 | 25 | ### System Details: 26 | 27 | 28 | 29 | 1. Server Type: 30 | 2. Server Software: 31 | 3. MC Version: 32 | 4. Carbon Version: 33 | 34 | ### Pastebins: 35 | 36 | 37 | 38 | ### Any other relevant details: 39 | 40 | 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 💬 ​ Ask a question 4 | url: https://discord.gg/S8s75Yf 5 | about: Support for Carbon is provided on Discord. Instead of making an issue to ask a question, join us on discord and we'll be happy to help! 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "⚡ Feature request" 3 | about: Suggest an idea for Carbon 4 | title: "[Feature]" 5 | labels: proposed enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Proposed Feature Description: 11 | 12 | 13 | 14 | ### Proposed Feature Functionality: 15 | 16 | 17 | -------------------------------------------------------------------------------- /.github/assets/Carbon_Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hexaoxide/Carbon/ba94e985c16a1947762633eb2323475387ffcd1d/.github/assets/Carbon_Banner.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Kotlin temp files 5 | .kotlin/ 6 | 7 | # Log file 8 | *.log 9 | 10 | # BlueJ files 11 | *.ctxt 12 | 13 | # Mobile Tools for Java (J2ME) 14 | .mtj.tmp/ 15 | 16 | # Package Files # 17 | *.jar 18 | *.war 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | *.iml 28 | *.ipr 29 | *.iws 30 | /out/ 31 | /bin/ 32 | 33 | # User-specific stuff 34 | .idea/**/workspace.xml 35 | .idea/**/tasks.xml 36 | .idea/**/usage.statistics.xml 37 | .idea/**/dictionaries 38 | .idea/**/shelf 39 | /.idea/ 40 | 41 | # Generated files 42 | .idea/**/contentModel.xml 43 | 44 | # Sensitive or high-churn files 45 | .idea/**/dataSources/ 46 | .idea/**/dataSources.ids 47 | .idea/**/dataSources.local.xml 48 | .idea/**/sqlDataSources.xml 49 | .idea/**/dynamic.xml 50 | .idea/**/uiDesigner.xml 51 | .idea/**/dbnavigator.xml 52 | 53 | # Gradle 54 | .idea/**/gradle.xml 55 | .idea/**/libraries 56 | 57 | # Gradle and Maven with auto-import 58 | # When using Gradle or Maven with auto-import, you should exclude module files, 59 | # since they will be recreated, and may cause churn. Uncomment if using 60 | # auto-import. 61 | .idea/modules.xml 62 | .idea/*.iml 63 | .idea/modules 64 | .idea/misc.xml 65 | 66 | # Dolphin browser keeps recreating this 67 | .directory 68 | 69 | # Gradle 70 | .gradle 71 | **/build/ 72 | !src/**/build/ 73 | 74 | # Ignore Gradle GUI config 75 | gradle-app.setting 76 | 77 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 78 | !gradle-wrapper.jar 79 | 80 | # Cache of project 81 | .gradletasknamecache 82 | 83 | # Mac filesystem dust 84 | .DS_Store/ 85 | .DS_Store 86 | 87 | **/run/ 88 | **/run2/ 89 | 90 | **/run-plugins.yml 91 | -------------------------------------------------------------------------------- /LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | CarbonChat 2 | 3 | Copyright (c) 2024 Josua Parks (Vicarious) 4 | Contributors 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Carbon plugin banner.
3 | Carbon is a modern chat Java Edition plugin built on channels, with just about every single setting and format configurable. 4 |

5 | 6 | ## Support 7 | 8 | Support is given through [GitHub Issues](https://github.com/Hexaoxide/Carbon/issues) 9 | and [Discord](https://discord.gg/S8s75Yf). 10 | Please use the discord for help setting up the plugin, and use issues for bug reports. 11 | 12 | ## Checkstyle 13 | 14 | Carbon uses (a fork of) checkstyle to ensure code style is consistent across the entire project. 15 | For checkstyle support in IDEA: 16 | 17 | 1. Install the [checkstyle plugin](https://github.com/jshiell/checkstyle-idea). 18 | 2. Compile https://gitlab.com/stellardrift/stylecheck 19 | 3. `Settings` -> `Tools` -> `Checkstyle` `Third-Party Checks`, add the compiled stylecheck jar 20 | 4. While still in the `Checkstyle` tab, go to `Configuration File`, add `.checkstyle/checkstyle.xml` and tick the check 21 | box. 22 | -------------------------------------------------------------------------------- /api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("carbon.publishing-conventions") 3 | alias(libs.plugins.javadoc.links) 4 | } 5 | 6 | description = "API for interfacing with the CarbonChat Minecraft mod/plugin" 7 | 8 | dependencies { 9 | // Doesn't add any dependencies, only version constraints 10 | api(platform(libs.adventureBom)) 11 | 12 | // Provided by platform 13 | compileOnlyApi(libs.adventureApi) 14 | compileOnlyApi(libs.adventureTextSerializerPlain) 15 | compileOnlyApi(libs.adventureTextSerializerLegacy) 16 | compileOnlyApi(libs.adventureTextSerializerGson) { 17 | exclude("com.google.code.gson") 18 | } 19 | compileOnlyApi(libs.minimessage) 20 | 21 | compileOnlyApi(libs.checkerQual) 22 | 23 | // Provided by Minecraft 24 | compileOnlyApi(libs.gson) 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/CarbonChatProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api; 21 | 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.checkerframework.checker.nullness.qual.Nullable; 24 | import org.checkerframework.framework.qual.DefaultQualifier; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * Static accessor for the {@link CarbonChat} instance. 29 | * 30 | * @since 1.0.0 31 | */ 32 | @DefaultQualifier(NonNull.class) 33 | public final class CarbonChatProvider { 34 | 35 | private static @Nullable CarbonChat instance; 36 | 37 | private CarbonChatProvider() { 38 | 39 | } 40 | 41 | /** 42 | * Registers the {@link CarbonChat} implementation. 43 | * 44 | * @param carbonChat the carbon implementation 45 | * @since 1.0.0 46 | */ 47 | @ApiStatus.Internal 48 | public static void register(final CarbonChat carbonChat) { 49 | CarbonChatProvider.instance = carbonChat; 50 | } 51 | 52 | /** 53 | * Gets the currently registered {@link CarbonChat} implementation. 54 | * 55 | * @return the registered carbon implementation 56 | * @since 1.0.0 57 | */ 58 | public static CarbonChat carbonChat() { 59 | if (CarbonChatProvider.instance == null) { 60 | throw new IllegalStateException("CarbonChat not initialized!"); 61 | } 62 | 63 | return CarbonChatProvider.instance; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/CarbonServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api; 21 | 22 | import java.util.List; 23 | import net.draycia.carbon.api.users.CarbonPlayer; 24 | import net.kyori.adventure.audience.Audience; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | /** 29 | * The server that carbon is running on. 30 | * 31 | * @since 2.0.0 32 | */ 33 | @DefaultQualifier(NonNull.class) 34 | public interface CarbonServer extends Audience { 35 | 36 | /** 37 | * The server's console. 38 | * 39 | * @return the server's console 40 | * @since 2.0.0 41 | */ 42 | Audience console(); 43 | 44 | /** 45 | * The players that are online on the server. 46 | * 47 | * @return the online players 48 | * @since 2.0.0 49 | */ 50 | List players(); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/channels/ChannelPermissionResultImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.channels; 21 | 22 | import java.util.function.Supplier; 23 | import net.kyori.adventure.text.Component; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.framework.qual.DefaultQualifier; 26 | 27 | @DefaultQualifier(NonNull.class) 28 | record ChannelPermissionResultImpl( 29 | boolean permitted, 30 | Supplier reasonSupplier 31 | ) implements ChannelPermissionResult { 32 | 33 | static final ChannelPermissionResult ALLOWED = 34 | new ChannelPermissionResultImpl(true, Component::empty); 35 | 36 | @Override 37 | public Component reason() { 38 | return this.reasonSupplier.get(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/Cancellable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event; 21 | 22 | /** 23 | * Marks an event as cancellable. 24 | * 25 | * @since 3.0.0 26 | */ 27 | public interface Cancellable { 28 | 29 | /** 30 | * Gets if the event is cancelled. 31 | * 32 | * @return if the event is cancelled 33 | * @since 3.0.0 34 | */ 35 | boolean cancelled(); 36 | 37 | /** 38 | * Sets the cancelled state. 39 | * 40 | * @param cancelled new cancelled state 41 | * @since 3.0.0 42 | */ 43 | void cancelled(boolean cancelled); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/CarbonEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event; 21 | 22 | /** 23 | * Marker interface for events. 24 | * 25 | * @since 1.0.0 26 | */ 27 | public interface CarbonEvent { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/CarbonEventSubscriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event; 21 | 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.checkerframework.framework.qual.DefaultQualifier; 24 | 25 | /** 26 | * An EventSubscriber. 27 | * 28 | * @param CarbonEvent implementations 29 | * @since 3.0.0 30 | */ 31 | @DefaultQualifier(NonNull.class) 32 | public interface CarbonEventSubscriber { 33 | 34 | /** 35 | * Invokes this event consumer. 36 | * 37 | * @param event the event 38 | * @throws Throwable if an exception is thrown 39 | * @since 1.0.0 40 | */ 41 | void on(T event) throws Throwable; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/CarbonEventSubscription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event; 21 | 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.checkerframework.framework.qual.DefaultQualifier; 24 | 25 | /** 26 | * A subscription to a specific event type. 27 | * 28 | * @param event type 29 | * @since 3.0.0 30 | */ 31 | @DefaultQualifier(NonNull.class) 32 | public interface CarbonEventSubscription { 33 | 34 | /** 35 | * Gets the event type. 36 | * 37 | * @return the event type 38 | * @since 3.0.0 39 | */ 40 | Class event(); 41 | 42 | /** 43 | * Gets the {@link CarbonEventSubscriber subscriber}. 44 | * 45 | * @return the subscriber 46 | * @since 3.0.0 47 | */ 48 | CarbonEventSubscriber subscriber(); 49 | 50 | /** 51 | * Disposes this subscription. 52 | * 53 | *

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

54 | * 55 | * @since 3.0.0 56 | */ 57 | void dispose(); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/events/CarbonChannelRegisterEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event.events; 21 | 22 | import java.util.Set; 23 | import java.util.function.Consumer; 24 | import net.draycia.carbon.api.channels.ChannelRegistry; 25 | import net.draycia.carbon.api.event.CarbonEvent; 26 | import net.kyori.adventure.key.Key; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | 30 | /** 31 | * {@link CarbonEvent} that's called after new channels are registered. 32 | * 33 | *

Note that some invocations of this event may be too early for 34 | * API consumers to be notified. {@link ChannelRegistry#allKeys(Consumer)} 35 | * is provided as a helper for when knowledge of all registered channels 36 | * is needed.

37 | * 38 | * @since 3.0.0 39 | */ 40 | @DefaultQualifier(NonNull.class) 41 | public interface CarbonChannelRegisterEvent extends CarbonEvent { 42 | 43 | /** 44 | * Gets the channel registry. 45 | * 46 | * @return the channel registry 47 | * @since 3.0.0 48 | */ 49 | ChannelRegistry channelRegistry(); 50 | 51 | /** 52 | * Gets the key(s) that were registered to trigger this event. 53 | * 54 | * @return key(s) registered 55 | * @since 3.0.0 56 | */ 57 | Set registered(); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/events/CarbonPrivateChatEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event.events; 21 | 22 | import net.draycia.carbon.api.event.Cancellable; 23 | import net.draycia.carbon.api.event.CarbonEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.kyori.adventure.text.Component; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | /** 30 | * Called whenever a player privately messages another player. 31 | * 32 | * @since 3.0.0 33 | */ 34 | @DefaultQualifier(NonNull.class) 35 | public interface CarbonPrivateChatEvent extends CarbonEvent, Cancellable { 36 | 37 | /** 38 | * Sets the message that will be sent. 39 | * 40 | * @param message the new message 41 | * @throws NullPointerException if message is null 42 | * @since 3.0.0 43 | */ 44 | void message(Component message); 45 | 46 | /** 47 | * The message that will be sent. 48 | * 49 | * @return the message 50 | * @since 3.0.0 51 | */ 52 | Component message(); 53 | 54 | /** 55 | * The message sender. 56 | * 57 | * @return the sender of the message 58 | * @since 3.0.0 59 | */ 60 | CarbonPlayer sender(); 61 | 62 | /** 63 | * The message recipient. 64 | * 65 | * @return the recipient of the message 66 | * @since 3.0.0 67 | */ 68 | CarbonPlayer recipient(); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/events/ChannelSwitchEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event.events; 21 | 22 | import net.draycia.carbon.api.channels.ChatChannel; 23 | import net.draycia.carbon.api.event.CarbonEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | /** 29 | * Called when a player switches channels. 30 | * 31 | * @since 3.0.0 32 | */ 33 | @DefaultQualifier(NonNull.class) 34 | public interface ChannelSwitchEvent extends CarbonEvent { 35 | 36 | /** 37 | * The player switching channels. 38 | * 39 | * @since 3.0.0 40 | */ 41 | CarbonPlayer player(); 42 | 43 | /** 44 | * The channel the player is switching to. 45 | * 46 | * @since 3.0.0 47 | */ 48 | ChatChannel channel(); 49 | 50 | /** 51 | * Sets the player's new channel. 52 | * 53 | * @param chatChannel the new channel 54 | * @since 3.0.0 55 | */ 56 | void channel(final ChatChannel chatChannel); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/events/PartyJoinEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event.events; 21 | 22 | import java.util.UUID; 23 | import net.draycia.carbon.api.event.CarbonEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.api.users.Party; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | /** 30 | * Called when a player is added to a {@link Party}. 31 | * 32 | * @since 3.0.0 33 | */ 34 | @DefaultQualifier(NonNull.class) 35 | public interface PartyJoinEvent extends CarbonEvent { 36 | 37 | /** 38 | * ID of the player joining a party. 39 | * 40 | *

The player's {@link CarbonPlayer#party()} field is not guaranteed to be updated immediately, 41 | * especially if the change needs to propagate cross-server.

42 | * 43 | * @return player id 44 | * @since 3.0.0 45 | */ 46 | UUID playerId(); 47 | 48 | /** 49 | * The party being joined. 50 | * 51 | *

{@link Party#members()} will reflect the new member.

52 | * 53 | * @return party 54 | * @since 3.0.0 55 | */ 56 | Party party(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/event/events/PartyLeaveEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.event.events; 21 | 22 | import java.util.UUID; 23 | import net.draycia.carbon.api.event.CarbonEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.api.users.Party; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | /** 30 | * Called when a player is removed from a {@link Party}. 31 | * 32 | * @since 3.0.0 33 | */ 34 | @DefaultQualifier(NonNull.class) 35 | public interface PartyLeaveEvent extends CarbonEvent { 36 | 37 | /** 38 | * ID of the player leaving a party. 39 | * 40 | *

The player's {@link CarbonPlayer#party()} field is not guaranteed to be updated immediately, 41 | * especially if the change needs to propagate cross-server.

42 | * 43 | * @return player id 44 | * @since 3.0.0 45 | */ 46 | UUID playerId(); 47 | 48 | /** 49 | * The party being left. 50 | * 51 | *

{@link Party#members()} will reflect the removed member.

52 | * 53 | * @return party 54 | * @since 3.0.0 55 | */ 56 | Party party(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/util/ChatComponentRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.util; 21 | 22 | import net.draycia.carbon.api.users.CarbonPlayer; 23 | import net.kyori.adventure.audience.Audience; 24 | import net.kyori.adventure.text.Component; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | /** 29 | * Renderer used to construct chat components on a per-player basis. 30 | * 31 | * @since 2.0.0 32 | */ 33 | @FunctionalInterface 34 | @DefaultQualifier(NonNull.class) 35 | public interface ChatComponentRenderer { 36 | 37 | /** 38 | * Renders a Component for the specified recipient. 39 | * 40 | * @param sender the player that sent the message 41 | * @param recipient a recipient of the message. 42 | * may be a player, console, or other Audience implementations 43 | * @param message the message being sent 44 | * @param originalMessage the original message that was sent 45 | * @return the component to be shown to the recipient, 46 | * or empty if the recipient should not receive the message 47 | * @since 2.0.0 48 | */ 49 | Component render(CarbonPlayer sender, 50 | Audience recipient, 51 | Component message, 52 | Component originalMessage); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/util/KeyedRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.util; 21 | 22 | import net.kyori.adventure.key.Key; 23 | import net.kyori.adventure.key.Keyed; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.framework.qual.DefaultQualifier; 26 | 27 | /** 28 | * A {@link ChatComponentRenderer chat renderer} that's identifiable by key. 29 | * 30 | * @since 2.0.0 31 | */ 32 | @DefaultQualifier(NonNull.class) 33 | public interface KeyedRenderer extends Keyed, ChatComponentRenderer { 34 | 35 | /** 36 | * Creates a new renderer with the corresponding key. 37 | * 38 | * @param key the renderer's key 39 | * @param renderer the chat renderer 40 | * @return the keyed renderer 41 | * @since 2.0.0 42 | */ 43 | static KeyedRenderer keyedRenderer(final Key key, final ChatComponentRenderer renderer) { 44 | return new KeyedRendererImpl(key, renderer); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/net/draycia/carbon/api/util/KeyedRendererImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.api.util; 21 | 22 | import net.draycia.carbon.api.users.CarbonPlayer; 23 | import net.kyori.adventure.audience.Audience; 24 | import net.kyori.adventure.key.Key; 25 | import net.kyori.adventure.text.Component; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | record KeyedRendererImpl(Key key, ChatComponentRenderer renderer) implements KeyedRenderer { 31 | 32 | @Override 33 | public Component render( 34 | final CarbonPlayer sender, 35 | final Audience recipient, 36 | final Component message, 37 | final Component originalMessage 38 | ) { 39 | return this.renderer.render(sender, recipient, message, originalMessage); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /build-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | gradlePluginPortal() 7 | maven("https://oss.sonatype.org/content/repositories/snapshots/") { 8 | mavenContent { snapshotsOnly() } 9 | } 10 | } 11 | 12 | dependencies { 13 | implementation(libs.shadow) 14 | implementation(libs.indraCommon) 15 | implementation(libs.indraLicenseHeader) 16 | implementation(libs.mod.publish.plugin) 17 | implementation(libs.configurateYaml) 18 | implementation(libs.gremlin.gradle) 19 | implementation(libs.run.task) 20 | 21 | // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 22 | implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) 23 | } 24 | -------------------------------------------------------------------------------- /build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | versionCatalogs { 3 | create("libs") { 4 | from(files("../gradle/libs.versions.toml")) 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/CarbonPermissionsExtension.kt: -------------------------------------------------------------------------------- 1 | import io.leangen.geantyref.TypeToken 2 | import org.gradle.api.file.RegularFileProperty 3 | import org.gradle.api.model.ObjectFactory 4 | import org.gradle.api.provider.ListProperty 5 | import org.gradle.api.provider.Provider 6 | import org.gradle.kotlin.dsl.listProperty 7 | import org.spongepowered.configurate.ConfigurationNode 8 | import org.spongepowered.configurate.yaml.NodeStyle 9 | import org.spongepowered.configurate.yaml.YamlConfigurationLoader 10 | import javax.inject.Inject 11 | 12 | abstract class CarbonPermissionsExtension @Inject constructor(private val objects: ObjectFactory) { 13 | abstract val yaml: RegularFileProperty 14 | 15 | val permissions: Provider> = create() 16 | 17 | private fun create(): ListProperty = objects.listProperty().also { 18 | it.set(yaml.map { file -> 19 | val loader = YamlConfigurationLoader.builder() 20 | .path(file.asFile.toPath()) 21 | .nodeStyle(NodeStyle.BLOCK) 22 | .build() 23 | loader.load().childrenMap().map { (name, child) -> 24 | loadPermission(name as String, child) 25 | } 26 | }) 27 | it.disallowChanges() 28 | it.finalizeValueOnRead() 29 | } 30 | 31 | private fun loadPermission(name: String, node: ConfigurationNode): Permission { 32 | return if (node.isMap) { 33 | Permission( 34 | name, 35 | node.node("description").string, 36 | node.node("children").takeIf { c -> !c.virtual() } 37 | ?.get(object : TypeToken>() {}) 38 | ) 39 | } else { 40 | Permission(name, node.string, null) 41 | } 42 | } 43 | 44 | data class Permission( 45 | val string: String, 46 | val description: String?, 47 | val children: Map? 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/CarbonPlatformExtension.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.api.file.RegularFileProperty 2 | 3 | abstract class CarbonPlatformExtension { 4 | abstract val productionJar: RegularFileProperty 5 | } 6 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/ConfigurablePluginsExt.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.api.Action 2 | import org.gradle.api.artifacts.ExternalModuleDependency 3 | import org.gradle.api.artifacts.MinimalExternalModuleDependency 4 | import org.gradle.api.provider.ListProperty 5 | import org.gradle.api.provider.Provider 6 | 7 | abstract class ConfigurablePluginsExt { 8 | data class DepPlugin( 9 | val dep: Provider, 10 | val op: Action?, 11 | val defaultEnabled: Boolean = false, 12 | val name: String = dep.get().name 13 | ) 14 | 15 | abstract val gradleDependencyBased: ListProperty 16 | 17 | fun dependency(lib: Provider, op: Action? = null) { 18 | gradleDependencyBased.add(DepPlugin(lib, op)) 19 | } 20 | 21 | fun dependency(lib: Provider, defaultEnabled: Boolean, op: Action? = null) { 22 | gradleDependencyBased.add(DepPlugin(lib, op, defaultEnabled)) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/FileCopyTask.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.api.DefaultTask 2 | import org.gradle.api.tasks.InputFile 3 | import org.gradle.api.tasks.OutputFile 4 | import org.gradle.api.tasks.TaskAction 5 | 6 | abstract class FileCopyTask : DefaultTask() { 7 | @InputFile 8 | val fileToCopy = project.objects.fileProperty() 9 | 10 | @OutputFile 11 | val destination = project.objects.fileProperty() 12 | 13 | @TaskAction 14 | fun copyFile() { 15 | destination.get().asFile.parentFile.mkdirs() 16 | fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.base-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("net.kyori.indra") 3 | id("net.kyori.indra.git") 4 | id("net.kyori.indra.checkstyle") 5 | id("net.kyori.indra.licenser.spotless") 6 | } 7 | 8 | version = rootProject.version 9 | 10 | indra { 11 | gpl3OnlyLicense() 12 | 13 | javaVersions { 14 | target(21) 15 | } 16 | 17 | github(GITHUB_ORGANIZATION, GITHUB_REPO) 18 | } 19 | 20 | spotless { 21 | java { 22 | targetExclude( 23 | "src/main/java/net/draycia/carbon/common/messages/PrefixedDelegateIterator.java", 24 | "src/main/java/net/draycia/carbon/common/messages/StandardPlaceholderResolverStrategyButDifferent.java", 25 | "src/main/java/com/google/inject/assistedinject/**" 26 | ) 27 | } 28 | } 29 | 30 | indraSpotlessLicenser { 31 | licenseHeaderFile(rootProject.file("LICENSE_HEADER")) 32 | } 33 | 34 | tasks { 35 | withType { 36 | // disable unclaimed annotation and missing annotation warnings 37 | options.compilerArgs.add("-Xlint:-processing,-classfile") 38 | options.compilerArgs.add("-parameters") 39 | } 40 | } 41 | 42 | dependencies { 43 | checkstyle(libs.stylecheck) 44 | } 45 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.build-logic.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("base") 3 | } 4 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.configurable-plugins.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.spongepowered.configurate.objectmapping.ConfigSerializable 2 | import org.spongepowered.configurate.yaml.NodeStyle 3 | import org.spongepowered.configurate.yaml.YamlConfigurationLoader 4 | import xyz.jpenilla.runtask.task.RunWithPlugins 5 | 6 | val pluginsExt = extensions.create("configurablePlugins", ConfigurablePluginsExt::class.java) 7 | 8 | afterEvaluate { 9 | val configs = pluginsExt.gradleDependencyBased.get().map { entry -> 10 | val c = configurations.register(entry.name + "Plugin") { 11 | isTransitive = false 12 | } 13 | dependencies { 14 | c.name(entry.dep) { entry.op?.execute(this) } 15 | } 16 | entry to c 17 | } 18 | 19 | tasks.withType(RunWithPlugins::class).configureEach { 20 | val cfg = readConfig() 21 | configs.forEach { (entry, configuration) -> 22 | val enabled = cfg.taskOverrides[name]?.get(entry.name) 23 | ?: cfg.defaults[entry.name] 24 | ?: false 25 | if (enabled) { 26 | pluginJars.from(configuration) 27 | } 28 | } 29 | } 30 | } 31 | 32 | @ConfigSerializable 33 | class Config { 34 | var defaults: MutableMap = mutableMapOf() 35 | var taskOverrides: MutableMap> = mutableMapOf( 36 | "someTaskName" to mutableMapOf("somePlugin" to false) 37 | ) 38 | } 39 | 40 | @Synchronized 41 | fun readConfig(): Config { 42 | val loader = YamlConfigurationLoader.builder() 43 | .file(file("run-plugins.yml")) 44 | .nodeStyle(NodeStyle.BLOCK) 45 | .defaultOptions { 46 | it.header("Enable and disable optional plugins for run tasks in this project") 47 | } 48 | .build() 49 | val n = loader.load() 50 | val c = n.get(Config::class.java) as Config 51 | var write = false 52 | for (e in pluginsExt.gradleDependencyBased.get()) { 53 | if (!c.defaults.containsKey(e.name)) { 54 | write = true 55 | c.defaults[e.name] = e.defaultEnabled 56 | } 57 | } 58 | if (write) { 59 | n.set(c) 60 | loader.save(n) 61 | } 62 | return c 63 | } 64 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.permissions.gradle.kts: -------------------------------------------------------------------------------- 1 | val ext = extensions.create("carbonPermission", CarbonPermissionsExtension::class.java) 2 | ext.yaml.convention(rootProject.layout.projectDirectory.file("common/src/main/resources/carbon-permissions.yml")) 3 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.publishing-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("carbon.base-conventions") 3 | id("net.kyori.indra.publishing") 4 | } 5 | 6 | 7 | signing { 8 | val signingKey: String? by project 9 | val signingPassword: String? by project 10 | useInMemoryPgpKeys(signingKey, signingPassword) 11 | } 12 | 13 | indra { 14 | configurePublications { 15 | pom { 16 | developers { 17 | developer { 18 | id.set("Vicarious") 19 | name.set("Josua Parks") 20 | } 21 | developer { 22 | id.set("jmp") 23 | name.set("Jason Penilla") 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/carbon.shadow-platform.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("carbon.platform-conventions") 3 | id("com.gradleup.shadow") 4 | } 5 | 6 | tasks { 7 | jar { 8 | archiveClassifier = "unshaded" 9 | } 10 | shadowJar { 11 | archiveClassifier.set(null as String?) 12 | configureShadowJar() 13 | mergeServiceFiles() 14 | } 15 | } 16 | 17 | extensions.configure { 18 | productionJar = tasks.shadowJar.flatMap { it.archiveFile } 19 | } 20 | -------------------------------------------------------------------------------- /build-logic/src/main/kotlin/constants.kt: -------------------------------------------------------------------------------- 1 | const val GITHUB_ORGANIZATION = "Hexaoxide" 2 | const val GITHUB_REPO = "Carbon" 3 | const val GITHUB_REPO_URL = "https://github.com/$GITHUB_ORGANIZATION/$GITHUB_REPO" 4 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("carbon.build-logic") 3 | alias(libs.plugins.hangar.publish) 4 | alias(libs.plugins.indra.publishing.sonatype) 5 | } 6 | 7 | val projectVersion: String by project // get from gradle.properties 8 | version = projectVersion 9 | 10 | fun Project.platformJar(): Provider = 11 | extensions.getByType().productionJar 12 | 13 | hangarPublish.publications.register("plugin") { 14 | version = projectVersion 15 | id = "Carbon" 16 | channel = if (projectVersion.contains("-beta.")) "Beta" else "Release" 17 | changelog = releaseNotes 18 | apiKey = providers.environmentVariable("HANGAR_UPLOAD_KEY") 19 | platforms.paper { 20 | jar = project(":carbonchat-paper").platformJar() 21 | platformVersions.add("1.21.1-1.21.5") 22 | dependencies { 23 | url("LuckPerms", "https://luckperms.net/") 24 | hangar("Essentials") { 25 | required = false 26 | } 27 | url("DiscordSRV", "https://www.spigotmc.org/resources/discordsrv.18494/") { 28 | required = false 29 | } 30 | url("PlaceholderAPI", "https://www.spigotmc.org/resources/placeholderapi.6245/") { 31 | required = false 32 | } 33 | hangar("MiniPlaceholders") { 34 | required = false 35 | } 36 | } 37 | } 38 | platforms.velocity { 39 | jar = project(":carbonchat-velocity").platformJar() 40 | platformVersions.add("3.4") 41 | dependencies { 42 | url("LuckPerms", "https://luckperms.net/") 43 | hangar("MiniPlaceholders") { 44 | required = false 45 | } 46 | hangar("SignedVelocity") { 47 | required = false 48 | } 49 | } 50 | } 51 | } 52 | 53 | indraSonatype { 54 | useAlternateSonatypeOSSHost("s01") 55 | } 56 | -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("carbon.base-conventions") 3 | } 4 | 5 | dependencies { 6 | api(projects.carbonchatApi) 7 | api(libs.gremlin.runtime) 8 | compileOnlyApi(platform(libs.log4jBom)) 9 | compileOnlyApi(libs.log4jApi) 10 | 11 | // Configs 12 | api(libs.configurateHocon) { 13 | // Provided at platform level (usually through adventure) 14 | exclude("net.kyori", "option") 15 | } 16 | // Bring in option for -common compile 17 | compileOnly(libs.configurateHocon) 18 | api(libs.adventureSerializerConfigurate4) { 19 | isTransitive = false 20 | } 21 | 22 | // Cloud 23 | api(platform(libs.cloudBom)) 24 | api(libs.cloudCore) 25 | api(platform(libs.cloudMinecraftBom)) 26 | api(libs.cloudMinecraftExtras) { 27 | isTransitive = false 28 | } 29 | api(libs.cloudSigned) 30 | 31 | // Other 32 | compileOnlyApi(libs.guice) { 33 | exclude("com.google.guava") 34 | } 35 | compileOnlyApi(libs.assistedInject) { 36 | isTransitive = false 37 | } 38 | compileOnlyApi(libs.luckPermsApi) 39 | compileOnlyApi(libs.event) 40 | 41 | // Storage 42 | compileOnlyApi(libs.jdbiCore) 43 | compileOnlyApi(libs.jdbiObject) 44 | compileOnlyApi(libs.jdbiPostgres) 45 | api(libs.hikariCP) 46 | compileOnlyApi(libs.flyway) { 47 | exclude("com.google.code.gson", "gson") 48 | } 49 | compileOnlyApi(libs.flywayMysql) { 50 | isTransitive = false 51 | } 52 | compileOnlyApi(libs.flywayPostgres) { 53 | isTransitive = false 54 | } 55 | 56 | // Messaging 57 | api(libs.messenger) 58 | api(libs.messengerNats) 59 | api(libs.messengerRabbitmq) 60 | api(libs.messengerRedis) 61 | compileOnlyApi(libs.netty) 62 | 63 | api(libs.event) 64 | api(libs.registry) { 65 | exclude("com.google.guava") 66 | } 67 | api(libs.kyoriMoonshine) 68 | api(libs.kyoriMoonshineCore) 69 | api(libs.kyoriMoonshineStandard) 70 | 71 | compileOnlyApi(libs.caffeine) 72 | 73 | // we shade and relocate a newer version than minecraft provides 74 | compileOnlyApi(libs.guava) 75 | 76 | // Plugins 77 | compileOnly(libs.miniplaceholders) 78 | } 79 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/CarbonPlatformModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common; 21 | 22 | import com.google.inject.AbstractModule; 23 | import com.google.inject.multibindings.Multibinder; 24 | import net.draycia.carbon.common.integration.Integration; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public abstract class CarbonPlatformModule extends AbstractModule { 30 | 31 | @Override 32 | protected final void configure() { 33 | this.configurePlatform(); 34 | 35 | this.configureIntegrations( 36 | Multibinder.newSetBinder(this.binder(), Integration.class), 37 | Multibinder.newSetBinder(this.binder(), Integration.ConfigMeta.class) 38 | ); 39 | } 40 | 41 | protected abstract void configurePlatform(); 42 | 43 | protected void configureIntegrations( 44 | final Multibinder integrations, 45 | final Multibinder configs 46 | ) { 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/DataDirectory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common; 21 | 22 | import com.google.inject.BindingAnnotation; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | import java.nio.file.Path; 28 | 29 | /** 30 | * Injection binding annotation for the {@link Path} which is Carbon's data directory. 31 | */ 32 | @BindingAnnotation 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target({ElementType.PARAMETER, ElementType.FIELD}) 35 | public @interface DataDirectory { 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/PeriodicTasks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common; 21 | 22 | import com.google.inject.BindingAnnotation; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | import java.util.concurrent.ScheduledExecutorService; 28 | 29 | /** 30 | * Injection binding annotation for the {@link ScheduledExecutorService} used for 31 | * periodic tasks. 32 | */ 33 | @BindingAnnotation 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) 36 | public @interface PeriodicTasks { 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/PlatformScheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common; 21 | 22 | import com.google.inject.Inject; 23 | import com.google.inject.Singleton; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public interface PlatformScheduler { 30 | 31 | void scheduleForPlayer(CarbonPlayer carbonPlayer, Runnable runnable); 32 | 33 | @Singleton 34 | final class RunImmediately implements PlatformScheduler { 35 | @Inject 36 | private RunImmediately() { 37 | } 38 | 39 | @Override 40 | public void scheduleForPlayer(final CarbonPlayer carbonPlayer, final Runnable runnable) { 41 | runnable.run(); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/RawChat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common; 21 | 22 | import com.google.inject.BindingAnnotation; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * Injection binding annotation for the raw chat type key. 30 | */ 31 | @BindingAnnotation 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) 34 | public @interface RawChat { 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/channels/messages/ConfigChannelMessages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.channels.messages; 21 | 22 | import java.util.UUID; 23 | import net.draycia.carbon.common.messages.SourcedAudience; 24 | import net.kyori.adventure.key.Key; 25 | import net.kyori.adventure.text.Component; 26 | import net.kyori.moonshine.annotation.Message; 27 | import net.kyori.moonshine.annotation.Placeholder; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public interface ConfigChannelMessages { 33 | 34 | // TODO: locale placeholders? 35 | @Message("channel.format") 36 | Component chatFormat( 37 | SourcedAudience audience, 38 | @Placeholder UUID uuid, 39 | @Placeholder Key channel, 40 | @Placeholder("display_name") Component displayName, 41 | @Placeholder String username, 42 | @Placeholder Component message, 43 | @Placeholder("party_name") Component partyName 44 | ); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/CarbonCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import java.util.Objects; 23 | import net.kyori.adventure.key.Key; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public abstract class CarbonCommand { 30 | 31 | private @Nullable CommandSettings commandSettings = null; 32 | 33 | public CommandSettings commandSettings() { 34 | return Objects.requireNonNullElseGet(this.commandSettings, this::defaultCommandSettings); 35 | } 36 | 37 | public void commandSettings(final @NonNull CommandSettings commandSettings) { 38 | this.commandSettings = commandSettings; 39 | } 40 | 41 | public abstract void init(); 42 | 43 | public abstract CommandSettings defaultCommandSettings(); 44 | 45 | public abstract Key key(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/CommandSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 23 | 24 | @ConfigSerializable 25 | public class CommandSettings { 26 | 27 | private boolean enabled = true; 28 | private String name = ""; 29 | private String[] aliases = new String[0]; 30 | 31 | public CommandSettings() { 32 | 33 | } 34 | 35 | public CommandSettings(final boolean enabled, final String name, final String... aliases) { 36 | this.enabled = enabled; 37 | this.name = name; 38 | this.aliases = aliases; 39 | } 40 | 41 | public CommandSettings(final String name, final String... aliases) { 42 | this(true, name, aliases); 43 | } 44 | 45 | public boolean enabled() { 46 | return this.enabled; 47 | } 48 | 49 | public String name() { 50 | return this.name; 51 | } 52 | 53 | public String[] aliases() { 54 | return this.aliases; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/Commander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import net.kyori.adventure.audience.Audience; 23 | 24 | public interface Commander extends Audience { 25 | 26 | boolean hasPermission(String permission); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/ExecutionCoordinatorHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import java.util.concurrent.ExecutorService; 23 | import java.util.concurrent.Executors; 24 | import java.util.concurrent.TimeUnit; 25 | import net.draycia.carbon.common.util.ConcurrentUtil; 26 | import org.apache.logging.log4j.Logger; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | import org.incendo.cloud.execution.ExecutionCoordinator; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public record ExecutionCoordinatorHolder( 33 | ExecutionCoordinator executionCoordinator, 34 | ExecutorService executorService 35 | ) { 36 | 37 | public void shutdown() { 38 | ConcurrentUtil.shutdownExecutor(this.executorService, TimeUnit.MILLISECONDS, 50); 39 | } 40 | 41 | public static ExecutionCoordinatorHolder create(final Logger logger) { 42 | final ExecutorService executorService = Executors.newFixedThreadPool(4, ConcurrentUtil.carbonThreadFactory(logger, "Commands")); 43 | return new ExecutionCoordinatorHolder( 44 | ExecutionCoordinator.coordinatorFor(executorService), 45 | executorService 46 | ); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/ParserFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import net.draycia.carbon.common.command.argument.CarbonPlayerParser; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.framework.qual.DefaultQualifier; 25 | 26 | @DefaultQualifier(NonNull.class) 27 | public interface ParserFactory { 28 | 29 | CarbonPlayerParser carbonPlayer(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/PlayerCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command; 21 | 22 | import net.draycia.carbon.api.users.CarbonPlayer; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | 25 | public interface PlayerCommander extends Commander { 26 | 27 | @NonNull CarbonPlayer carbonPlayer(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/argument/PlayerSuggestions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command.argument; 21 | 22 | import net.draycia.carbon.common.command.Commander; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.framework.qual.DefaultQualifier; 25 | import org.incendo.cloud.suggestion.SuggestionProvider; 26 | 27 | @DefaultQualifier(NonNull.class) 28 | public interface PlayerSuggestions extends SuggestionProvider { 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/exception/CommandCompleted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command.exception; 21 | 22 | import net.kyori.adventure.text.Component; 23 | import net.kyori.adventure.text.ComponentLike; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public final class CommandCompleted extends ComponentException { 30 | 31 | private static final long serialVersionUID = 1352215898395889299L; 32 | 33 | private CommandCompleted(final @Nullable Component message) { 34 | super(message); 35 | } 36 | 37 | public static CommandCompleted withoutMessage() { 38 | return new CommandCompleted(null); 39 | } 40 | 41 | public static CommandCompleted withMessage(final ComponentLike message) { 42 | return new CommandCompleted(message.asComponent()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/command/exception/ComponentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.command.exception; 21 | 22 | import net.kyori.adventure.text.Component; 23 | import net.kyori.adventure.text.ComponentLike; 24 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; 25 | import net.kyori.adventure.util.ComponentMessageThrowable; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.checker.nullness.qual.Nullable; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public class ComponentException extends RuntimeException implements ComponentMessageThrowable { 32 | 33 | private static final long serialVersionUID = 132203031250316968L; 34 | 35 | private final @Nullable Component message; 36 | 37 | protected ComponentException(final @Nullable Component message) { 38 | this.message = message; 39 | } 40 | 41 | public static ComponentException withoutMessage() { 42 | return new ComponentException(null); 43 | } 44 | 45 | public static ComponentException withMessage(final ComponentLike message) { 46 | return new ComponentException(message.asComponent()); 47 | } 48 | 49 | @Override 50 | public @Nullable Component componentMessage() { 51 | return this.message; 52 | } 53 | 54 | @Override 55 | public String getMessage() { 56 | return PlainTextComponentSerializer.plainText().serializeOr(this.message, "No message."); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/config/CommandConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.config; 21 | 22 | import java.util.Map; 23 | import net.draycia.carbon.common.command.CommandSettings; 24 | import net.draycia.carbon.common.util.CloudUtils; 25 | import net.kyori.adventure.key.Key; 26 | import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 29 | 30 | @ConfigSerializable 31 | @DefaultQualifier(MonotonicNonNull.class) 32 | public class CommandConfig { 33 | 34 | private Map settings = CloudUtils.defaultCommandSettings(); 35 | 36 | public CommandConfig() { 37 | 38 | } 39 | 40 | public CommandConfig(final Map settings) { 41 | this.settings = settings; 42 | } 43 | 44 | public Map settings() { 45 | return this.settings; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/config/ConfigHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.config; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * Tells Carbon's config loading logic to use {@link #value()} 29 | * as the header in {@link org.spongepowered.configurate.ConfigurationOptions} 30 | * when loading/saving this type as the root node of a document. 31 | */ 32 | @Target(ElementType.TYPE) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface ConfigHeader { 35 | String value(); 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/CancellableImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event; 21 | 22 | import net.draycia.carbon.api.event.Cancellable; 23 | 24 | public class CancellableImpl implements Cancellable, com.seiama.event.Cancellable { 25 | 26 | private boolean cancelled = false; 27 | 28 | @Override 29 | public boolean cancelled() { 30 | return this.cancelled; 31 | } 32 | 33 | @Override 34 | public void cancelled(final boolean cancelled) { 35 | this.cancelled = cancelled; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/CarbonEventSubscriptionImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event; 21 | 22 | import com.seiama.event.EventSubscription; 23 | import net.draycia.carbon.api.event.CarbonEvent; 24 | import net.draycia.carbon.api.event.CarbonEventSubscriber; 25 | import net.draycia.carbon.api.event.CarbonEventSubscription; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | record CarbonEventSubscriptionImpl( 31 | Class event, 32 | CarbonEventSubscriber subscriber, 33 | EventSubscription backingSubscription 34 | ) implements CarbonEventSubscription { 35 | 36 | @Override 37 | public void dispose() { 38 | this.backingSubscription.dispose(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/events/CarbonEarlyChatEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event.events; 21 | 22 | import net.draycia.carbon.api.event.CarbonEvent; 23 | import net.draycia.carbon.api.users.CarbonPlayer; 24 | 25 | public class CarbonEarlyChatEvent implements CarbonEvent { 26 | 27 | public final CarbonPlayer sender; 28 | public String message; 29 | 30 | public CarbonEarlyChatEvent(final CarbonPlayer sender, final String message) { 31 | this.sender = sender; 32 | this.message = message; 33 | } 34 | 35 | public CarbonPlayer sender() { 36 | return this.sender; 37 | } 38 | 39 | public String message() { 40 | return this.message; 41 | } 42 | 43 | public void message(final String message) { 44 | this.message = message; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/events/CarbonPrivateChatEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event.events; 21 | 22 | import java.util.Objects; 23 | import net.draycia.carbon.api.event.events.CarbonPrivateChatEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.common.event.CancellableImpl; 26 | import net.kyori.adventure.text.Component; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | 30 | /** 31 | * Called whenever a player privately messages another player. 32 | * 33 | * @since 3.0.0 34 | */ 35 | @DefaultQualifier(NonNull.class) 36 | public class CarbonPrivateChatEventImpl extends CancellableImpl implements CarbonPrivateChatEvent { 37 | 38 | private final CarbonPlayer sender; 39 | private final CarbonPlayer recipient; 40 | 41 | private Component message; 42 | 43 | public CarbonPrivateChatEventImpl(final CarbonPlayer sender, final CarbonPlayer recipient, final Component message) { 44 | this.sender = sender; 45 | this.recipient = recipient; 46 | this.message = message; 47 | } 48 | 49 | public void message(final Component message) { 50 | this.message = Objects.requireNonNull(message); 51 | } 52 | 53 | public Component message() { 54 | return this.message; 55 | } 56 | 57 | public CarbonPlayer sender() { 58 | return this.sender; 59 | } 60 | 61 | public CarbonPlayer recipient() { 62 | return this.recipient; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/events/CarbonReloadEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event.events; 21 | 22 | import net.draycia.carbon.api.event.CarbonEvent; 23 | 24 | public class CarbonReloadEvent implements CarbonEvent { 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/events/ChannelRegisterEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event.events; 21 | 22 | import java.util.Set; 23 | import net.draycia.carbon.api.event.events.CarbonChannelRegisterEvent; 24 | import net.draycia.carbon.common.channels.CarbonChannelRegistry; 25 | import net.kyori.adventure.key.Key; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public record ChannelRegisterEventImpl( 31 | CarbonChannelRegistry channelRegistry, 32 | Set registered 33 | ) implements CarbonChannelRegisterEvent { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/event/events/ChannelSwitchEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.event.events; 21 | 22 | import net.draycia.carbon.api.channels.ChatChannel; 23 | import net.draycia.carbon.api.event.events.ChannelSwitchEvent; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public class ChannelSwitchEventImpl implements ChannelSwitchEvent { 30 | 31 | private final CarbonPlayer player; 32 | private ChatChannel chatChannel; 33 | 34 | public ChannelSwitchEventImpl(final CarbonPlayer player, final ChatChannel chatChannel) { 35 | this.player = player; 36 | this.chatChannel = chatChannel; 37 | } 38 | 39 | @Override 40 | public CarbonPlayer player() { 41 | return this.player; 42 | } 43 | 44 | @Override 45 | public ChatChannel channel() { 46 | return this.chatChannel; 47 | } 48 | 49 | @Override 50 | public void channel(final ChatChannel chatChannel) { 51 | this.chatChannel = chatChannel; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/integration/Integration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.integration; 21 | 22 | import java.lang.reflect.Type; 23 | import net.draycia.carbon.common.config.ConfigManager; 24 | 25 | public interface Integration { 26 | 27 | boolean eligible(); 28 | 29 | void register(); 30 | 31 | interface ConfigMeta { 32 | Type type(); 33 | 34 | String name(); 35 | 36 | record ConfigMetaRecord(Type type, String name) implements ConfigMeta {} 37 | } 38 | 39 | static ConfigMeta configMeta(final String name, final Type type) { 40 | return new ConfigMeta.ConfigMetaRecord(type, name); 41 | } 42 | 43 | default C config(final ConfigManager configManager, final ConfigMeta meta) { 44 | return configManager.primaryConfig().integrations().config(meta); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/listeners/DeafenHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.listeners; 21 | 22 | import com.google.inject.Inject; 23 | import net.draycia.carbon.api.event.CarbonEventHandler; 24 | import net.draycia.carbon.api.event.events.CarbonChatEvent; 25 | import net.draycia.carbon.api.users.CarbonPlayer; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public class DeafenHandler implements Listener { 31 | 32 | @Inject 33 | public DeafenHandler(final CarbonEventHandler events) { 34 | events.subscribe(CarbonChatEvent.class, 0, false, event -> { 35 | if (!event.sender().deafened()) { 36 | return; 37 | } 38 | 39 | event.recipients().removeIf(entry -> entry instanceof CarbonPlayer carbonPlayer && 40 | carbonPlayer.deafened()); 41 | }); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/listeners/HyperlinkHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.listeners; 21 | 22 | import com.google.inject.Inject; 23 | import net.draycia.carbon.api.event.CarbonEventHandler; 24 | import net.draycia.carbon.api.event.events.CarbonChatEvent; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | import static net.draycia.carbon.common.util.Strings.URL_REPLACEMENT_CONFIG; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public class HyperlinkHandler implements Listener { 32 | 33 | @Inject 34 | public HyperlinkHandler(final CarbonEventHandler events) { 35 | events.subscribe(CarbonChatEvent.class, 0, false, event -> { 36 | if (event.sender().hasPermission("carbon.chatlinks")) { 37 | event.message(event.message().replaceText(URL_REPLACEMENT_CONFIG.get())); 38 | } 39 | }); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/listeners/IgnoreHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.listeners; 21 | 22 | import com.google.inject.Inject; 23 | import net.draycia.carbon.api.event.CarbonEventHandler; 24 | import net.draycia.carbon.api.event.events.CarbonChatEvent; 25 | import net.draycia.carbon.api.users.CarbonPlayer; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public class IgnoreHandler implements Listener { 31 | 32 | @Inject 33 | public IgnoreHandler(final CarbonEventHandler events) { 34 | events.subscribe(CarbonChatEvent.class, 0, false, event -> { 35 | event.recipients().removeIf(entry -> entry instanceof CarbonPlayer carbonPlayer && 36 | carbonPlayer.ignoring(event.sender())); 37 | }); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/listeners/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.listeners; 21 | 22 | public interface Listener { 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages; 21 | 22 | import net.kyori.adventure.audience.Audience; 23 | import net.kyori.adventure.text.Component; 24 | import net.kyori.moonshine.message.IMessageSender; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public class CarbonMessageSender implements IMessageSender { 30 | 31 | @Override 32 | public void send(final Audience receiver, final Component renderedMessage) { 33 | if (receiver instanceof SourcedAudience sourcedAudience) { 34 | sourcedAudience.recipient().sendMessage(renderedMessage); 35 | } else { 36 | receiver.sendMessage(renderedMessage); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/NotPlaceholder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | @Documented 29 | @Target({ElementType.PARAMETER, ElementType.TYPE_USE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | public @interface NotPlaceholder { 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages; 21 | 22 | public record Option(boolean value) { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/PrefixedDelegateIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * moonshine - A localisation library for Java. 3 | * Copyright (C) Mariell Hoversholm 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package net.draycia.carbon.common.messages; 19 | 20 | import java.util.Iterator; 21 | 22 | public final class PrefixedDelegateIterator implements Iterator { 23 | 24 | private final T prefix; 25 | private final Iterator delegate; 26 | private boolean seenPrefix = false; 27 | 28 | public PrefixedDelegateIterator(final T prefix, final Iterator delegate) { 29 | this.prefix = prefix; 30 | this.delegate = delegate; 31 | } 32 | 33 | @Override 34 | public boolean hasNext() { 35 | return !this.seenPrefix || this.delegate.hasNext(); 36 | } 37 | 38 | @Override 39 | public T next() { 40 | if (!this.seenPrefix) { 41 | this.seenPrefix = true; 42 | return this.prefix; 43 | } 44 | 45 | return this.delegate.next(); 46 | } 47 | 48 | @Override 49 | public void remove() { 50 | if (!this.seenPrefix) { 51 | throw new IllegalStateException("must see prefix before removing from iterator"); 52 | } 53 | 54 | this.delegate.remove(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/SourcedAudienceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages; 21 | 22 | import net.kyori.adventure.audience.Audience; 23 | 24 | record SourcedAudienceImpl(Audience sender, Audience recipient) implements SourcedAudience { 25 | 26 | static final SourcedAudience EMPTY = new SourcedAudienceImpl(Audience.empty(), Audience.empty()); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/SourcedMessageSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages; 21 | 22 | import net.kyori.adventure.text.Component; 23 | import net.kyori.moonshine.message.IMessageSender; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.framework.qual.DefaultQualifier; 26 | 27 | @DefaultQualifier(NonNull.class) 28 | public class SourcedMessageSender implements IMessageSender { 29 | 30 | @Override 31 | public void send(final SourcedAudience receiver, final Component renderedMessage) { 32 | receiver.recipient().sendMessage(renderedMessage); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/BooleanPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.text.minimessage.tag.Tag; 26 | import net.kyori.moonshine.placeholder.ConclusionValue; 27 | import net.kyori.moonshine.placeholder.ContinuanceValue; 28 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 29 | import net.kyori.moonshine.util.Either; 30 | import org.checkerframework.checker.nullness.qual.Nullable; 31 | 32 | public class BooleanPlaceholderResolver implements IPlaceholderResolver { 33 | 34 | @Override 35 | public @Nullable Map, ContinuanceValue>> resolve( 36 | final String placeholderName, 37 | final Boolean value, 38 | final R receiver, 39 | final Type owner, 40 | final Method method, 41 | final @Nullable Object[] parameters 42 | ) { 43 | if (value == null) { 44 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed("false")))); 45 | } 46 | 47 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(value.toString())))); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/ComponentPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.text.Component; 26 | import net.kyori.adventure.text.minimessage.tag.Tag; 27 | import net.kyori.moonshine.placeholder.ConclusionValue; 28 | import net.kyori.moonshine.placeholder.ContinuanceValue; 29 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 30 | import net.kyori.moonshine.util.Either; 31 | import org.checkerframework.checker.nullness.qual.NonNull; 32 | import org.checkerframework.checker.nullness.qual.Nullable; 33 | import org.checkerframework.framework.qual.DefaultQualifier; 34 | 35 | @DefaultQualifier(NonNull.class) 36 | public class ComponentPlaceholderResolver implements IPlaceholderResolver { 37 | 38 | @Override 39 | public @Nullable Map, ContinuanceValue>> resolve( 40 | final String placeholderName, 41 | final Component value, 42 | final R receiver, 43 | final Type owner, 44 | final Method method, 45 | final @Nullable Object[] parameters 46 | ) { 47 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.selfClosingInserting(value)))); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/IntPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.text.minimessage.tag.Tag; 26 | import net.kyori.moonshine.placeholder.ConclusionValue; 27 | import net.kyori.moonshine.placeholder.ContinuanceValue; 28 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 29 | import net.kyori.moonshine.util.Either; 30 | import org.checkerframework.checker.nullness.qual.Nullable; 31 | 32 | public class IntPlaceholderResolver implements IPlaceholderResolver { 33 | 34 | @Override 35 | public @Nullable Map, ContinuanceValue>> resolve( 36 | final String placeholderName, 37 | final Integer value, 38 | final R receiver, 39 | final Type owner, 40 | final Method method, 41 | final @Nullable Object[] parameters 42 | ) { 43 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(String.valueOf(value))))); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/KeyPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.key.Key; 26 | import net.kyori.adventure.text.minimessage.tag.Tag; 27 | import net.kyori.moonshine.placeholder.ConclusionValue; 28 | import net.kyori.moonshine.placeholder.ContinuanceValue; 29 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 30 | import net.kyori.moonshine.util.Either; 31 | import org.checkerframework.checker.nullness.qual.Nullable; 32 | 33 | public class KeyPlaceholderResolver implements IPlaceholderResolver { 34 | 35 | @Override 36 | public @Nullable Map, ContinuanceValue>> resolve( 37 | final String placeholderName, 38 | final Key value, 39 | final R receiver, 40 | final Type owner, 41 | final Method method, 42 | final @Nullable Object[] parameters 43 | ) { 44 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(value.toString())))); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/LongPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.text.minimessage.tag.Tag; 26 | import net.kyori.moonshine.placeholder.ConclusionValue; 27 | import net.kyori.moonshine.placeholder.ContinuanceValue; 28 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 29 | import net.kyori.moonshine.util.Either; 30 | import org.checkerframework.checker.nullness.qual.Nullable; 31 | 32 | public class LongPlaceholderResolver implements IPlaceholderResolver { 33 | 34 | @Override 35 | public @Nullable Map, ContinuanceValue>> resolve( 36 | final String placeholderName, 37 | final Long value, 38 | final R receiver, 39 | final Type owner, 40 | final Method method, 41 | final @Nullable Object[] parameters 42 | ) { 43 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(String.valueOf(value))))); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/OptionPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.draycia.carbon.common.messages.Option; 26 | import net.draycia.carbon.common.messages.OptionTagResolver; 27 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 28 | import net.kyori.moonshine.placeholder.ConclusionValue; 29 | import net.kyori.moonshine.placeholder.ContinuanceValue; 30 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 31 | import net.kyori.moonshine.util.Either; 32 | import org.checkerframework.checker.nullness.qual.Nullable; 33 | 34 | public final class OptionPlaceholderResolver implements IPlaceholderResolver { 35 | 36 | @Override 37 | public Map, ContinuanceValue>> resolve( 38 | final String placeholderName, 39 | final Option value, 40 | final R receiver, 41 | final Type owner, 42 | final Method method, 43 | final @Nullable Object[] parameters 44 | ) { 45 | if (value == null) { 46 | throw new IllegalArgumentException(); 47 | } 48 | 49 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(new OptionTagResolver(placeholderName, value.value())))); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/StringPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import net.kyori.adventure.text.minimessage.tag.Tag; 26 | import net.kyori.moonshine.placeholder.ConclusionValue; 27 | import net.kyori.moonshine.placeholder.ContinuanceValue; 28 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 29 | import net.kyori.moonshine.util.Either; 30 | import org.checkerframework.checker.nullness.qual.Nullable; 31 | 32 | public class StringPlaceholderResolver implements IPlaceholderResolver { 33 | 34 | @Override 35 | public @Nullable Map, ContinuanceValue>> resolve( 36 | final String placeholderName, 37 | final String value, 38 | final R receiver, 39 | final Type owner, 40 | final Method method, 41 | final @Nullable Object[] parameters 42 | ) { 43 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(value)))); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messages/placeholders/UUIDPlaceholderResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messages.placeholders; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Map; 25 | import java.util.UUID; 26 | import net.kyori.adventure.text.minimessage.tag.Tag; 27 | import net.kyori.moonshine.placeholder.ConclusionValue; 28 | import net.kyori.moonshine.placeholder.ContinuanceValue; 29 | import net.kyori.moonshine.placeholder.IPlaceholderResolver; 30 | import net.kyori.moonshine.util.Either; 31 | import org.checkerframework.checker.nullness.qual.NonNull; 32 | import org.checkerframework.checker.nullness.qual.Nullable; 33 | import org.checkerframework.framework.qual.DefaultQualifier; 34 | 35 | @DefaultQualifier(NonNull.class) 36 | public class UUIDPlaceholderResolver implements IPlaceholderResolver { 37 | 38 | @Override 39 | public @Nullable Map, ContinuanceValue>> resolve( 40 | final String placeholderName, 41 | final UUID value, 42 | final R receiver, 43 | final Type owner, 44 | final Method method, 45 | final @Nullable Object[] parameters 46 | ) { 47 | return Map.of(placeholderName, Either.left(ConclusionValue.conclusionValue(Tag.preProcessParsed(value.toString())))); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messaging/ServerId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messaging; 21 | 22 | import com.google.inject.BindingAnnotation; 23 | import com.google.inject.Key; 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | import java.util.UUID; 29 | 30 | /** 31 | * Injection binding annotation for the {@link UUID} identifier of 32 | * the currently running Carbon instance for cross-server packet 33 | * communications. 34 | */ 35 | @BindingAnnotation 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) 38 | public @interface ServerId { 39 | Key KEY = Key.get(UUID.class, ServerId.class); 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/messaging/packets/SaveCompletedPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.messaging.packets; 21 | 22 | import com.google.inject.assistedinject.Assisted; 23 | import com.google.inject.assistedinject.AssistedInject; 24 | import io.netty.buffer.ByteBuf; 25 | import java.util.UUID; 26 | import net.draycia.carbon.common.messaging.ServerId; 27 | import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public final class SaveCompletedPacket extends CarbonPacket { 33 | 34 | private @MonotonicNonNull UUID player; 35 | 36 | @AssistedInject 37 | public SaveCompletedPacket(final @ServerId UUID serverId, final @Assisted UUID player) { 38 | super(serverId); 39 | this.player = player; 40 | } 41 | 42 | public SaveCompletedPacket(final UUID sender, final ByteBuf data) { 43 | super(sender); 44 | this.read(data); 45 | } 46 | 47 | public UUID playerId() { 48 | return this.player; 49 | } 50 | 51 | @Override 52 | public void read(final ByteBuf buffer) { 53 | this.player = this.readUUID(buffer); 54 | } 55 | 56 | @Override 57 | public void write(final ByteBuf buffer) { 58 | this.writeUUID(this.player, buffer); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/serialisation/gson/UUIDSerializerGson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.serialisation.gson; 21 | 22 | import com.google.gson.TypeAdapter; 23 | import com.google.gson.stream.JsonReader; 24 | import com.google.gson.stream.JsonWriter; 25 | import java.io.IOException; 26 | import java.util.UUID; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.checker.nullness.qual.Nullable; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public class UUIDSerializerGson extends TypeAdapter { 33 | 34 | @Override 35 | public void write(final JsonWriter jsonWriter, final @Nullable UUID uuid) throws IOException { 36 | if (uuid != null) { 37 | jsonWriter.value(uuid.toString()); 38 | } else { 39 | jsonWriter.value((String) null); 40 | } 41 | } 42 | 43 | @Override 44 | public UUID read(final JsonReader jsonReader) throws IOException { 45 | return UUID.fromString(jsonReader.nextString()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/Backing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users; 21 | 22 | import com.google.inject.BindingAnnotation; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | import net.draycia.carbon.api.users.UserManager; 28 | import net.draycia.carbon.common.users.db.DatabaseUserManager; 29 | import net.draycia.carbon.common.users.json.JSONUserManager; 30 | 31 | /** 32 | * Injection binding annotation for the backing {@link UserManagerInternal} 33 | * (i.e. {@link JSONUserManager} or {@link DatabaseUserManager}), 34 | * with the generic type of {@link CarbonPlayerCommon}. 35 | * 36 | *

Injecting {@link UserManagerInternal} or {@link UserManager} with a generic type of {@literal ?}, without this annotation, 37 | * will inject the {@link PlatformUserManager}, which wraps the backing manager (this is generally what you want).

38 | */ 39 | @BindingAnnotation 40 | @Retention(RetentionPolicy.RUNTIME) 41 | @Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) 42 | public @interface Backing { 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/ProfileResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users; 21 | 22 | import java.util.UUID; 23 | import java.util.concurrent.CompletableFuture; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | 28 | @DefaultQualifier(NonNull.class) 29 | public interface ProfileResolver { 30 | 31 | CompletableFuture<@Nullable UUID> resolveUUID(String username, boolean cacheOnly); 32 | 33 | default CompletableFuture<@Nullable UUID> resolveUUID(final String username) { 34 | return this.resolveUUID(username, false); 35 | } 36 | 37 | CompletableFuture<@Nullable String> resolveName(UUID uuid, boolean cacheOnly); 38 | 39 | default CompletableFuture<@Nullable String> resolveName(final UUID uuid) { 40 | return this.resolveName(uuid, false); 41 | } 42 | 43 | void shutdown(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/UserManagerInternal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users; 21 | 22 | import java.util.UUID; 23 | import java.util.concurrent.CompletableFuture; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.api.users.UserManager; 26 | import net.draycia.carbon.common.messaging.packets.DisbandPartyPacket; 27 | import net.draycia.carbon.common.messaging.packets.PartyChangePacket; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public interface UserManagerInternal extends UserManager { 33 | 34 | void shutdown(); 35 | 36 | CompletableFuture saveIfNeeded(C player); 37 | 38 | CompletableFuture loggedOut(UUID uuid); 39 | 40 | void saveCompleteMessageReceived(UUID playerId); 41 | 42 | void cleanup(); 43 | 44 | CompletableFuture saveParty(PartyImpl info); 45 | 46 | void disbandParty(UUID id); 47 | 48 | void partyChangeMessageReceived(PartyChangePacket pkt); 49 | 50 | void disbandPartyMessageReceived(DisbandPartyPacket pkt); 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/argument/BinaryUUIDArgumentFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.argument; 21 | 22 | import java.sql.Types; 23 | import java.util.UUID; 24 | import org.jdbi.v3.core.argument.AbstractArgumentFactory; 25 | import org.jdbi.v3.core.argument.Argument; 26 | import org.jdbi.v3.core.config.ConfigRegistry; 27 | 28 | public final class BinaryUUIDArgumentFactory extends AbstractArgumentFactory { 29 | 30 | public BinaryUUIDArgumentFactory() { 31 | super(Types.BINARY); // BINARY(16) 32 | } 33 | 34 | @Override 35 | public Argument build(final UUID value, final ConfigRegistry config) { 36 | return (position, statement, ctx) -> statement.setBytes(position, unhex(value.toString().replace("-", ""))); 37 | } 38 | 39 | private static byte[] unhex(final String s) { 40 | final int len = s.length(); 41 | final byte[] data = new byte[len / 2]; 42 | for (int i = 0; i < len; i += 2) { 43 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) 44 | + Character.digit(s.charAt(i + 1), 16)); 45 | } 46 | return data; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/argument/ComponentArgumentFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.argument; 21 | 22 | import java.sql.Types; 23 | import net.kyori.adventure.text.Component; 24 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 25 | import org.jdbi.v3.core.argument.AbstractArgumentFactory; 26 | import org.jdbi.v3.core.argument.Argument; 27 | import org.jdbi.v3.core.config.ConfigRegistry; 28 | 29 | public final class ComponentArgumentFactory extends AbstractArgumentFactory { 30 | 31 | public ComponentArgumentFactory() { 32 | super(Types.VARCHAR); 33 | } 34 | 35 | @Override 36 | public Argument build(final Component value, final ConfigRegistry config) { 37 | return (position, statement, ctx) -> statement.setString(position, GsonComponentSerializer.gson().serialize(value)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/argument/KeyArgumentFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.argument; 21 | 22 | import java.sql.Types; 23 | import net.kyori.adventure.key.Key; 24 | import org.jdbi.v3.core.argument.AbstractArgumentFactory; 25 | import org.jdbi.v3.core.argument.Argument; 26 | import org.jdbi.v3.core.config.ConfigRegistry; 27 | 28 | public final class KeyArgumentFactory extends AbstractArgumentFactory { 29 | 30 | public KeyArgumentFactory() { 31 | super(Types.VARCHAR); 32 | } 33 | 34 | @Override 35 | public Argument build(final Key value, final ConfigRegistry config) { 36 | return (position, statement, ctx) -> statement.setString(position, value.toString()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/mapper/BinaryUUIDColumnMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.mapper; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import java.util.UUID; 25 | import net.draycia.carbon.common.util.FastUuidSansHyphens; 26 | import net.draycia.carbon.common.util.Strings; 27 | import org.checkerframework.checker.nullness.qual.Nullable; 28 | import org.jdbi.v3.core.mapper.ColumnMapper; 29 | import org.jdbi.v3.core.statement.StatementContext; 30 | 31 | public final class BinaryUUIDColumnMapper implements ColumnMapper { 32 | 33 | @Override 34 | public UUID map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException { 35 | final byte @Nullable [] bytes = rs.getBytes(columnNumber); 36 | 37 | if (bytes != null) { 38 | return FastUuidSansHyphens.parseUuid(Strings.asHexString(bytes)); 39 | } 40 | 41 | return null; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/mapper/ComponentColumnMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.mapper; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import net.draycia.carbon.common.util.Strings; 25 | import net.kyori.adventure.text.Component; 26 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; 27 | import org.jdbi.v3.core.mapper.ColumnMapper; 28 | import org.jdbi.v3.core.statement.StatementContext; 29 | 30 | public final class ComponentColumnMapper implements ColumnMapper { 31 | 32 | @Override 33 | public Component map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException { 34 | return GsonComponentSerializer.gson().deserializeOrNull(Strings.trim(rs.getString(columnNumber))); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/mapper/KeyColumnMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.mapper; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import net.draycia.carbon.common.util.Strings; 25 | import net.kyori.adventure.key.Key; 26 | import org.checkerframework.checker.nullness.qual.Nullable; 27 | import org.intellij.lang.annotations.Subst; 28 | import org.jdbi.v3.core.mapper.ColumnMapper; 29 | import org.jdbi.v3.core.statement.StatementContext; 30 | 31 | public final class KeyColumnMapper implements ColumnMapper { 32 | 33 | @Override 34 | public Key map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException { 35 | final @Nullable @Subst("key:value") String keyValue = Strings.trim(rs.getString(columnNumber)); 36 | 37 | if (keyValue != null) { 38 | return Key.key(keyValue); 39 | } 40 | 41 | return null; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/mapper/NativeUUIDColumnMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.mapper; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import java.util.UUID; 25 | import org.jdbi.v3.core.mapper.ColumnMapper; 26 | import org.jdbi.v3.core.statement.StatementContext; 27 | 28 | // todo: I'm not entirely sure that this is necessary, but I don't feel like testing PSQL 29 | public final class NativeUUIDColumnMapper implements ColumnMapper { 30 | 31 | @Override 32 | public UUID map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException { 33 | return rs.getObject(columnNumber, UUID.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/users/db/mapper/PartyRowMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.users.db.mapper; 21 | 22 | import java.sql.ResultSet; 23 | import java.sql.SQLException; 24 | import java.util.UUID; 25 | import net.draycia.carbon.common.users.PartyImpl; 26 | import net.kyori.adventure.text.Component; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | import org.jdbi.v3.core.mapper.ColumnMapper; 30 | import org.jdbi.v3.core.mapper.RowMapper; 31 | import org.jdbi.v3.core.statement.StatementContext; 32 | 33 | @DefaultQualifier(NonNull.class) 34 | public final class PartyRowMapper implements RowMapper { 35 | 36 | @Override 37 | public PartyImpl map(final ResultSet rs, final StatementContext ctx) throws SQLException { 38 | final ColumnMapper component = ctx.findColumnMapperFor(Component.class).orElseThrow(); 39 | final ColumnMapper uuid = ctx.findColumnMapperFor(UUID.class).orElseThrow(); 40 | return PartyImpl.create( 41 | component.map(rs, "name", ctx), 42 | uuid.map(rs, "partyid", ctx) 43 | ); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/CarbonDependencies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import java.nio.file.Path; 23 | import java.util.Set; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.framework.qual.DefaultQualifier; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | import xyz.jpenilla.gremlin.runtime.DependencyCache; 29 | import xyz.jpenilla.gremlin.runtime.DependencyResolver; 30 | import xyz.jpenilla.gremlin.runtime.DependencySet; 31 | 32 | @DefaultQualifier(NonNull.class) 33 | public final class CarbonDependencies { 34 | 35 | private CarbonDependencies() { 36 | } 37 | 38 | public static Set resolve(final Path cacheDir) { 39 | final DependencySet deps = DependencySet.readFromClasspathResource( 40 | CarbonDependencies.class.getClassLoader(), "carbon-dependencies.txt"); 41 | final DependencyCache cache = new DependencyCache(cacheDir); 42 | final Logger logger = LoggerFactory.getLogger(CarbonDependencies.class.getSimpleName()); 43 | final Set files; 44 | try (final DependencyResolver downloader = new DependencyResolver(logger)) { 45 | files = downloader.resolve(deps, cache).jarFiles(); 46 | } 47 | cache.cleanup(); 48 | return files; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/ChannelUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import net.draycia.carbon.api.CarbonChatProvider; 23 | import net.draycia.carbon.api.channels.ChatChannel; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.kyori.adventure.text.Component; 26 | 27 | public final class ChannelUtils { 28 | 29 | private ChannelUtils() { 30 | 31 | } 32 | 33 | public static void broadcastMessageToChannel(final Component msg, final ChatChannel channel) { 34 | 35 | // TODO: Emit events 36 | 37 | for (final CarbonPlayer recipient : CarbonChatProvider.carbonChat().server().players()) { 38 | if (channel.permissions().hearingPermitted(recipient).permitted() && !recipient.leftChannels().contains(channel.key())) { 39 | recipient.sendMessage(msg); 40 | } 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/DiscordRecipient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import net.kyori.adventure.audience.Audience; 23 | 24 | public final class DiscordRecipient implements Audience { 25 | 26 | public static final DiscordRecipient INSTANCE = new DiscordRecipient(); 27 | 28 | private DiscordRecipient() { 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/EmptyAudienceWithPointers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import net.draycia.carbon.api.users.CarbonPlayer; 23 | import net.kyori.adventure.audience.Audience; 24 | import net.kyori.adventure.audience.ForwardingAudience; 25 | import net.kyori.adventure.identity.Identity; 26 | import net.kyori.adventure.pointer.Pointers; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public final class EmptyAudienceWithPointers implements ForwardingAudience.Single { 32 | 33 | private final Pointers pointers; 34 | 35 | private EmptyAudienceWithPointers(final Pointers pointers) { 36 | this.pointers = pointers; 37 | } 38 | 39 | @Override 40 | public Audience audience() { 41 | return Audience.empty(); 42 | } 43 | 44 | @Override 45 | public Pointers pointers() { 46 | return this.pointers; 47 | } 48 | 49 | public static EmptyAudienceWithPointers forCarbonPlayer(final CarbonPlayer player) { 50 | return new EmptyAudienceWithPointers(Pointers.builder() 51 | .withStatic(Identity.UUID, player.uuid()) 52 | .withStatic(Identity.NAME, player.username()) 53 | .withDynamic(Identity.DISPLAY_NAME, player::displayName) 54 | .build()); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/Exceptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import java.util.function.Consumer; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.framework.qual.DefaultQualifier; 25 | 26 | @DefaultQualifier(NonNull.class) 27 | public final class Exceptions { 28 | 29 | private Exceptions() { 30 | } 31 | 32 | @SuppressWarnings("unchecked") 33 | public static RuntimeException rethrow(final Throwable t) throws X { 34 | throw (X) t; 35 | } 36 | 37 | public static Consumer sneaky(final CheckedConsumer consumer) { 38 | return t -> { 39 | try { 40 | consumer.accept(t); 41 | } catch (final Throwable thr) { 42 | rethrow(thr); 43 | } 44 | }; 45 | } 46 | 47 | @FunctionalInterface 48 | public interface CheckedConsumer { 49 | void accept(T t) throws X; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/SQLDrivers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import java.sql.Driver; 23 | import java.util.ServiceLoader; 24 | 25 | public final class SQLDrivers { 26 | 27 | private SQLDrivers() { 28 | } 29 | 30 | public static void loadFrom(final ClassLoader loader) { 31 | ServiceLoader.load(Driver.class, loader).stream() 32 | .forEach(provider -> forceInit(provider.type())); 33 | } 34 | 35 | private static Class forceInit(final Class klass) { 36 | try { 37 | Class.forName(klass.getName(), true, klass.getClassLoader()); 38 | } catch (final ClassNotFoundException e) { 39 | throw new AssertionError(e); 40 | } 41 | return klass; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/net/draycia/carbon/common/util/Strings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.common.util; 21 | 22 | import com.google.common.base.Suppliers; 23 | import java.util.function.Supplier; 24 | import java.util.regex.Pattern; 25 | import net.kyori.adventure.text.TextReplacementConfig; 26 | import net.kyori.adventure.text.event.ClickEvent; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.checker.nullness.qual.Nullable; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | public final class Strings { 33 | 34 | private static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?"); 35 | public static final Supplier URL_REPLACEMENT_CONFIG = Suppliers.memoize( 36 | () -> TextReplacementConfig.builder() 37 | .match(DEFAULT_URL_PATTERN) 38 | .replacement(builder -> builder.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, builder.content()))) 39 | .build() 40 | ); 41 | 42 | private Strings() { 43 | } 44 | 45 | public static @Nullable String trim(final @Nullable String s) { 46 | return s == null ? null : s.trim(); 47 | } 48 | 49 | public static String asHexString(final byte[] bytes) { 50 | final StringBuilder sb = new StringBuilder(bytes.length * 2); 51 | for (final byte b : bytes) { 52 | sb.append("%02x".formatted(b & 0xFF)); 53 | } 54 | return sb.toString(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/clear-ignores.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM carbon_ignores WHERE (id = :id); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/clear-leftchannels.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM carbon_leftchannels WHERE (id = :id); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/clear-party-members.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM carbon_party_members WHERE (partyid = :partyid); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/drop-party-member.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM carbon_party_members WHERE (playerid = :playerid); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/drop-party.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM carbon_parties WHERE (partyid = :partyid); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/insert-party-member.sql: -------------------------------------------------------------------------------- 1 | INSERT{!PSQL: IGNORE} INTO carbon_party_members (partyid, playerid) VALUES(:partyid, :playerid){PSQL: ON CONFLICT DO NOTHING}; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/insert-party.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO carbon_parties( 2 | partyid, 3 | name 4 | ) VALUES ( 5 | :partyid, 6 | :name 7 | ); 8 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/insert-player.sql: -------------------------------------------------------------------------------- 1 | INSERT{!PSQL: IGNORE} INTO carbon_users( 2 | id, 3 | muted, 4 | muteexpiration, 5 | deafened, 6 | selectedchannel, 7 | displayname, 8 | lastwhispertarget, 9 | whisperreplytarget, 10 | spying, 11 | ignoringdms, 12 | party, 13 | applycustomfilters 14 | ) VALUES ( 15 | :id, 16 | :muted, 17 | :muteexpiration, 18 | :deafened, 19 | :selectedchannel, 20 | :displayname, 21 | :lastwhispertarget, 22 | :whisperreplytarget, 23 | :spying, 24 | :ignoringdms, 25 | :party, 26 | :applycustomfilters 27 | ){PSQL: ON CONFLICT DO NOTHING}; 28 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V1__create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_users ( 2 | `id` UUID NOT NULL PRIMARY KEY, 3 | `muted` BOOLEAN, 4 | `deafened` BOOLEAN, 5 | `selectedchannel` VARCHAR(256), 6 | `displayname` VARCHAR(1024), 7 | `lastwhispertarget` UUID, 8 | `whisperreplytarget` UUID, 9 | `spying` BOOLEAN, 10 | `ignoringdms` BOOLEAN 11 | ); 12 | 13 | CREATE TABLE carbon_ignores ( 14 | `id` UUID NOT NULL, 15 | `ignoredplayer` UUID NOT NULL, 16 | PRIMARY KEY (id, ignoredplayer) 17 | ); 18 | 19 | CREATE TABLE carbon_leftchannels ( 20 | `id` UUID NOT NULL, 21 | `channel` VARCHAR(256) NOT NULL, 22 | PRIMARY KEY (id, channel) 23 | ); 24 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V2__increase_nickname_size.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users MODIFY displayname VARCHAR(8192); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V3__parties.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_party_members ( 2 | `partyid` UUID NOT NULL, 3 | `playerid` UUID NOT NULL, 4 | PRIMARY KEY (partyid, playerid) 5 | ); 6 | 7 | CREATE TABLE carbon_parties ( 8 | `partyid` UUID NOT NULL PRIMARY KEY, 9 | `name` VARCHAR(8192) 10 | ); 11 | 12 | ALTER TABLE carbon_users ADD COLUMN party UUID; 13 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V4__filters.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN applycustomfilters BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V5__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN muteexpiration BOOLEAN AFTER muted; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/h2/V6__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ALTER COLUMN muteexpiration BIGINT; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V10__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users MODIFY COLUMN muteexpiration BIGINT; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V1__create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_users ( 2 | `id` BINARY(16) NOT NULL PRIMARY KEY, 3 | `muted` BOOLEAN, 4 | `deafened` BOOLEAN, 5 | `selectedchannel` VARCHAR(256), 6 | `username` VARCHAR(20), 7 | `displayname` VARCHAR(1024), 8 | `lastwhispertarget` BINARY(16), 9 | `whisperreplytarget` BINARY(16), 10 | `spying` BOOLEAN 11 | ); 12 | 13 | CREATE TABLE carbon_ignores ( 14 | `id` BINARY(16) NOT NULL, 15 | `ignoredplayer` BINARY(16) NOT NULL, 16 | PRIMARY KEY (id, ignoredplayer) 17 | ); 18 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V2__create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_leftchannels ( 2 | `id` BINARY(16) NOT NULL, 3 | `channel` BINARY(16) NOT NULL, 4 | PRIMARY KEY (id, channel) 5 | ); 6 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V3__fix_leftchannels.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE carbon_leftchannels; 2 | CREATE TABLE carbon_leftchannels ( 3 | `id` BINARY(16) NOT NULL, 4 | `channel` VARCHAR(256) NOT NULL, 5 | PRIMARY KEY (id, channel) 6 | ); 7 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V4__drop_usernames.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users DROP COLUMN username; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V5__add_dmtoggle.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN ignoringdms BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V6__increase_nickname_size.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users MODIFY displayname VARCHAR(8192); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V7__parties.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_party_members ( 2 | `partyid` BINARY(16) NOT NULL, 3 | `playerid` BINARY(16) NOT NULL, 4 | PRIMARY KEY (partyid, playerid) 5 | ); 6 | 7 | CREATE TABLE carbon_parties ( 8 | `partyid` BINARY(16) NOT NULL PRIMARY KEY, 9 | `name` VARCHAR(8192) 10 | ); 11 | 12 | ALTER TABLE carbon_users ADD COLUMN party BINARY(16); 13 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V8__filters.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN applycustomfilters BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/mysql/V9__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN muteexpiration BOOLEAN AFTER muted; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V10__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ALTER COLUMN muteexpiration TYPE BIGINT USING (CASE WHEN muteexpiration THEN 1 ELSE 0 END); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V1__create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_users ( 2 | id UUID NOT NULL PRIMARY KEY, 3 | muted BOOLEAN, 4 | deafened BOOLEAN, 5 | selectedchannel VARCHAR(256), 6 | username VARCHAR(20), 7 | displayname VARCHAR(1024), 8 | lastwhispertarget UUID, 9 | whisperreplytarget UUID, 10 | spying BOOLEAN 11 | ); 12 | 13 | CREATE TABLE carbon_ignores ( 14 | id UUID NOT NULL, 15 | ignoredplayer UUID NOT NULL, 16 | PRIMARY KEY (id, ignoredplayer) 17 | ); 18 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V2__create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_leftchannels ( 2 | id UUID NOT NULL, 3 | channel VARCHAR(100) NOT NULL, 4 | PRIMARY KEY (id, channel) 5 | ); 6 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V3__fix_leftchannels.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_leftchannels 2 | ALTER COLUMN channel TYPE VARCHAR(256), 3 | ALTER COLUMN channel SET NOT NULL; 4 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V4__drop_usernames.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users DROP COLUMN username; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V5__add_dmtoggle.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN ignoringdms BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V6__increase_nickname_size.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ALTER COLUMN displayname TYPE VARCHAR(8192); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V7__parties.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE carbon_party_members ( 2 | partyid UUID NOT NULL, 3 | playerid UUID NOT NULL, 4 | PRIMARY KEY (partyid, playerid) 5 | ); 6 | 7 | CREATE TABLE carbon_parties ( 8 | partyid UUID NOT NULL PRIMARY KEY, 9 | name VARCHAR(8192) 10 | ); 11 | 12 | ALTER TABLE carbon_users ADD COLUMN party UUID; 13 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V8__filters.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN applycustomfilters BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/migrations/postgresql/V9__tempmute.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE carbon_users ADD COLUMN muteexpiration BOOLEAN; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/save-ignores.sql: -------------------------------------------------------------------------------- 1 | INSERT{!PSQL: IGNORE} INTO carbon_ignores (id, ignoredplayer) VALUES(:id, :ignoredplayer){PSQL: ON CONFLICT DO NOTHING}; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/save-leftchannels.sql: -------------------------------------------------------------------------------- 1 | INSERT{!PSQL: IGNORE} INTO carbon_leftchannels (id, channel) VALUES(:id, :channel){PSQL: ON CONFLICT DO NOTHING}; 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/select-ignores.sql: -------------------------------------------------------------------------------- 1 | SELECT ignoredplayer FROM carbon_ignores WHERE (id = :id); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/select-leftchannels.sql: -------------------------------------------------------------------------------- 1 | SELECT channel FROM carbon_leftchannels WHERE (id = :id); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/select-party-members.sql: -------------------------------------------------------------------------------- 1 | SELECT playerid FROM carbon_party_members WHERE (partyid = :partyid); 2 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/select-party.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | partyid, 3 | name 4 | FROM carbon_parties WHERE (partyid = :partyid); 5 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/select-player.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | id, 3 | muted, 4 | muteexpiration, 5 | deafened, 6 | selectedchannel, 7 | displayname, 8 | lastwhispertarget, 9 | whisperreplytarget, 10 | spying, 11 | ignoringdms, 12 | party, 13 | applycustomfilters 14 | FROM carbon_users WHERE (id = :id); 15 | -------------------------------------------------------------------------------- /common/src/main/resources/queries/update-player.sql: -------------------------------------------------------------------------------- 1 | UPDATE carbon_users SET 2 | muted = :muted, 3 | muteexpiration = :muteexpiration, 4 | deafened = :deafened, 5 | selectedchannel = :selectedchannel, 6 | displayname = :displayname, 7 | lastwhispertarget = :lastwhispertarget, 8 | whisperreplytarget = :whisperreplytarget, 9 | spying = :spying, 10 | ignoringdms = :ignoringdms, 11 | party = :party, 12 | applycustomfilters = :applycustomfilters 13 | WHERE (id = :id); 14 | -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - source: common/src/main/resources/locale/messages-en_US.properties 3 | translation: /common/src/main/resources/locale/messages-%locale_with_underscore%.properties 4 | bundles: 5 | - 1 6 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/draycia/carbon/fabric/CarbonFabricBootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.fabric; 21 | 22 | import com.google.inject.Guice; 23 | import net.draycia.carbon.api.CarbonChatProvider; 24 | import net.draycia.carbon.common.util.CarbonDependencies; 25 | import net.fabricmc.api.ModInitializer; 26 | import net.fabricmc.loader.api.FabricLoader; 27 | import xyz.jpenilla.gremlin.runtime.platformsupport.FabricClasspathAppender; 28 | 29 | public class CarbonFabricBootstrap implements ModInitializer { 30 | 31 | @Override 32 | public void onInitialize() { 33 | new FabricClasspathAppender().append( 34 | CarbonDependencies.resolve( 35 | FabricLoader.getInstance().getConfigDir().resolve("carbonchat").resolve("libraries") 36 | ) 37 | ); 38 | 39 | final CarbonChatFabric carbonChat = Guice.createInjector(new CarbonChatFabricModule()) 40 | .getInstance(CarbonChatFabric.class); 41 | CarbonChatProvider.register(carbonChat); 42 | carbonChat.onInitialize(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/draycia/carbon/fabric/FabricScheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.fabric; 21 | 22 | import com.google.inject.Inject; 23 | import com.google.inject.Singleton; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.common.PlatformScheduler; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | @Singleton 31 | public final class FabricScheduler implements PlatformScheduler { 32 | 33 | private final MinecraftServerHolder serverHolder; 34 | 35 | @Inject 36 | private FabricScheduler(final MinecraftServerHolder serverHolder) { 37 | this.serverHolder = serverHolder; 38 | } 39 | 40 | @Override 41 | public void scheduleForPlayer(final CarbonPlayer carbonPlayer, final Runnable runnable) { 42 | this.serverHolder.requireServer().execute(runnable); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/draycia/carbon/fabric/MinecraftServerHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.fabric; 21 | 22 | import com.google.inject.Inject; 23 | import com.google.inject.Singleton; 24 | import java.util.Objects; 25 | import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; 26 | import net.minecraft.server.MinecraftServer; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.checker.nullness.qual.Nullable; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | @Singleton 33 | public final class MinecraftServerHolder { 34 | 35 | private volatile @Nullable MinecraftServer server; 36 | 37 | @Inject 38 | private MinecraftServerHolder() { 39 | ServerLifecycleEvents.SERVER_STARTING.register(server -> this.server = server); 40 | ServerLifecycleEvents.SERVER_STOPPED.register(server -> this.server = null); 41 | } 42 | 43 | public MinecraftServer requireServer() { 44 | return Objects.requireNonNull(this.server, "server requested when not active"); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/draycia/carbon/fabric/command/FabricCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.fabric.command; 21 | 22 | import me.lucko.fabric.api.permissions.v0.Permissions; 23 | import net.draycia.carbon.common.command.Commander; 24 | import net.kyori.adventure.audience.Audience; 25 | import net.kyori.adventure.audience.ForwardingAudience; 26 | import net.minecraft.commands.CommandSourceStack; 27 | import org.checkerframework.checker.nullness.qual.NonNull; 28 | import org.checkerframework.framework.qual.DefaultQualifier; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public interface FabricCommander extends Commander, ForwardingAudience.Single { 32 | 33 | static FabricCommander from(final CommandSourceStack commandSourceStack) { 34 | return new FabricCommanderImpl(commandSourceStack); 35 | } 36 | 37 | CommandSourceStack commandSourceStack(); 38 | 39 | @Override 40 | default Audience audience() { 41 | return this.commandSourceStack(); 42 | } 43 | 44 | record FabricCommanderImpl(CommandSourceStack commandSourceStack) implements FabricCommander { 45 | 46 | @Override 47 | public boolean hasPermission(final String permission) { 48 | return Permissions.check(this.commandSourceStack, permission, this.commandSourceStack.getServer().getOperatorUserPermissionLevel()); 49 | } 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /fabric/src/main/resources/carbonchat.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8.4", 4 | "package": "net.draycia.carbon.fabric.mixin", 5 | "compatibilityLevel": "JAVA_21", 6 | "mixins": [], 7 | "client": [ 8 | ], 9 | "injectors": { 10 | "defaultRequire": 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /fabric/src/main/resources/data/carbonchat/chat_type/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "chat": { 3 | "parameters": [ 4 | "content" 5 | ], 6 | "translation_key": "%s" 7 | }, 8 | "narration": { 9 | "parameters": [ 10 | "content" 11 | ], 12 | "translation_key": "%s" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /fabric/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 18, 4 | "description": "CarbonChat Data" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project Properties 2 | projectVersion=3.0.0-SNAPSHOT 3 | group=de.hexaoxi 4 | description=CarbonChat - A modern chat plugin 5 | 6 | # Gradle Properties 7 | org.gradle.caching=true 8 | org.gradle.parallel=true 9 | org.gradle.jvmargs=-Xmx2G 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hexaoxide/Carbon/ba94e985c16a1947762633eb2323475387ffcd1d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/CarbonPaperBootstrap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper; 21 | 22 | import com.google.inject.Guice; 23 | import net.draycia.carbon.api.CarbonChatProvider; 24 | import org.bukkit.plugin.java.JavaPlugin; 25 | import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public final class CarbonPaperBootstrap extends JavaPlugin { 31 | 32 | private @MonotonicNonNull CarbonChatPaper carbonChat; 33 | 34 | @Override 35 | public void onLoad() { 36 | this.carbonChat = Guice.createInjector(new CarbonChatPaperModule(this)) 37 | .getInstance(CarbonChatPaper.class); 38 | CarbonChatProvider.register(this.carbonChat); 39 | } 40 | 41 | @Override 42 | public void onEnable() { 43 | if (this.carbonChat != null) { 44 | this.carbonChat.onEnable(); 45 | } 46 | } 47 | 48 | @Override 49 | public void onDisable() { 50 | if (this.carbonChat != null) { 51 | this.carbonChat.onDisable(); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/CarbonPaperLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper; 21 | 22 | import io.papermc.paper.plugin.loader.PluginClasspathBuilder; 23 | import io.papermc.paper.plugin.loader.PluginLoader; 24 | import net.draycia.carbon.common.util.CarbonDependencies; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | import xyz.jpenilla.gremlin.runtime.platformsupport.PaperClasspathAppender; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public class CarbonPaperLoader implements PluginLoader { 31 | 32 | @Override 33 | public void classloader(final PluginClasspathBuilder classpathBuilder) { 34 | new PaperClasspathAppender(classpathBuilder).append( 35 | CarbonDependencies.resolve(classpathBuilder.getContext().getDataDirectory().resolve("libraries")) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/command/PaperCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper.command; 21 | 22 | import net.draycia.carbon.common.command.Commander; 23 | import net.kyori.adventure.audience.Audience; 24 | import net.kyori.adventure.audience.ForwardingAudience; 25 | import org.bukkit.command.CommandSender; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | 29 | @DefaultQualifier(NonNull.class) 30 | public interface PaperCommander extends Commander, ForwardingAudience.Single { 31 | 32 | static PaperCommander from(final CommandSender sender) { 33 | return new PaperCommanderImpl(sender); 34 | } 35 | 36 | CommandSender commandSender(); 37 | 38 | record PaperCommanderImpl(CommandSender commandSender) implements PaperCommander { 39 | 40 | @Override 41 | public Audience audience() { 42 | return this.commandSender; 43 | } 44 | 45 | @Override 46 | public boolean hasPermission(final String permission) { 47 | return this.commandSender.hasPermission(permission); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/command/PaperPlayerCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper.command; 21 | 22 | import net.draycia.carbon.api.users.CarbonPlayer; 23 | import net.draycia.carbon.api.users.UserManager; 24 | import net.draycia.carbon.common.command.PlayerCommander; 25 | import net.kyori.adventure.audience.Audience; 26 | import org.bukkit.command.CommandSender; 27 | import org.bukkit.entity.Player; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | import static java.util.Objects.requireNonNull; 32 | 33 | @DefaultQualifier(NonNull.class) 34 | public record PaperPlayerCommander( 35 | UserManager userManager, 36 | Player player 37 | ) implements PlayerCommander, PaperCommander { 38 | 39 | @Override 40 | public CommandSender commandSender() { 41 | return this.player; 42 | } 43 | 44 | @Override 45 | public Audience audience() { 46 | return this.player; 47 | } 48 | 49 | @Override 50 | public CarbonPlayer carbonPlayer() { 51 | return requireNonNull(this.userManager.user(this.player.getUniqueId()).join(), "No CarbonPlayer for logged in Player!"); 52 | } 53 | 54 | @Override 55 | public boolean hasPermission(final String permission) { 56 | return this.player.hasPermission(permission); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/hooks/PAPIChatHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper.hooks; 21 | 22 | import com.google.inject.Inject; 23 | import me.clip.placeholderapi.PlaceholderAPI; 24 | import net.draycia.carbon.api.event.CarbonEventHandler; 25 | import net.draycia.carbon.common.event.events.CarbonEarlyChatEvent; 26 | import net.draycia.carbon.common.listeners.Listener; 27 | import net.draycia.carbon.common.util.ColorUtils; 28 | import net.draycia.carbon.paper.CarbonChatPaper; 29 | import net.draycia.carbon.paper.users.CarbonPlayerPaper; 30 | import org.checkerframework.checker.nullness.qual.NonNull; 31 | import org.checkerframework.framework.qual.DefaultQualifier; 32 | 33 | @DefaultQualifier(NonNull.class) 34 | public class PAPIChatHook implements Listener { 35 | 36 | @Inject 37 | public PAPIChatHook(final CarbonEventHandler events) { 38 | events.subscribe(CarbonEarlyChatEvent.class, 0, false, event -> { 39 | if (!CarbonChatPaper.papiLoaded()) { 40 | return; 41 | } 42 | 43 | if (!event.sender().hasPermission("carbon.chatplaceholders")) { 44 | return; 45 | } 46 | 47 | if (!(event.sender() instanceof CarbonPlayerPaper playerPaper)) { 48 | return; 49 | } 50 | 51 | final String papiParsed = PlaceholderAPI.setPlaceholders(playerPaper.bukkitPlayer(), event.message()); 52 | 53 | event.message(ColorUtils.legacyToMiniMessage(papiParsed)); 54 | }); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/integration/dsrv/DSRVIntegration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper.integration.dsrv; 21 | 22 | import com.google.inject.Inject; 23 | import com.google.inject.Injector; 24 | import net.draycia.carbon.common.config.ConfigManager; 25 | import net.draycia.carbon.common.integration.Integration; 26 | import org.bukkit.Bukkit; 27 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 28 | 29 | public final class DSRVIntegration implements Integration { 30 | 31 | private final Injector injector; 32 | private final DSRVIntegration.Config config; 33 | 34 | @Inject 35 | private DSRVIntegration( 36 | final Injector injector, 37 | final ConfigManager configManager 38 | ) { 39 | this.injector = injector; 40 | this.config = this.config(configManager, configMeta()); 41 | } 42 | 43 | @Override 44 | public boolean eligible() { 45 | return this.config.enabled && Bukkit.getPluginManager().isPluginEnabled("DiscordSRV"); 46 | } 47 | 48 | @Override 49 | public void register() { 50 | this.injector.getInstance(DSRVListener.class).register(); 51 | } 52 | 53 | public static ConfigMeta configMeta() { 54 | return Integration.configMeta("discordsrv", DSRVIntegration.Config.class); 55 | } 56 | 57 | @ConfigSerializable 58 | public static final class Config { 59 | 60 | boolean enabled = true; 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /paper/src/main/java/net/draycia/carbon/paper/integration/essxd/EssXDIntegration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.paper.integration.essxd; 21 | 22 | import com.google.inject.Inject; 23 | import com.google.inject.Injector; 24 | import net.draycia.carbon.common.config.ConfigManager; 25 | import net.draycia.carbon.common.integration.Integration; 26 | import org.bukkit.Bukkit; 27 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 28 | 29 | public final class EssXDIntegration implements Integration { 30 | 31 | private final Injector injector; 32 | private final EssXDIntegration.Config config; 33 | 34 | @Inject 35 | private EssXDIntegration( 36 | final Injector injector, 37 | final ConfigManager configManager 38 | ) { 39 | this.injector = injector; 40 | this.config = this.config(configManager, configMeta()); 41 | } 42 | 43 | @Override 44 | public boolean eligible() { 45 | return this.config.enabled && Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord"); 46 | } 47 | 48 | @Override 49 | public void register() { 50 | this.injector.getInstance(EssXDListener.class).register(); 51 | } 52 | 53 | public static ConfigMeta configMeta() { 54 | return Integration.configMeta("essentialsx_discord", EssXDIntegration.Config.class); 55 | } 56 | 57 | @ConfigSerializable 58 | public static final class Config { 59 | 60 | boolean enabled = true; 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /sponge/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.spongepowered.gradle.plugin.config.PluginLoaders 2 | import org.spongepowered.plugin.metadata.model.PluginDependency 3 | import java.util.* 4 | 5 | plugins { 6 | id("carbon.shadow-platform") 7 | id("org.spongepowered.gradle.plugin") 8 | } 9 | 10 | dependencies { 11 | implementation(projects.carbonchatCommon) 12 | implementation(libs.cloudSponge) 13 | //implementation(libs.bstatsSponge) // not updated for api 8 yet 14 | } 15 | 16 | tasks { 17 | shadowJar { 18 | dependencies { 19 | // included in sponge 20 | exclude(dependency("io.leangen.geantyref:geantyref")) 21 | exclude(dependency("com.google.inject:guice")) 22 | exclude(dependency("aopalliance:aopalliance")) 23 | exclude(dependency("javax.inject:javax.inject")) 24 | } 25 | } 26 | } 27 | 28 | sponge { 29 | injectRepositories(false) // We specify repositories in settings.gradle.kts 30 | apiVersion("10.0.0-SNAPSHOT") 31 | plugin(rootProject.name.toLowerCase(Locale.ROOT)) { 32 | loader { 33 | name(PluginLoaders.JAVA_PLAIN) 34 | version("1.0") 35 | } 36 | displayName(rootProject.name) 37 | entrypoint("net.draycia.carbon.sponge.CarbonChatSponge") 38 | description(project.description) 39 | license("GPLv3") 40 | links { 41 | homepage(GITHUB_REPO_URL) 42 | source(GITHUB_REPO_URL) 43 | issues("$GITHUB_REPO_URL/issues") 44 | } 45 | contributor("Vicarious") { 46 | description("Lead Developer") 47 | } 48 | contributor("Glare") { 49 | description("Moral Support") 50 | } 51 | dependency("spongeapi") { 52 | loadOrder(PluginDependency.LoadOrder.AFTER) 53 | optional(false) 54 | } 55 | dependency("luckperms") { 56 | version(">=5.0.0") 57 | optional(true) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sponge/src/main/java/net/draycia/carbon/sponge/command/SpongeCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2021 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.sponge.command; 21 | 22 | import net.draycia.carbon.common.command.Commander; 23 | import net.kyori.adventure.audience.Audience; 24 | import net.kyori.adventure.audience.ForwardingAudience; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; 27 | import org.jetbrains.annotations.NotNull; 28 | import org.spongepowered.api.command.CommandCause; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public interface SpongeCommander extends Commander, ForwardingAudience.Single { 32 | 33 | static SpongeCommander from(final CommandCause commandCause) { 34 | return new SpongeCommanderImpl(commandCause); 35 | } 36 | 37 | @NonNull CommandCause commandCause(); 38 | 39 | record SpongeCommanderImpl(CommandCause commandCause) implements SpongeCommander { 40 | 41 | @Override 42 | public @NotNull Audience audience() { 43 | return this.commandCause.audience(); 44 | } 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /sponge/src/main/java/net/draycia/carbon/sponge/command/SpongePlayerCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2021 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.sponge.command; 21 | 22 | import net.draycia.carbon.api.CarbonChat; 23 | import net.draycia.carbon.api.users.CarbonPlayer; 24 | import net.draycia.carbon.common.command.PlayerCommander; 25 | import net.kyori.adventure.audience.Audience; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | import org.jetbrains.annotations.NotNull; 29 | import org.spongepowered.api.command.CommandCause; 30 | import org.spongepowered.api.entity.living.player.server.ServerPlayer; 31 | 32 | import static java.util.Objects.requireNonNull; 33 | 34 | @DefaultQualifier(NonNull.class) 35 | public record SpongePlayerCommander( 36 | CarbonChat carbon, 37 | ServerPlayer player, 38 | CommandCause commandCause 39 | ) implements PlayerCommander, SpongeCommander { 40 | 41 | @Override 42 | public CarbonPlayer carbonPlayer() { 43 | return requireNonNull(this.carbon.server().userManager().carbonPlayer(this.player.uniqueId()).join().player(), "No CarbonPlayer for logged in Player!"); 44 | } 45 | 46 | @Override 47 | public @NotNull Audience audience() { 48 | return this.commandCause.audience(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /sponge/src/main/java/net/draycia/carbon/sponge/listeners/SpongeReloadListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2021 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.sponge.listeners; 21 | 22 | import com.google.inject.Inject; 23 | import net.draycia.carbon.api.CarbonChat; 24 | import net.draycia.carbon.common.channels.CarbonChannelRegistry; 25 | import net.draycia.carbon.common.config.ConfigFactory; 26 | import net.draycia.carbon.common.event.CarbonReloadEvent; 27 | import org.spongepowered.api.event.Listener; 28 | import org.spongepowered.api.event.lifecycle.RefreshGameEvent; 29 | 30 | public class SpongeReloadListener { 31 | 32 | final CarbonChat carbonChat; 33 | final ConfigFactory configFactory; 34 | final CarbonChannelRegistry channelRegistry; 35 | 36 | @Inject 37 | public SpongeReloadListener( 38 | final CarbonChat carbonChat, 39 | final ConfigFactory configFactory, 40 | final CarbonChannelRegistry channelRegistry 41 | ) { 42 | this.carbonChat = carbonChat; 43 | this.configFactory = configFactory; 44 | this.channelRegistry = channelRegistry; 45 | } 46 | 47 | @Listener 48 | public void onReload(final RefreshGameEvent event) { 49 | this.carbonChat.eventHandler().emit(new CarbonReloadEvent()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /velocity/src/main/java/net/draycia/carbon/velocity/command/VelocityCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.velocity.command; 21 | 22 | import com.velocitypowered.api.command.CommandSource; 23 | import net.draycia.carbon.common.command.Commander; 24 | import net.kyori.adventure.audience.Audience; 25 | import net.kyori.adventure.audience.ForwardingAudience; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.checkerframework.framework.qual.DefaultQualifier; 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | @DefaultQualifier(NonNull.class) 31 | public interface VelocityCommander extends Commander, ForwardingAudience.Single { 32 | 33 | static VelocityCommander from(final CommandSource source) { 34 | return new VelocityCommanderImpl(source); 35 | } 36 | 37 | CommandSource commandSource(); 38 | 39 | record VelocityCommanderImpl(CommandSource commandSource) implements VelocityCommander { 40 | 41 | @Override 42 | public @NotNull Audience audience() { 43 | return this.commandSource; 44 | } 45 | 46 | @Override 47 | public boolean hasPermission(final String permission) { 48 | return this.commandSource.hasPermission(permission); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /velocity/src/main/java/net/draycia/carbon/velocity/command/VelocityPlayerCommander.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.velocity.command; 21 | 22 | import com.velocitypowered.api.command.CommandSource; 23 | import com.velocitypowered.api.proxy.Player; 24 | import net.draycia.carbon.api.users.CarbonPlayer; 25 | import net.draycia.carbon.api.users.UserManager; 26 | import net.draycia.carbon.common.command.PlayerCommander; 27 | import net.kyori.adventure.audience.Audience; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | import static java.util.Objects.requireNonNull; 33 | 34 | @DefaultQualifier(NonNull.class) 35 | public record VelocityPlayerCommander( 36 | UserManager userManager, 37 | Player player 38 | ) implements PlayerCommander, VelocityCommander { 39 | 40 | @Override 41 | public CommandSource commandSource() { 42 | return this.player; 43 | } 44 | 45 | @Override 46 | public @NotNull Audience audience() { 47 | return this.player; 48 | } 49 | 50 | @Override 51 | public CarbonPlayer carbonPlayer() { 52 | return requireNonNull(this.userManager.user(this.player.getUniqueId()).join(), "No CarbonPlayer for logged in Player!"); 53 | } 54 | 55 | @Override 56 | public boolean hasPermission(final String permission) { 57 | return this.player.hasPermission(permission); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /velocity/src/main/java/net/draycia/carbon/velocity/listeners/VelocityListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CarbonChat 3 | * 4 | * Copyright (c) 2024 Josua Parks (Vicarious) 5 | * Contributors 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package net.draycia.carbon.velocity.listeners; 21 | 22 | import com.velocitypowered.api.event.AwaitingEventExecutor; 23 | import com.velocitypowered.api.event.EventManager; 24 | import net.draycia.carbon.velocity.CarbonVelocityBootstrap; 25 | 26 | public interface VelocityListener extends AwaitingEventExecutor { 27 | 28 | void register(EventManager eventManager, CarbonVelocityBootstrap bootstrap); 29 | } 30 | --------------------------------------------------------------------------------