├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── V1_10 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_10.java ├── V1_11 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_11.java ├── V1_12 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_12.java ├── V1_13 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_13.java ├── V1_13_1 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_13_1.java ├── V1_14 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_14.java ├── V1_15 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_15.java ├── V1_16 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_16.java ├── V1_16_2 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_16_2.java ├── V1_16_4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_16_4.java ├── V1_17 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_17.java ├── V1_18 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_18.java ├── V1_18_2 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_18_2.java ├── V1_19 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_19.java ├── V1_19_3 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_19_3.java ├── V1_19_4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_19_4.java ├── V1_20 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_20.java ├── V1_20_2 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_20_2.java ├── V1_20_3 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_20_3.java ├── V1_20_5 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_20_5.java ├── V1_20_6 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_20_6.java ├── V1_21 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21.java ├── V1_21_1 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_1.java ├── V1_21_10 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_10.java ├── V1_21_2 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_2.java ├── V1_21_3 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_3.java ├── V1_21_4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_4.java ├── V1_21_5 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_5.java ├── V1_21_6 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_6.java ├── V1_21_7 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_7.java ├── V1_21_8 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_8.java ├── V1_21_9 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_21_9.java ├── V1_8 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_8.java ├── V1_8_3 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_8_3.java ├── V1_8_4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_8_4.java ├── V1_9 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_9.java ├── V1_9_4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ └── nms │ └── V1_9_4.java ├── abstraction ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── loohp │ └── interactivechat │ ├── nms │ └── NMSWrapper.java │ ├── objectholders │ ├── CommandSuggestion.java │ ├── CustomTabCompletionAction.java │ ├── IICPlayer.java │ ├── IOfflineICPlayer.java │ ├── InternalOfflinePlayerInfo.java │ ├── ValuePairs.java │ └── ValueTrios.java │ └── utils │ ├── ComponentCompacting.java │ ├── ComponentFlattening.java │ ├── NativeJsonConverter.java │ ├── ReflectionUtils.java │ └── UnsafeAccessor.java ├── common ├── lib │ ├── CMIAPI-9.7.4.1.jar │ ├── Dynmap-3.7-beta-7-spigot.jar │ ├── ExcellentEnchants-5.1.0.jar │ ├── MPDBStriped-v3.36.3.jar │ ├── VentureChat-3.7.1.jar │ ├── bungeecord-proxy-1.21-R0.1-SNAPSHOT.jar │ ├── eco-6.75.2-all.jar │ ├── nightcore-2.7.9.jar │ └── velocity-3.4.0-SNAPSHOT-469.jar ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── loohp │ │ └── interactivechat │ │ ├── Commands.java │ │ ├── InteractiveChat.java │ │ ├── api │ │ ├── InteractiveChatAPI.java │ │ └── events │ │ │ ├── ICPlayerEvent.java │ │ │ ├── ICPlayerJoinEvent.java │ │ │ ├── ICPlayerQuitEvent.java │ │ │ ├── InteractiveChatConfigReloadEvent.java │ │ │ ├── InventoryPlaceholderEvent.java │ │ │ ├── ItemPlaceholderEvent.java │ │ │ ├── OfflineICPlayerCreationEvent.java │ │ │ ├── OfflineICPlayerEvent.java │ │ │ ├── OfflineICPlayerUpdateEvent.java │ │ │ ├── PlaceholderEvent.java │ │ │ ├── PlayerMentionPlayerEvent.java │ │ │ ├── PostPacketComponentProcessEvent.java │ │ │ ├── PreChatPacketSendEvent.java │ │ │ ├── PreExternalResponseSendEvent.java │ │ │ ├── PrePacketComponentProcessEvent.java │ │ │ └── ProxyCustomDataRecievedEvent.java │ │ ├── bungeemessaging │ │ ├── BungeeMessageListener.java │ │ ├── BungeeMessageSender.java │ │ ├── ServerPingListener.java │ │ └── ServerPingListenerUtils.java │ │ ├── config │ │ ├── Config.java │ │ └── ConfigManager.java │ │ ├── data │ │ ├── Database.java │ │ └── PlayerDataManager.java │ │ ├── datafixer │ │ └── ConfigDataFixer.java │ │ ├── debug │ │ └── Debug.java │ │ ├── hooks │ │ ├── bedrock │ │ │ ├── BedrockHook.java │ │ │ ├── BedrockHookPlatform.java │ │ │ ├── floodgate │ │ │ │ └── FloodgateHookPlatform.java │ │ │ └── geyser │ │ │ │ └── GeyserHookPlatform.java │ │ ├── discordsrv │ │ │ └── DiscordSRVEvents.java │ │ ├── dynmap │ │ │ ├── DynmapCoreChatListener.java │ │ │ └── DynmapListener.java │ │ ├── eco │ │ │ └── EcoHook.java │ │ ├── essentials │ │ │ ├── EssentialsDiscord.java │ │ │ └── EssentialsNicknames.java │ │ ├── excellentenchants │ │ │ └── ExcellentEnchantsHook.java │ │ ├── luckperms │ │ │ └── LuckPermsEvents.java │ │ ├── triton │ │ │ └── TritonHook.java │ │ └── venturechat │ │ │ └── VentureChatInjection.java │ │ ├── listeners │ │ ├── ChatEvents.java │ │ ├── InventoryEvents.java │ │ ├── MapViewer.java │ │ ├── PaperChatEvents.java │ │ ├── PlayerEvents.java │ │ └── packet │ │ │ ├── ClientSettingsHandler.java │ │ │ ├── MessagePacketHandler.java │ │ │ ├── OutTabCompletePacketHandler.java │ │ │ ├── RedispatchedSignPacketHandler.java │ │ │ └── listeners │ │ │ ├── PLibClientSettingPacket.java │ │ │ ├── PLibOutMessagePacket.java │ │ │ ├── PLibOutTabCompletePacket.java │ │ │ └── PLibRedispatchSignedPacket.java │ │ ├── main │ │ ├── CMLMain.java │ │ ├── GUIMain.java │ │ └── Main.java │ │ ├── metrics │ │ ├── Charts.java │ │ └── Metrics.java │ │ ├── modules │ │ ├── CommandsDisplay.java │ │ ├── CustomPlaceholderDisplay.java │ │ ├── EnderchestDisplay.java │ │ ├── HoverableItemDisplay.java │ │ ├── InventoryDisplay.java │ │ ├── ItemDisplay.java │ │ ├── MentionDisplay.java │ │ ├── PlayernameDisplay.java │ │ ├── ProcessAccurateSender.java │ │ ├── ProcessCommands.java │ │ ├── ProcessExternalMessage.java │ │ └── SenderFinder.java │ │ ├── nms │ │ └── NMS.java │ │ ├── objectholders │ │ ├── AsyncChatSendingExecutor.java │ │ ├── BuiltInPlaceholder.java │ │ ├── ConcurrentCacheHashMap.java │ │ ├── CooldownResult.java │ │ ├── CustomPlaceholder.java │ │ ├── Either.java │ │ ├── ICInventoryHolder.java │ │ ├── ICMaterial.java │ │ ├── ICPlaceholder.java │ │ ├── ICPlayer.java │ │ ├── ICPlayerEquipment.java │ │ ├── ICPlayerFactory.java │ │ ├── LegacyIdKey.java │ │ ├── LimitedQueue.java │ │ ├── LogFilter.java │ │ ├── MentionPair.java │ │ ├── MentionTagConverter.java │ │ ├── ModernChatCompletionTask.java │ │ ├── NicknameManager.java │ │ ├── OfflineICPlayer.java │ │ ├── OffsetMatchResult.java │ │ ├── OutboundPacket.java │ │ ├── PermissionCache.java │ │ ├── PlaceholderCooldownManager.java │ │ ├── ProcessSenderResult.java │ │ ├── ReplaceTextBundle.java │ │ ├── SignedMessageModificationData.java │ │ ├── WebData.java │ │ └── WrappedString.java │ │ ├── placeholderapi │ │ └── Placeholders.java │ │ ├── platform │ │ ├── ProtocolPlatform.java │ │ └── protocollib │ │ │ ├── ProtocolLibAsyncChatSendingExecutor.java │ │ │ ├── ProtocolLibDummyPlayer.java │ │ │ └── ProtocolLibPlatform.java │ │ ├── proxy │ │ ├── bungee │ │ │ ├── CommandsBungee.java │ │ │ ├── InteractiveChatBungee.java │ │ │ ├── PluginMessageSendingBungee.java │ │ │ ├── ServerPingBungee.java │ │ │ └── metrics │ │ │ │ ├── Charts.java │ │ │ │ └── Metrics.java │ │ ├── objectholders │ │ │ ├── BackendInteractiveChatData.java │ │ │ ├── ChatPacketType.java │ │ │ ├── ForwardedMessageData.java │ │ │ ├── ProxyHandlePacketTypes.java │ │ │ ├── ProxyMessageForwardingHandler.java │ │ │ └── ProxyPlayerCooldownManager.java │ │ └── velocity │ │ │ ├── CommandsVelocity.java │ │ │ ├── ICChannelIdentifier.java │ │ │ ├── InteractiveChatVelocity.java │ │ │ ├── LogFilterVelocity.java │ │ │ ├── PluginMessageSendingVelocity.java │ │ │ ├── ServerPingVelocity.java │ │ │ ├── TextColor.java │ │ │ ├── VelocityPluginDescription.java │ │ │ └── metrics │ │ │ ├── Charts.java │ │ │ └── Metrics.java │ │ ├── registry │ │ └── Registry.java │ │ ├── updater │ │ ├── Updater.java │ │ └── Version.java │ │ └── utils │ │ ├── BookUtils.java │ │ ├── ChatColorUtils.java │ │ ├── ChatComponentType.java │ │ ├── ClassUtils.java │ │ ├── CollectionUtils.java │ │ ├── ColorUtils.java │ │ ├── CompassUtils.java │ │ ├── ComponentFont.java │ │ ├── ComponentModernizing.java │ │ ├── ComponentReplacing.java │ │ ├── ComponentStyling.java │ │ ├── CustomArrayUtils.java │ │ ├── CustomStringUtils.java │ │ ├── DataStreamIO.java │ │ ├── DataTypeIO.java │ │ ├── FileUtils.java │ │ ├── FilledMapUtils.java │ │ ├── HTTPRequestUtils.java │ │ ├── HashUtils.java │ │ ├── IgnoreUtils.java │ │ ├── InteractiveChatComponentSerializer.java │ │ ├── InventoryUtils.java │ │ ├── ItemNBTUtils.java │ │ ├── ItemStackUtils.java │ │ ├── JsonUtils.java │ │ ├── LanguageUtils.java │ │ ├── MCVersion.java │ │ ├── ModernChatSigningUtils.java │ │ ├── NBTParsingUtils.java │ │ ├── NativeAdventureConverter.java │ │ ├── PlaceholderParser.java │ │ ├── PlayerUtils.java │ │ ├── PotionUtils.java │ │ ├── RarityUtils.java │ │ ├── SkinUtils.java │ │ ├── SoundUtils.java │ │ ├── TimeUtils.java │ │ ├── UUIDUtils.java │ │ ├── WrappedChatComponentUtils.java │ │ ├── XMaterialUtils.java │ │ ├── ZipUtils.java │ │ └── bossbar │ │ ├── BossBarUpdater.java │ │ └── BossBarUpdaterImpl.java │ └── resources │ ├── bungee.yml │ ├── config.yml │ ├── config_proxy.yml │ ├── icon.png │ ├── plugin.yml │ ├── storage.yml │ └── velocity-plugin.json └── pom.xml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [LOOHP] 4 | custom: ['https://paypal.me/loohpjames/5USD'] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | 11 | # Compiled class file 12 | *.class 13 | 14 | # Log file 15 | *.log 16 | 17 | # BlueJ files 18 | *.ctxt 19 | 20 | # Package Files # 21 | *.war 22 | *.nar 23 | *.ear 24 | *.zip 25 | *.tar.gz 26 | *.rar 27 | 28 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 29 | hs_err_pid* 30 | 31 | *~ 32 | 33 | # temporary files which can be created if a process still has a handle open of a deleted file 34 | .fuse_hidden* 35 | 36 | # KDE directory preferences 37 | .directory 38 | 39 | # Linux trash folder which might appear on any partition or disk 40 | .Trash-* 41 | 42 | # .nfs files are created when an open file is removed but is still being accessed 43 | .nfs* 44 | 45 | # General 46 | .DS_Store 47 | .AppleDouble 48 | .LSOverride 49 | 50 | # Icon must end with two \r 51 | Icon 52 | 53 | # Thumbnails 54 | ._* 55 | 56 | # Files that might appear in the root of a volume 57 | .DocumentRevisions-V100 58 | .fseventsd 59 | .Spotlight-V100 60 | .TemporaryItems 61 | .Trashes 62 | .VolumeIcon.icns 63 | .com.apple.timemachine.donotpresent 64 | 65 | # Directories potentially created on remote AFP share 66 | .AppleDB 67 | .AppleDesktop 68 | Network Trash Folder 69 | Temporary Items 70 | .apdisk 71 | 72 | # Windows thumbnail cache files 73 | Thumbs.db 74 | Thumbs.db:encryptable 75 | ehthumbs.db 76 | ehthumbs_vista.db 77 | 78 | # Dump file 79 | *.stackdump 80 | 81 | # Folder config file 82 | [Dd]esktop.ini 83 | 84 | # Recycle Bin used on file shares 85 | $RECYCLE.BIN/ 86 | 87 | # Windows Installer files 88 | *.cab 89 | *.msi 90 | *.msix 91 | *.msm 92 | *.msp 93 | 94 | # Windows shortcuts 95 | *.lnk 96 | 97 | target/ 98 | 99 | pom.xml.tag 100 | pom.xml.releaseBackup 101 | pom.xml.versionsBackup 102 | pom.xml.next 103 | 104 | release.properties 105 | dependency-reduced-pom.xml 106 | buildNumber.properties 107 | .mvn/timing.properties 108 | .mvn/wrapper/maven-wrapper.jar 109 | .flattened-pom.xml 110 | 111 | # Common working directory 112 | run/ 113 | .run/ -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/CommandSuggestion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class CommandSuggestion { 24 | 25 | public static CommandSuggestion of(int position, T suggestion) { 26 | return new CommandSuggestion<>(position, suggestion); 27 | } 28 | 29 | private final int position; 30 | private final T suggestion; 31 | 32 | private CommandSuggestion(int position, T suggestion) { 33 | this.position = position; 34 | this.suggestion = suggestion; 35 | } 36 | 37 | public int getPosition() { 38 | return position; 39 | } 40 | 41 | public T getSuggestion() { 42 | return suggestion; 43 | } 44 | 45 | public E getSuggestion(Class suggestionClass) { 46 | return suggestionClass.cast(suggestion); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/CustomTabCompletionAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public enum CustomTabCompletionAction { 24 | 25 | ADD, REMOVE; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/IICPlayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.inventory.Inventory; 25 | 26 | import java.util.Map; 27 | import java.util.Set; 28 | 29 | public interface IICPlayer extends IOfflineICPlayer { 30 | 31 | boolean isLocal(); 32 | 33 | boolean isRemote(); 34 | 35 | boolean isValid(); 36 | 37 | Player getLocalPlayer(); 38 | 39 | String getRemoteServer(); 40 | 41 | void setRemoteServer(String server); 42 | 43 | String getServer(); 44 | 45 | String getDisplayName(); 46 | 47 | boolean isVanished(); 48 | 49 | void setRemoteVanished(boolean remoteVanished); 50 | 51 | void setRemoteRightHanded(boolean rightHanded); 52 | 53 | void setRemoteSelectedSlot(int selectedSlot); 54 | 55 | void setRemoteExperienceLevel(int experienceLevel); 56 | 57 | void setRemoteInventory(Inventory inventory); 58 | 59 | void setRemoteEnderChest(Inventory enderchest); 60 | 61 | Set getNicknames(); 62 | 63 | Set getRemoteNicknames(); 64 | 65 | void setRemoteNicknames(Set remoteNicknames); 66 | 67 | Map getRemotePlaceholdersMapping(); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/IOfflineICPlayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import org.bukkit.OfflinePlayer; 24 | import org.bukkit.inventory.EntityEquipment; 25 | import org.bukkit.inventory.Inventory; 26 | import org.bukkit.inventory.ItemStack; 27 | 28 | import java.util.Map; 29 | import java.util.UUID; 30 | 31 | public interface IOfflineICPlayer { 32 | 33 | UUID getUniqueId(); 34 | 35 | OfflinePlayer getLocalOfflinePlayer(); 36 | 37 | boolean isOnline(); 38 | 39 | String getName(); 40 | 41 | int getSelectedSlot(); 42 | 43 | boolean isRightHanded(); 44 | 45 | int getExperienceLevel(); 46 | 47 | EntityEquipment getEquipment(); 48 | 49 | Inventory getInventory(); 50 | 51 | ItemStack getMainHandItem(); 52 | 53 | ItemStack getOffHandItem(); 54 | 55 | Inventory getEnderChest(); 56 | 57 | IICPlayer getPlayer(); 58 | 59 | void updateOfflineData(); 60 | 61 | Object getProperty(String key); 62 | 63 | boolean hasProperty(String key); 64 | 65 | Map getProperties(); 66 | 67 | Object addProperties(String key, Object value); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/InternalOfflinePlayerInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import org.bukkit.inventory.Inventory; 24 | 25 | public class InternalOfflinePlayerInfo { 26 | 27 | private final int selectedSlot; 28 | private final boolean rightHanded; 29 | private final int xpLevel; 30 | private final Inventory inventory; 31 | private final Inventory enderchest; 32 | 33 | public InternalOfflinePlayerInfo(int selectedSlot, boolean rightHanded, int xpLevel, Inventory inventory, Inventory enderchest) { 34 | this.selectedSlot = selectedSlot; 35 | this.rightHanded = rightHanded; 36 | this.xpLevel = xpLevel; 37 | this.inventory = inventory; 38 | this.enderchest = enderchest; 39 | } 40 | 41 | public int getSelectedSlot() { 42 | return selectedSlot; 43 | } 44 | 45 | public boolean isRightHanded() { 46 | return rightHanded; 47 | } 48 | 49 | public int getXpLevel() { 50 | return xpLevel; 51 | } 52 | 53 | public Inventory getInventory() { 54 | return inventory; 55 | } 56 | 57 | public Inventory getEnderchest() { 58 | return enderchest; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/ValuePairs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.Objects; 24 | import java.util.function.BiConsumer; 25 | import java.util.function.BiFunction; 26 | 27 | public class ValuePairs { 28 | 29 | private final F first; 30 | private final S second; 31 | 32 | public ValuePairs(F first, S second) { 33 | this.first = first; 34 | this.second = second; 35 | } 36 | 37 | public F getFirst() { 38 | return first; 39 | } 40 | 41 | public S getSecond() { 42 | return second; 43 | } 44 | 45 | public T product(BiFunction function) { 46 | return function.apply(first, second); 47 | } 48 | 49 | public void consume(BiConsumer consumer) { 50 | consumer.accept(first, second); 51 | } 52 | 53 | @Override 54 | public boolean equals(Object o) { 55 | if (this == o) { 56 | return true; 57 | } 58 | if (o == null || getClass() != o.getClass()) { 59 | return false; 60 | } 61 | ValuePairs that = (ValuePairs) o; 62 | return Objects.equals(first, that.first) && Objects.equals(second, that.second); 63 | } 64 | 65 | @Override 66 | public int hashCode() { 67 | return Objects.hash(first, second); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/objectholders/ValueTrios.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class ValueTrios { 24 | 25 | private final F first; 26 | private final S second; 27 | private final T third; 28 | 29 | public ValueTrios(F first, S second, T third) { 30 | this.first = first; 31 | this.second = second; 32 | this.third = third; 33 | } 34 | 35 | public F getFirst() { 36 | return first; 37 | } 38 | 39 | public S getSecond() { 40 | return second; 41 | } 42 | 43 | public T getThird() { 44 | return third; 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | final int prime = 31; 50 | int result = 1; 51 | result = prime * result + ((first == null) ? 0 : first.hashCode()); 52 | result = prime * result + ((second == null) ? 0 : second.hashCode()); 53 | result = prime * result + ((third == null) ? 0 : third.hashCode()); 54 | return result; 55 | } 56 | 57 | @SuppressWarnings("rawtypes") 58 | @Override 59 | public boolean equals(Object obj) { 60 | if (this == obj) { 61 | return true; 62 | } 63 | if (!(obj instanceof ValueTrios)) { 64 | return false; 65 | } 66 | ValueTrios other = (ValueTrios) obj; 67 | if (first == null) { 68 | if (other.first != null) { 69 | return false; 70 | } 71 | } else if (!first.equals(other.first)) { 72 | return false; 73 | } 74 | if (second == null) { 75 | if (other.second != null) { 76 | return false; 77 | } 78 | } else if (!second.equals(other.second)) { 79 | return false; 80 | } 81 | if (third == null) { 82 | return other.third == null; 83 | } else { 84 | return third.equals(other.third); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/utils/ComponentCompacting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 com.loohp.interactivechat.utils; 21 | 22 | import net.kyori.adventure.text.Component; 23 | import net.kyori.adventure.text.TextComponent; 24 | import net.kyori.adventure.text.event.ClickEvent; 25 | import net.kyori.adventure.text.event.HoverEvent; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | import java.util.Objects; 30 | 31 | public class ComponentCompacting { 32 | 33 | public static Component optimize(Component component) { 34 | return optimizeEvents(component).compact(); 35 | } 36 | 37 | public static Component optimizeEvents(Component component) { 38 | component = ComponentFlattening.flatten(component); 39 | List children = component.children(); 40 | if (children.isEmpty()) { 41 | return component; 42 | } 43 | List optimized = new ArrayList<>(); 44 | HoverEvent hoverEvent = null; 45 | ClickEvent clickEvent = null; 46 | Component currentComponent = Component.empty().hoverEvent(hoverEvent).clickEvent(clickEvent); 47 | for (Component child : children) { 48 | if ((Objects.equals(child.hoverEvent(), hoverEvent) && Objects.equals(child.clickEvent(), clickEvent)) || (child instanceof TextComponent && ((TextComponent) child).content().isEmpty())) { 49 | currentComponent = currentComponent.append(child.hoverEvent(null).clickEvent(null)); 50 | } else { 51 | optimized.add(currentComponent); 52 | hoverEvent = child.hoverEvent(); 53 | clickEvent = child.clickEvent(); 54 | currentComponent = Component.empty().hoverEvent(hoverEvent).clickEvent(clickEvent).append(child.hoverEvent(null).clickEvent(null)); 55 | } 56 | } 57 | optimized.add(currentComponent); 58 | 59 | return component.children(optimized); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/utils/ComponentFlattening.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import net.kyori.adventure.text.Component; 24 | import net.kyori.adventure.text.format.Style.Merge; 25 | 26 | import java.util.ArrayList; 27 | import java.util.Collections; 28 | import java.util.List; 29 | 30 | public class ComponentFlattening { 31 | 32 | public static Component flatten(Component component) { 33 | return Component.empty().children(getChildren(component)); 34 | } 35 | 36 | private static List getChildren(Component component) { 37 | List list = new ArrayList<>(); 38 | list.add(component.children(Collections.emptyList())); 39 | for (Component child : component.children()) { 40 | child = child.style(child.style().merge(component.style(), Merge.Strategy.IF_ABSENT_ON_TARGET)); 41 | list.addAll(getChildren(child)); 42 | } 43 | return list; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/utils/NativeJsonConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.google.gson.Gson; 24 | import com.google.gson.JsonElement; 25 | 26 | import java.lang.reflect.InvocationTargetException; 27 | import java.lang.reflect.Method; 28 | 29 | public class NativeJsonConverter { 30 | 31 | private static final String NATIVE_PACKAGE = new String(new char[] {'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'g', 's', 'o', 'n'}); 32 | 33 | public static final Gson GSON = new Gson(); 34 | 35 | private static final Object nativeGSON; 36 | private static final Class nativeGsonElementClass; 37 | private static final Method nativeGSONToJsonMethod; 38 | private static final Method nativeGSONFromJsonMethod; 39 | 40 | static { 41 | try { 42 | Class nativeGsonClass = Class.forName(NATIVE_PACKAGE + ".Gson"); 43 | nativeGsonElementClass = Class.forName(NATIVE_PACKAGE + ".JsonElement"); 44 | nativeGSON = nativeGsonClass.getConstructor().newInstance(); 45 | nativeGSONToJsonMethod = nativeGsonClass.getMethod("toJson", nativeGsonElementClass); 46 | nativeGSONFromJsonMethod = nativeGsonClass.getMethod("fromJson", String.class, Class.class); 47 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) { 48 | throw new RuntimeException(e); 49 | } 50 | } 51 | 52 | public static JsonElement fromNative(Object nativeJsonElement) { 53 | try { 54 | String json = (String) nativeGSONToJsonMethod.invoke(nativeGSON, nativeJsonElement); 55 | return GSON.fromJson(json, JsonElement.class); 56 | } catch (IllegalAccessException | InvocationTargetException e) { 57 | throw new RuntimeException(e); 58 | } 59 | } 60 | 61 | public static Object toNative(JsonElement jsonElement) { 62 | try { 63 | String json = GSON.toJson(jsonElement); 64 | return nativeGSONFromJsonMethod.invoke(nativeGSON, json, nativeGsonElementClass); 65 | } catch (IllegalAccessException | InvocationTargetException e) { 66 | throw new RuntimeException(e); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/utils/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.lang.reflect.Field; 24 | import java.lang.reflect.Method; 25 | 26 | public class ReflectionUtils { 27 | 28 | public static Field findDeclaredField(Class clazz, Class fieldType, String... names) throws NoSuchFieldException { 29 | NoSuchFieldException exception = null; 30 | for (String name : names) { 31 | try { 32 | Field field = clazz.getDeclaredField(name); 33 | if (field.getType().equals(fieldType)) { 34 | return field; 35 | } 36 | } catch (NoSuchFieldException e) { 37 | exception = e; 38 | } 39 | } 40 | if (exception == null) { 41 | throw new NoSuchFieldException(); 42 | } else { 43 | throw exception; 44 | } 45 | } 46 | 47 | public static Method findDeclaredMethod(Class clazz, Class[] parameters, String... names) throws NoSuchMethodException { 48 | NoSuchMethodException exception = null; 49 | for (String name : names) { 50 | try { 51 | return clazz.getDeclaredMethod(name, parameters); 52 | } catch (NoSuchMethodException e) { 53 | exception = e; 54 | } 55 | } 56 | if (exception == null) { 57 | throw new NoSuchMethodException(); 58 | } else { 59 | throw exception; 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /abstraction/src/main/java/com/loohp/interactivechat/utils/UnsafeAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import sun.misc.Unsafe; 24 | 25 | import java.lang.reflect.Field; 26 | 27 | public class UnsafeAccessor { 28 | 29 | private static final Field unsafeField; 30 | private static Unsafe unsafe; 31 | 32 | static { 33 | try { 34 | unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); 35 | } catch (NoSuchFieldException e) { 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | 40 | public static Unsafe getUnsafe() { 41 | if (unsafe != null) { 42 | return unsafe; 43 | } 44 | try { 45 | unsafeField.setAccessible(true); 46 | return unsafe = (Unsafe) unsafeField.get(null); 47 | } catch (IllegalAccessException e) { 48 | throw new RuntimeException(e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /common/lib/CMIAPI-9.7.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/CMIAPI-9.7.4.1.jar -------------------------------------------------------------------------------- /common/lib/Dynmap-3.7-beta-7-spigot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/Dynmap-3.7-beta-7-spigot.jar -------------------------------------------------------------------------------- /common/lib/ExcellentEnchants-5.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/ExcellentEnchants-5.1.0.jar -------------------------------------------------------------------------------- /common/lib/MPDBStriped-v3.36.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/MPDBStriped-v3.36.3.jar -------------------------------------------------------------------------------- /common/lib/VentureChat-3.7.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/VentureChat-3.7.1.jar -------------------------------------------------------------------------------- /common/lib/bungeecord-proxy-1.21-R0.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/bungeecord-proxy-1.21-R0.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /common/lib/eco-6.75.2-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/eco-6.75.2-all.jar -------------------------------------------------------------------------------- /common/lib/nightcore-2.7.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/nightcore-2.7.9.jar -------------------------------------------------------------------------------- /common/lib/velocity-3.4.0-SNAPSHOT-469.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/lib/velocity-3.4.0-SNAPSHOT-469.jar -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/ICPlayerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import com.loohp.platformscheduler.Scheduler; 25 | import org.bukkit.event.Event; 26 | import org.bukkit.event.HandlerList; 27 | 28 | /** 29 | * This is the base class of all events related to icplayers. 30 | * 31 | * @author LOOHP 32 | */ 33 | public class ICPlayerEvent extends Event { 34 | 35 | private static final HandlerList HANDLERS = new HandlerList(); 36 | 37 | public static HandlerList getHandlerList() { 38 | return HANDLERS; 39 | } 40 | 41 | protected final ICPlayer player; 42 | protected final boolean isRemote; 43 | 44 | public ICPlayerEvent(ICPlayer player, boolean isRemote) { 45 | super(!Scheduler.isPrimaryThread()); 46 | this.player = player; 47 | this.isRemote = isRemote; 48 | } 49 | 50 | public ICPlayer getPlayer() { 51 | return player; 52 | } 53 | 54 | public boolean isRemote() { 55 | return isRemote; 56 | } 57 | 58 | public HandlerList getHandlers() { 59 | return HANDLERS; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/ICPlayerJoinEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import org.bukkit.event.HandlerList; 25 | 26 | /** 27 | * Called when a icplayer joins 28 | * 29 | * @author LOOHP 30 | */ 31 | public class ICPlayerJoinEvent extends ICPlayerEvent { 32 | 33 | private static final HandlerList HANDLERS = new HandlerList(); 34 | 35 | public static HandlerList getHandlerList() { 36 | return HANDLERS; 37 | } 38 | 39 | public ICPlayerJoinEvent(ICPlayer player, boolean isRemote) { 40 | super(player, isRemote); 41 | } 42 | 43 | public HandlerList getHandlers() { 44 | return HANDLERS; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/ICPlayerQuitEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import org.bukkit.event.HandlerList; 25 | 26 | /** 27 | * Called when a icplayer is quits 28 | * 29 | * @author LOOHP 30 | */ 31 | public class ICPlayerQuitEvent extends ICPlayerEvent { 32 | 33 | private static final HandlerList HANDLERS = new HandlerList(); 34 | 35 | public static HandlerList getHandlerList() { 36 | return HANDLERS; 37 | } 38 | 39 | public ICPlayerQuitEvent(ICPlayer player, boolean isRemote) { 40 | super(player, isRemote); 41 | } 42 | 43 | public HandlerList getHandlers() { 44 | return HANDLERS; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/InteractiveChatConfigReloadEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.platformscheduler.Scheduler; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | /** 28 | * Fired when /ic reload is used 29 | * 30 | * @author LOOHP 31 | */ 32 | public class InteractiveChatConfigReloadEvent extends Event { 33 | 34 | private static final HandlerList HANDLERS = new HandlerList(); 35 | 36 | public static HandlerList getHandlerList() { 37 | return HANDLERS; 38 | } 39 | 40 | public InteractiveChatConfigReloadEvent() { 41 | super(!Scheduler.isPrimaryThread()); 42 | } 43 | 44 | public HandlerList getHandlers() { 45 | return HANDLERS; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/InventoryPlaceholderEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import net.kyori.adventure.text.Component; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.event.HandlerList; 27 | import org.bukkit.inventory.Inventory; 28 | 29 | /** 30 | * This event is called whenever the inventory (and enderchest) placeholder is 31 | * used. Only the inventory can be changed in this event, nothing else. Inventory 32 | * cannot be null. Changing the Component or Canceling the event will cause 33 | * UnsupportedOperationException to be thrown. 34 | * 35 | * @author LOOHP 36 | */ 37 | public class InventoryPlaceholderEvent extends PlaceholderEvent { 38 | 39 | private static final HandlerList HANDLERS = new HandlerList(); 40 | 41 | public static HandlerList getHandlerList() { 42 | return HANDLERS; 43 | } 44 | 45 | private final InventoryPlaceholderType type; 46 | private Inventory inventory; 47 | 48 | public InventoryPlaceholderEvent(ICPlayer sender, Player receiver, Component component, long timeSent, Inventory inventory, InventoryPlaceholderType type) { 49 | super(sender, receiver, component, timeSent); 50 | this.inventory = inventory; 51 | this.type = type; 52 | } 53 | 54 | public InventoryPlaceholderType getType() { 55 | return type; 56 | } 57 | 58 | public Inventory getInventory() { 59 | return inventory; 60 | } 61 | 62 | public void setInventory(Inventory inventory) { 63 | if (inventory == null) { 64 | throw new IllegalArgumentException("Inventory cannot be null"); 65 | } 66 | this.inventory = inventory; 67 | } 68 | 69 | @Override 70 | public Component getComponent() { 71 | return component; 72 | } 73 | 74 | @Override 75 | @Deprecated 76 | public void setComponent(Component component) { 77 | throw new UnsupportedOperationException("Changing the Component in this event is not allowed"); 78 | } 79 | 80 | @Override 81 | @Deprecated 82 | public void setCancelled(boolean cancel) { 83 | throw new UnsupportedOperationException("Cancelling this event is not allowed"); 84 | } 85 | 86 | public HandlerList getHandlers() { 87 | return HANDLERS; 88 | } 89 | 90 | public enum InventoryPlaceholderType { 91 | INVENTORY, INVENTORY1_UPPER, INVENTORY1_LOWER, ENDERCHEST 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/ItemPlaceholderEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import net.kyori.adventure.text.Component; 25 | import org.bukkit.Material; 26 | import org.bukkit.entity.Player; 27 | import org.bukkit.event.HandlerList; 28 | import org.bukkit.inventory.ItemStack; 29 | 30 | /** 31 | * This event is called whenever the item placeholder is used. Only the itemStack 32 | * can be changed in this event, nothing else. Changing the Component or 33 | * Canceling the event will cause UnsupportedOperationException to be thrown. 34 | * 35 | * @author LOOHP 36 | */ 37 | public class ItemPlaceholderEvent extends PlaceholderEvent { 38 | 39 | private static final HandlerList HANDLERS = new HandlerList(); 40 | 41 | public static HandlerList getHandlerList() { 42 | return HANDLERS; 43 | } 44 | 45 | private ItemStack itemStack; 46 | 47 | public ItemPlaceholderEvent(ICPlayer sender, Player receiver, Component component, long timeSent, ItemStack itemStack) { 48 | super(sender, receiver, component, timeSent); 49 | this.itemStack = itemStack; 50 | } 51 | 52 | public ItemStack getItemStack() { 53 | return itemStack; 54 | } 55 | 56 | public void setItemStack(ItemStack itemStack) { 57 | if (itemStack == null) { 58 | itemStack = new ItemStack(Material.AIR); 59 | } 60 | this.itemStack = itemStack; 61 | } 62 | 63 | @Override 64 | public Component getComponent() { 65 | return component; 66 | } 67 | 68 | @Override 69 | @Deprecated 70 | public void setComponent(Component component) { 71 | throw new UnsupportedOperationException("Changing the Component in this event is not allowed"); 72 | } 73 | 74 | @Override 75 | @Deprecated 76 | public void setCancelled(boolean cancel) { 77 | throw new UnsupportedOperationException("Cancelling this event is not allowed"); 78 | } 79 | 80 | public HandlerList getHandlers() { 81 | return HANDLERS; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/OfflineICPlayerCreationEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.OfflineICPlayer; 24 | import org.bukkit.event.HandlerList; 25 | 26 | /** 27 | * This is fired when an offlineICPlayer is created 28 | * 29 | * @author LOOHP 30 | */ 31 | public class OfflineICPlayerCreationEvent extends OfflineICPlayerEvent { 32 | 33 | private static final HandlerList HANDLERS = new HandlerList(); 34 | 35 | public static HandlerList getHandlerList() { 36 | return HANDLERS; 37 | } 38 | 39 | public OfflineICPlayerCreationEvent(OfflineICPlayer player) { 40 | super(player); 41 | } 42 | 43 | public HandlerList getHandlers() { 44 | return HANDLERS; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/OfflineICPlayerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.OfflineICPlayer; 24 | import com.loohp.platformscheduler.Scheduler; 25 | import org.bukkit.event.Event; 26 | import org.bukkit.event.HandlerList; 27 | 28 | /** 29 | * This is the base class of all events related to offlineicplayers. 30 | * 31 | * @author LOOHP 32 | */ 33 | public class OfflineICPlayerEvent extends Event { 34 | 35 | private static final HandlerList HANDLERS = new HandlerList(); 36 | 37 | public static HandlerList getHandlerList() { 38 | return HANDLERS; 39 | } 40 | 41 | protected final OfflineICPlayer player; 42 | 43 | public OfflineICPlayerEvent(OfflineICPlayer player) { 44 | super(!Scheduler.isPrimaryThread()); 45 | this.player = player; 46 | } 47 | 48 | public OfflineICPlayer getPlayer() { 49 | return player; 50 | } 51 | 52 | public HandlerList getHandlers() { 53 | return HANDLERS; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/OfflineICPlayerUpdateEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.OfflineICPlayer; 24 | import org.bukkit.event.HandlerList; 25 | 26 | /** 27 | * This is fired when an offlineICPlayer is updated 28 | * 29 | * @author LOOHP 30 | */ 31 | public class OfflineICPlayerUpdateEvent extends OfflineICPlayerEvent { 32 | 33 | private static final HandlerList HANDLERS = new HandlerList(); 34 | 35 | public static HandlerList getHandlerList() { 36 | return HANDLERS; 37 | } 38 | 39 | public OfflineICPlayerUpdateEvent(OfflineICPlayer player) { 40 | super(player); 41 | } 42 | 43 | public HandlerList getHandlers() { 44 | return HANDLERS; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/PlaceholderEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlayer; 24 | import com.loohp.platformscheduler.Scheduler; 25 | import net.kyori.adventure.text.Component; 26 | import org.bukkit.entity.Player; 27 | import org.bukkit.event.Cancellable; 28 | import org.bukkit.event.Event; 29 | import org.bukkit.event.HandlerList; 30 | 31 | /** 32 | * This is the base class of all events related to parsing placeholders. 33 | * 34 | * @author LOOHP 35 | */ 36 | public class PlaceholderEvent extends Event implements Cancellable { 37 | 38 | private static final HandlerList HANDLERS = new HandlerList(); 39 | 40 | public static HandlerList getHandlerList() { 41 | return HANDLERS; 42 | } 43 | 44 | protected final ICPlayer sender; 45 | protected final Player receiver; 46 | protected final long timeSent; 47 | protected Component component; 48 | protected boolean isCancelled; 49 | 50 | public PlaceholderEvent(ICPlayer sender, Player receiver, Component component, long timeSent) { 51 | super(!Scheduler.isPrimaryThread()); 52 | this.sender = sender; 53 | this.receiver = receiver; 54 | this.component = component; 55 | this.timeSent = timeSent; 56 | this.isCancelled = false; 57 | } 58 | 59 | public PlaceholderEvent(Player receiver, Component component, long timeSent) { 60 | this(null, receiver, component, timeSent); 61 | } 62 | 63 | public boolean hasSender() { 64 | return sender != null; 65 | } 66 | 67 | public ICPlayer getSender() { 68 | return sender; 69 | } 70 | 71 | public Player getReceiver() { 72 | return receiver; 73 | } 74 | 75 | public Component getComponent() { 76 | return component; 77 | } 78 | 79 | public void setComponent(Component component) { 80 | this.component = component; 81 | } 82 | 83 | public long getTimeSent() { 84 | return timeSent; 85 | } 86 | 87 | @Override 88 | public boolean isCancelled() { 89 | return isCancelled; 90 | } 91 | 92 | @Override 93 | public void setCancelled(boolean cancel) { 94 | this.isCancelled = cancel; 95 | } 96 | 97 | public HandlerList getHandlers() { 98 | return HANDLERS; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/PostPacketComponentProcessEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import net.kyori.adventure.text.Component; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.event.Event; 26 | import org.bukkit.event.HandlerList; 27 | 28 | import java.util.UUID; 29 | 30 | /** 31 | * This Event is called after the plugin had modified the 32 | * components of a chat packet. Sender will be null if the message is not send by a player or 33 | * the plugin is unable to find the sender of the message. 34 | * 35 | * @author LOOHP 36 | */ 37 | public class PostPacketComponentProcessEvent extends Event { 38 | 39 | private static final HandlerList HANDLERS = new HandlerList(); 40 | 41 | public static HandlerList getHandlerList() { 42 | return HANDLERS; 43 | } 44 | 45 | private final Player receiver; 46 | private final UUID sender; 47 | private Component component; 48 | 49 | public PostPacketComponentProcessEvent(boolean async, Player receiver, Component component, UUID sender) { 50 | super(async); 51 | this.receiver = receiver; 52 | this.component = component; 53 | this.sender = sender; 54 | } 55 | 56 | public Player getReceiver() { 57 | return receiver; 58 | } 59 | 60 | public UUID getSender() { 61 | return sender; 62 | } 63 | 64 | public Component getComponent() { 65 | return component; 66 | } 67 | 68 | public void setComponent(Component component) { 69 | this.component = component; 70 | } 71 | 72 | public HandlerList getHandlers() { 73 | return HANDLERS; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/PreExternalResponseSendEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import net.kyori.adventure.text.Component; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.event.Event; 26 | import org.bukkit.event.HandlerList; 27 | 28 | import java.util.UUID; 29 | 30 | /** 31 | * This Event is called after the plugin has modified the components an external request and is ready to send. 32 | * 33 | * @author LOOHP 34 | */ 35 | public class PreExternalResponseSendEvent extends Event { 36 | 37 | private static final HandlerList HANDLERS = new HandlerList(); 38 | 39 | public static HandlerList getHandlerList() { 40 | return HANDLERS; 41 | } 42 | 43 | private final Player reciever; 44 | private Component component; 45 | private final UUID sender; 46 | private Component original; 47 | private boolean sendOriginalIfCancelled; 48 | 49 | public PreExternalResponseSendEvent(boolean async, Player reciever, Component component, UUID sender, Component original, boolean sendOriginalIfCancelled) { 50 | super(async); 51 | this.reciever = reciever; 52 | this.component = component; 53 | this.sender = sender; 54 | this.original = original; 55 | this.sendOriginalIfCancelled = sendOriginalIfCancelled; 56 | } 57 | 58 | public Player getReciever() { 59 | return reciever; 60 | } 61 | 62 | public Component getComponent() { 63 | return component; 64 | } 65 | 66 | public void setComponent(Component component) { 67 | this.component = component; 68 | } 69 | 70 | public UUID getSender() { 71 | return sender; 72 | } 73 | 74 | public Component getOriginal() { 75 | return original; 76 | } 77 | 78 | public void setOriginal(Component original) { 79 | this.original = original; 80 | } 81 | 82 | public boolean isSendOriginalIfCancelled() { 83 | return sendOriginalIfCancelled; 84 | } 85 | 86 | public void setSendOriginalIfCancelled(boolean sendOriginalIfCancelled) { 87 | this.sendOriginalIfCancelled = sendOriginalIfCancelled; 88 | } 89 | 90 | @Override 91 | public HandlerList getHandlers() { 92 | return HANDLERS; 93 | } 94 | 95 | } 96 | 97 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/PrePacketComponentProcessEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import net.kyori.adventure.text.Component; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.event.Event; 26 | import org.bukkit.event.HandlerList; 27 | 28 | import java.util.UUID; 29 | 30 | /** 31 | * This Event is called after the plugin had determinded the chat component in 32 | * the packet need modifying and before the plugin actually modifies the 33 | * components. Sender will be null if the message is not send by a player or 34 | * the plugin is unable to find the sender of the message. 35 | * 36 | * @author LOOHP 37 | */ 38 | public class PrePacketComponentProcessEvent extends Event { 39 | 40 | private static final HandlerList HANDLERS = new HandlerList(); 41 | 42 | public static HandlerList getHandlerList() { 43 | return HANDLERS; 44 | } 45 | 46 | private final Player reciever; 47 | private Component component; 48 | private UUID sender; 49 | 50 | public PrePacketComponentProcessEvent(boolean async, Player reciever, Component component, UUID sender) { 51 | super(async); 52 | this.reciever = reciever; 53 | this.component = component; 54 | this.sender = sender; 55 | } 56 | 57 | public Player getReceiver() { 58 | return reciever; 59 | } 60 | 61 | public UUID getSender() { 62 | return sender; 63 | } 64 | 65 | public void setSender(UUID sender) { 66 | this.sender = sender; 67 | } 68 | 69 | public Component getComponent() { 70 | return component; 71 | } 72 | 73 | public void setComponent(Component component) { 74 | this.component = component; 75 | } 76 | 77 | public HandlerList getHandlers() { 78 | return HANDLERS; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/api/events/ProxyCustomDataRecievedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.api.events; 22 | 23 | import com.loohp.platformscheduler.Scheduler; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | import java.util.Arrays; 28 | 29 | /** 30 | * This is fired when a custom data packet is recieved from the proxy 31 | * 32 | * @author LOOHP 33 | */ 34 | public class ProxyCustomDataRecievedEvent extends Event { 35 | 36 | private static final HandlerList HANDLERS = new HandlerList(); 37 | 38 | public static HandlerList getHandlerList() { 39 | return HANDLERS; 40 | } 41 | 42 | private final String channel; 43 | private final byte[] data; 44 | 45 | public ProxyCustomDataRecievedEvent(String channel, byte[] data) { 46 | super(!Scheduler.isPrimaryThread()); 47 | this.channel = channel; 48 | this.data = data; 49 | } 50 | 51 | public String getChannel() { 52 | return channel; 53 | } 54 | 55 | public byte[] getData() { 56 | return Arrays.copyOf(data, data.length); 57 | } 58 | 59 | public HandlerList getHandlers() { 60 | return HANDLERS; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.bungeemessaging; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.PacketAdapter; 25 | import com.comphenix.protocol.events.PacketContainer; 26 | import com.comphenix.protocol.events.PacketEvent; 27 | import com.comphenix.protocol.wrappers.WrappedServerPing; 28 | import com.loohp.interactivechat.InteractiveChat; 29 | import com.loohp.interactivechat.platform.protocollib.ProtocolLibPlatform; 30 | import com.loohp.interactivechat.registry.Registry; 31 | import com.loohp.platformscheduler.Scheduler; 32 | 33 | import static com.loohp.interactivechat.bungeemessaging.ServerPingListenerUtils.REQUESTS; 34 | import static com.loohp.interactivechat.bungeemessaging.ServerPingListenerUtils.json; 35 | 36 | public class ServerPingListener { 37 | 38 | public static void listen() { 39 | ProtocolLibPlatform.protocolManager.addPacketListener(new PacketAdapter(PacketAdapter.params().optionAsync().plugin(InteractiveChat.plugin).types(PacketType.Handshake.Client.SET_PROTOCOL)) { 40 | @Override 41 | public void onPacketReceiving(PacketEvent event) { 42 | PacketContainer packet = event.getPacket(); 43 | String str = packet.getStrings().read(0); 44 | if (str != null && str.equals(Registry.PLUGIN_MESSAGING_PROTOCOL_IDENTIFIER) && event.isPlayerTemporary()) { 45 | REQUESTS.put(event.getPlayer(), System.currentTimeMillis() + 5000); 46 | } 47 | } 48 | }); 49 | ProtocolLibPlatform.protocolManager.addPacketListener(new PacketAdapter(PacketAdapter.params().optionAsync().plugin(InteractiveChat.plugin).types(PacketType.Status.Server.SERVER_INFO)) { 50 | @Override 51 | public void onPacketSending(PacketEvent event) { 52 | PacketContainer packet = event.getPacket(); 53 | WrappedServerPing response = packet.getServerPings().read(0); 54 | if (event.isPlayerTemporary() && REQUESTS.remove(event.getPlayer()) != null && response != null) { 55 | response.setMotD(json); 56 | packet.getServerPings().write(0, response); 57 | } 58 | } 59 | }); 60 | 61 | Scheduler.runTaskTimerAsynchronously(InteractiveChat.plugin, () -> { 62 | REQUESTS.entrySet().removeIf(entry -> System.currentTimeMillis() > entry.getValue()); 63 | }, 0, 20); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/bungeemessaging/ServerPingListenerUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.bungeemessaging; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.registry.Registry; 25 | import org.bukkit.entity.Player; 26 | import org.json.simple.JSONObject; 27 | 28 | import java.util.Map; 29 | import java.util.concurrent.ConcurrentHashMap; 30 | 31 | public class ServerPingListenerUtils { 32 | 33 | public static final Map REQUESTS = new ConcurrentHashMap<>(); 34 | public static String json; 35 | 36 | static { 37 | JSONObject obj = new JSONObject(); 38 | obj.put("present", true); 39 | obj.put("version", InteractiveChat.plugin.getDescription().getVersion()); 40 | obj.put("minecraftVersion", InteractiveChat.version.getNumber()); 41 | obj.put("exactMinecraftVersion", InteractiveChat.exactMinecraftVersion); 42 | obj.put("protocol", Registry.PLUGIN_MESSAGING_PROTOCOL_VERSION); 43 | json = obj.toJSONString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/debug/Debug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.debug; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import org.bukkit.ChatColor; 25 | import org.bukkit.event.EventHandler; 26 | import org.bukkit.event.Listener; 27 | import org.bukkit.event.player.PlayerJoinEvent; 28 | 29 | public class Debug implements Listener { 30 | 31 | @EventHandler 32 | public void onJoinPluginActive(PlayerJoinEvent event) { 33 | if (event.getPlayer().getName().equals("LOOHP") || event.getPlayer().getName().equals("AppLEshakE")) { 34 | event.getPlayer().sendMessage(ChatColor.GREEN + "InteractiveChat " + InteractiveChat.plugin.getDescription().getVersion() + " is running!"); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/bedrock/BedrockHookPlatform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.bedrock; 22 | 23 | import org.geysermc.cumulus.form.util.FormBuilder; 24 | 25 | import java.util.UUID; 26 | 27 | public interface BedrockHookPlatform { 28 | 29 | boolean isBedrockPlayer(UUID uuid); 30 | 31 | boolean isBedrockPlayerFromProxy(UUID uuid); 32 | 33 | boolean sendForm(UUID uuid, FormBuilder formBuilder); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/bedrock/floodgate/FloodgateHookPlatform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.bedrock.floodgate; 22 | 23 | import com.loohp.interactivechat.hooks.bedrock.BedrockHookPlatform; 24 | import org.geysermc.cumulus.form.util.FormBuilder; 25 | import org.geysermc.floodgate.api.FloodgateApi; 26 | import org.geysermc.floodgate.api.player.FloodgatePlayer; 27 | 28 | import java.util.UUID; 29 | 30 | public class FloodgateHookPlatform implements BedrockHookPlatform { 31 | 32 | @Override 33 | public boolean isBedrockPlayer(UUID uuid) { 34 | return FloodgateApi.getInstance().isFloodgatePlayer(uuid); 35 | } 36 | 37 | @Override 38 | public boolean isBedrockPlayerFromProxy(UUID uuid) { 39 | FloodgatePlayer player = FloodgateApi.getInstance().getPlayer(uuid); 40 | return player != null && player.isFromProxy(); 41 | } 42 | 43 | @Override 44 | public boolean sendForm(UUID uuid, FormBuilder formBuilder) { 45 | return FloodgateApi.getInstance().sendForm(uuid, formBuilder); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/bedrock/geyser/GeyserHookPlatform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.bedrock.geyser; 22 | 23 | import com.loohp.interactivechat.hooks.bedrock.BedrockHookPlatform; 24 | import org.geysermc.cumulus.form.util.FormBuilder; 25 | import org.geysermc.geyser.api.GeyserApi; 26 | 27 | import java.util.UUID; 28 | 29 | public class GeyserHookPlatform implements BedrockHookPlatform { 30 | 31 | @Override 32 | public boolean isBedrockPlayer(UUID uuid) { 33 | return GeyserApi.api().isBedrockPlayer(uuid); 34 | } 35 | 36 | @Override 37 | public boolean isBedrockPlayerFromProxy(UUID uuid) { 38 | return false; 39 | } 40 | 41 | @Override 42 | public boolean sendForm(UUID uuid, FormBuilder formBuilder) { 43 | return GeyserApi.api().sendForm(uuid, formBuilder); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapCoreChatListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.dynmap; 22 | 23 | import com.loohp.interactivechat.modules.ProcessExternalMessage; 24 | import com.loohp.interactivechat.registry.Registry; 25 | import com.loohp.interactivechat.utils.InteractiveChatComponentSerializer; 26 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 27 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.entity.Player; 30 | import org.dynmap.Client; 31 | import org.dynmap.DynmapCore; 32 | import org.dynmap.common.DynmapListenerManager.ChatEventListener; 33 | import org.dynmap.common.DynmapPlayer; 34 | 35 | public class DynmapCoreChatListener implements ChatEventListener { 36 | 37 | private final DynmapCore core; 38 | 39 | public DynmapCoreChatListener(DynmapCore core) { 40 | this.core = core; 41 | } 42 | 43 | @Override 44 | public void chatEvent(DynmapPlayer p, String msg) { 45 | if (core.disable_chat_to_web) { 46 | return; 47 | } 48 | if (core.mapManager != null) { 49 | Player bukkitplayer = Bukkit.getPlayer(p.getUUID()); 50 | if (bukkitplayer == null) { 51 | msg = msg.replaceAll(Registry.ID_PATTERN.pattern(), ""); 52 | core.mapManager.pushUpdate(new Client.ChatMessage("player", "", p.getDisplayName(), msg, p.getName())); 53 | } else { 54 | try { 55 | String component = InteractiveChatComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(msg)); 56 | String processed = PlainTextComponentSerializer.plainText().serialize(InteractiveChatComponentSerializer.gson().deserialize(ProcessExternalMessage.processAndRespond(bukkitplayer, component, false))); 57 | core.mapManager.pushUpdate(new Client.ChatMessage("player", "", p.getDisplayName(), processed, p.getName())); 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/dynmap/DynmapListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.dynmap; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.platformscheduler.Scheduler; 25 | import org.bukkit.Bukkit; 26 | import org.bukkit.ChatColor; 27 | import org.bukkit.event.EventHandler; 28 | import org.bukkit.event.Listener; 29 | import org.bukkit.event.server.PluginEnableEvent; 30 | import org.dynmap.DynmapCore; 31 | import org.dynmap.bukkit.DynmapPlugin; 32 | import org.dynmap.common.DynmapListenerManager; 33 | import org.dynmap.common.DynmapListenerManager.EventListener; 34 | import org.dynmap.common.DynmapListenerManager.EventType; 35 | 36 | import java.lang.reflect.Field; 37 | import java.util.ArrayList; 38 | import java.util.Map; 39 | 40 | public class DynmapListener implements Listener { 41 | 42 | private static boolean init = false; 43 | 44 | @SuppressWarnings("unchecked") 45 | public static void _init_() { 46 | Bukkit.getPluginManager().registerEvents(new DynmapListener(), InteractiveChat.plugin); 47 | try { 48 | DynmapPlugin dynmapPlugin = DynmapPlugin.plugin; 49 | Field coreField = dynmapPlugin.getClass().getDeclaredField("core"); 50 | coreField.setAccessible(true); 51 | DynmapCore dynmapCore = (DynmapCore) coreField.get(dynmapPlugin); 52 | coreField.setAccessible(false); 53 | DynmapListenerManager dynmapEvents = dynmapCore.listenerManager; 54 | Field listenerField = dynmapEvents.getClass().getDeclaredField("listeners"); 55 | listenerField.setAccessible(true); 56 | Map> listeners = (Map>) listenerField.get(dynmapEvents); 57 | listenerField.setAccessible(false); 58 | listeners.remove(EventType.PLAYER_CHAT); 59 | dynmapEvents.addListener(EventType.PLAYER_CHAT, new DynmapCoreChatListener(dynmapCore)); 60 | init = true; 61 | } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | @EventHandler 67 | public void onPluginEnable(PluginEnableEvent event) { 68 | if (init) { 69 | if (event.getPlugin().getName().equalsIgnoreCase("dynmap")) { 70 | Scheduler.runTaskLater(InteractiveChat.plugin, () -> { 71 | _init_(); 72 | Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into Dynmap!"); 73 | }, 100); 74 | } 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/essentials/EssentialsDiscord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.essentials; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.registry.Registry; 25 | import com.loohp.interactivechat.utils.ChatColorUtils; 26 | import com.loohp.interactivechat.utils.ComponentFont; 27 | import com.loohp.interactivechat.utils.ComponentReplacing; 28 | import net.essentialsx.api.v2.events.discord.DiscordChatMessageEvent; 29 | import net.kyori.adventure.text.Component; 30 | import net.kyori.adventure.text.TextReplacementConfig; 31 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 32 | import org.bukkit.event.EventHandler; 33 | import org.bukkit.event.EventPriority; 34 | import org.bukkit.event.Listener; 35 | 36 | public class EssentialsDiscord implements Listener { 37 | 38 | @EventHandler(priority = EventPriority.LOWEST) 39 | public void onDiscordChatMessage(DiscordChatMessageEvent event) { 40 | Component icComponent = LegacyComponentSerializer.legacySection().deserialize(event.getMessage()); 41 | icComponent = ComponentReplacing.replace(icComponent, Registry.ID_PATTERN.pattern(), false, (result, matchedComponents) -> { 42 | String placeholder = result.group(4); 43 | String replacement = placeholder == null ? "" : Registry.ID_UNESCAPE_PATTERN.matcher(placeholder).replaceAll(">"); 44 | return LegacyComponentSerializer.legacySection().deserialize(replacement); 45 | }); 46 | icComponent = ComponentReplacing.replace(icComponent, Registry.MENTION_TAG_CONVERTER.getReversePattern().pattern(), true, ((result, components) -> { 47 | return LegacyComponentSerializer.legacySection().deserialize(result.group(2)); 48 | })); 49 | icComponent = icComponent.replaceText(TextReplacementConfig.builder().match(ChatColorUtils.COLOR_TAG_PATTERN).replacement((result, builder) -> { 50 | String escape = result.group(1); 51 | String replacement = escape == null ? "" : escape; 52 | return builder.content(replacement); 53 | }).build()); 54 | if (InteractiveChat.fontTags) { 55 | icComponent = icComponent.replaceText(TextReplacementConfig.builder().match(ComponentFont.FONT_TAG_PATTERN).replacement((result, builder) -> { 56 | String escape = result.group(2); 57 | String replacement = escape == null ? "" : escape; 58 | return builder.content(replacement); 59 | }).build()); 60 | } 61 | event.setMessage(LegacyComponentSerializer.legacySection().serialize(icComponent)); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/excellentenchants/ExcellentEnchantsHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.excellentenchants; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.api.InteractiveChatAPI; 25 | import com.loohp.interactivechat.objectholders.ICPlayer; 26 | import com.loohp.interactivechat.objectholders.ICPlayerFactory; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.enchantments.Enchantment; 29 | import org.bukkit.inventory.ItemStack; 30 | import org.bukkit.inventory.meta.ItemMeta; 31 | import org.bukkit.plugin.Plugin; 32 | import su.nightexpress.excellentenchants.api.EnchantRegistry; 33 | import su.nightexpress.excellentenchants.config.Config; 34 | import su.nightexpress.excellentenchants.hook.HookPlugin; 35 | import su.nightexpress.excellentenchants.util.EnchantUtils; 36 | import su.nightexpress.nightcore.util.Plugins; 37 | 38 | import java.util.stream.Collectors; 39 | 40 | public class ExcellentEnchantsHook { 41 | 42 | public static final String NAMESPACE = "excellentenchants"; 43 | 44 | public static void init() { 45 | Plugin excellentEnchants = Bukkit.getPluginManager().getPlugin("ExcellentEnchants"); 46 | if (Config.isDescriptionEnabled() && (Plugins.isInstalled(HookPlugin.PACKET_EVENTS) || Plugins.isInstalled(HookPlugin.PROTOCOL_LIB))) { 47 | InteractiveChatAPI.registerItemStackTransformProvider(excellentEnchants, 1, (itemStack, uuid) -> { 48 | ICPlayer icPlayer = ICPlayerFactory.getICPlayer(uuid); 49 | return setExcellentEnchantsInfo(itemStack, icPlayer); 50 | }); 51 | } 52 | } 53 | 54 | public static ItemStack setExcellentEnchantsInfo(ItemStack itemStack, ICPlayer icPlayer) { 55 | if (icPlayer != null && icPlayer.isLocal() && EnchantUtils.canUpdateDisplay(icPlayer.getLocalPlayer())) { 56 | itemStack = EnchantUtils.addDescription(itemStack); 57 | } 58 | if (InteractiveChat.excellentEnchantsStripEnchantments && itemStack.hasItemMeta()) { 59 | ItemMeta itemMeta = itemStack.getItemMeta(); 60 | System.out.println(EnchantRegistry.getRegistered().stream().map(e -> e.getBukkitEnchantment().getKey()).collect(Collectors.toList())); 61 | for (Enchantment enchantment : itemMeta.getEnchants().keySet()) { 62 | System.out.println(enchantment.getKey() + " -> " + EnchantRegistry.isRegistered(enchantment)); 63 | if (EnchantRegistry.isRegistered(enchantment)) { 64 | itemMeta.removeEnchant(enchantment); 65 | } 66 | } 67 | itemStack.setItemMeta(itemMeta); 68 | } 69 | return itemStack; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/luckperms/LuckPermsEvents.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.luckperms; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.utils.PlayerUtils; 25 | import com.loohp.platformscheduler.Scheduler; 26 | import net.luckperms.api.LuckPermsProvider; 27 | import net.luckperms.api.event.user.UserDataRecalculateEvent; 28 | 29 | import java.util.Collections; 30 | import java.util.HashSet; 31 | import java.util.Set; 32 | import java.util.UUID; 33 | 34 | public class LuckPermsEvents { 35 | 36 | private final Set scheduledReset; 37 | 38 | public LuckPermsEvents(InteractiveChat plugin) { 39 | scheduledReset = Collections.synchronizedSet(new HashSet<>()); 40 | LuckPermsProvider.get().getEventBus().subscribe(plugin, UserDataRecalculateEvent.class, event -> { 41 | UUID uuid = event.getUser().getUniqueId(); 42 | if (!scheduledReset.contains(uuid)) { 43 | scheduledReset.add(uuid); 44 | Scheduler.runTaskLater(plugin, () -> { 45 | PlayerUtils.resetPermissionCache(uuid); 46 | scheduledReset.remove(uuid); 47 | }, 1); 48 | } 49 | }); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/triton/TritonHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.triton; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.utils.InteractiveChatComponentSerializer; 25 | import com.rexcantor64.triton.api.Triton; 26 | import com.rexcantor64.triton.api.TritonAPI; 27 | import com.rexcantor64.triton.api.config.FeatureSyntax; 28 | import net.kyori.adventure.text.Component; 29 | import net.md_5.bungee.api.chat.BaseComponent; 30 | import net.md_5.bungee.chat.ComponentSerializer; 31 | 32 | import java.util.UUID; 33 | 34 | public class TritonHook { 35 | 36 | public static Component parseLanguageChat(UUID player, Component component) { 37 | Triton triton = TritonAPI.getInstance(); 38 | String language; 39 | if (player == null) { 40 | language = triton.getLanguageManager().getMainLanguage().getLanguageId(); 41 | } else { 42 | language = triton.getPlayerManager().get(player).getLanguageId(); 43 | } 44 | FeatureSyntax syntax = triton.getConf().getChatSyntax(); 45 | String json; 46 | if (InteractiveChat.version.isLegacyRGB()) { 47 | json = InteractiveChatComponentSerializer.legacyGson().serialize(component); 48 | } else { 49 | json = InteractiveChatComponentSerializer.gson().serialize(component); 50 | } 51 | BaseComponent[] components = triton.getLanguageParser().parseComponent(language, syntax, ComponentSerializer.parse(json)); 52 | if (InteractiveChat.version.isLegacyRGB()) { 53 | return InteractiveChatComponentSerializer.legacyGson().deserialize(ComponentSerializer.toString(components)); 54 | } else { 55 | return InteractiveChatComponentSerializer.gson().deserialize(ComponentSerializer.toString(components)); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/hooks/venturechat/VentureChatInjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.hooks.venturechat; 22 | 23 | import com.comphenix.protocol.events.ListenerPriority; 24 | import com.comphenix.protocol.events.ListeningWhitelist; 25 | import com.comphenix.protocol.events.PacketEvent; 26 | import com.comphenix.protocol.events.PacketListener; 27 | import com.loohp.interactivechat.InteractiveChat; 28 | import com.loohp.interactivechat.platform.protocollib.ProtocolLibPlatform; 29 | import com.loohp.platformscheduler.Scheduler; 30 | import org.bukkit.Bukkit; 31 | import org.bukkit.ChatColor; 32 | import org.bukkit.event.EventHandler; 33 | import org.bukkit.event.Listener; 34 | import org.bukkit.event.server.PluginEnableEvent; 35 | 36 | public class VentureChatInjection implements Listener { 37 | 38 | private static boolean init = false; 39 | private static PacketListener packetListener = null; 40 | 41 | public static void _init_() { 42 | Bukkit.getPluginManager().registerEvents(new VentureChatInjection(), InteractiveChat.plugin); 43 | ProtocolLibPlatform.protocolManager.getPacketListeners().forEach(each -> { 44 | if (each.getPlugin().getName().equals("VentureChat")) { 45 | ListeningWhitelist whitelist = each.getSendingWhitelist(); 46 | if (whitelist.getTypes().stream().anyMatch(type -> {String name = type.name(); return name.equals("CHAT") || name.equals("SYSTEM_CHAT") || name.equals("CHAT_PREVIEW");})) { 47 | if (whitelist.getPriority().equals(ListenerPriority.MONITOR)) { 48 | packetListener = each; 49 | ProtocolLibPlatform.protocolManager.removePacketListener(each); 50 | } 51 | } 52 | } 53 | }); 54 | init = true; 55 | } 56 | 57 | public static void firePacketListener(PacketEvent event) { 58 | if (packetListener != null) { 59 | packetListener.onPacketSending(event); 60 | } 61 | } 62 | 63 | @EventHandler 64 | public void onPluginEnable(PluginEnableEvent event) { 65 | if (init) { 66 | if (event.getPlugin().getName().equalsIgnoreCase("VentureChat")) { 67 | Scheduler.runTaskLater(InteractiveChat.plugin, () -> { 68 | _init_(); 69 | Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into VentureChat!"); 70 | }, 100); 71 | } 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/listeners/PlayerEvents.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.listeners; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import org.bukkit.event.EventHandler; 25 | import org.bukkit.event.Listener; 26 | import org.bukkit.event.player.PlayerQuitEvent; 27 | 28 | public class PlayerEvents implements Listener { 29 | 30 | @EventHandler 31 | public void onQuit(PlayerQuitEvent event) { 32 | InteractiveChat.signedMessageModificationData.remove(event.getPlayer().getUniqueId()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/listeners/packet/ClientSettingsHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.listeners.packet; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.config.ConfigManager; 25 | import com.loohp.interactivechat.utils.ChatColorUtils; 26 | import com.loohp.platformscheduler.Scheduler; 27 | import org.bukkit.entity.Player; 28 | 29 | /** 30 | * Everything within the packet package (but not in sub-packages) contain platform independent code. 31 | * The sub-packages (packetevents and protocollib) contain the platform dependent code which will reference the methods within these classes. 32 | */ 33 | public class ClientSettingsHandler { 34 | 35 | /** 36 | * The ProtocolLib and PacketEvents independent packet listener classes call on this. 37 | * This is a simple method that checks the client settings for colour code configs. 38 | * It notifies the player about the disabling of colours, and sends a warning message concerning it. 39 | * 40 | * @param colorSettings Client side colour settings - whether colours are enabled or not 41 | * @param originalColorSettings Server side original colour settings. Compared with colorSettings with their original setting when they first joined. 42 | * @param player Player in question. 43 | */ 44 | public static void handlePacketReceiving(boolean colorSettings, boolean originalColorSettings, Player player) { 45 | if (originalColorSettings && !colorSettings) { 46 | sendMessageLater(player, ConfigManager.getConfig().getString("Messages.ColorsDisabled")); 47 | } else if (!originalColorSettings && colorSettings) { 48 | sendMessageLater(player, ConfigManager.getConfig().getString("Messages.ColorsReEnabled")); 49 | } 50 | } 51 | 52 | private static void sendMessageLater(Player player, String message) { 53 | Scheduler.runTaskLater(InteractiveChat.plugin, () -> { 54 | player.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', message)); 55 | }, 5, player); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/listeners/packet/MessagePacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.listeners.packet; 22 | 23 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 24 | import com.loohp.interactivechat.objectholders.AsyncChatSendingExecutor; 25 | import com.loohp.interactivechat.utils.ChatComponentType; 26 | import net.kyori.adventure.text.Component; 27 | 28 | import java.util.UUID; 29 | import java.util.concurrent.Executor; 30 | import java.util.concurrent.Executors; 31 | 32 | public class MessagePacketHandler { 33 | 34 | public static final UUID UUID_NIL = new UUID(0, 0); 35 | public static final Executor SCHEDULING_SERVICE = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("InteractiveChat Async ChatMessage Process Scheduling Thread").build()); 36 | public static AsyncChatSendingExecutor SERVICE = null; 37 | 38 | public static AsyncChatSendingExecutor getAsyncChatSendingExecutor() { 39 | return SERVICE; 40 | } 41 | 42 | public static class PacketAccessorResult { 43 | private final Component component; 44 | private final ChatComponentType type; 45 | private final int field; 46 | private final boolean preview; 47 | 48 | public PacketAccessorResult(Component component, ChatComponentType type, int field, boolean preview) { 49 | this.component = component; 50 | this.type = type; 51 | this.field = field; 52 | this.preview = preview; 53 | } 54 | 55 | public Component getComponent() { 56 | return component; 57 | } 58 | 59 | public ChatComponentType getType() { 60 | return type; 61 | } 62 | 63 | public int getField() { 64 | return field; 65 | } 66 | 67 | public boolean isPreview() { 68 | return preview; 69 | } 70 | } 71 | 72 | public static class PacketWriterResult { 73 | private final boolean tooLong; 74 | private final int jsonLength; 75 | private final UUID sender; 76 | 77 | public PacketWriterResult(boolean tooLong, int jsonLength, UUID sender) { 78 | this.tooLong = tooLong; 79 | this.jsonLength = jsonLength; 80 | this.sender = sender; 81 | } 82 | 83 | public boolean isTooLong() { 84 | return tooLong; 85 | } 86 | 87 | public int getJsonLength() { 88 | return jsonLength; 89 | } 90 | 91 | public UUID getSender() { 92 | return sender; 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/listeners/packet/RedispatchedSignPacketHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.listeners.packet; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import com.loohp.interactivechat.utils.ModernChatSigningUtils; 25 | import com.loohp.interactivechat.utils.PlayerUtils; 26 | import com.loohp.platformscheduler.Scheduler; 27 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 28 | import org.bukkit.entity.Player; 29 | 30 | import java.util.concurrent.ExecutionException; 31 | 32 | /** 33 | * Reducing code duplication... one class at a time. 34 | * (where possible, of course!) 35 | */ 36 | public class RedispatchedSignPacketHandler { 37 | 38 | public static void redispatchCommand(Player player, String command) { 39 | Scheduler.runTask(InteractiveChat.plugin, () -> { 40 | PlayerUtils.dispatchCommandAsPlayer(player, command); 41 | if (!InteractiveChat.skipDetectSpamRateWhenDispatchingUnsignedPackets) { 42 | ModernChatSigningUtils.detectRateSpam(player, command); 43 | } 44 | }, player); 45 | } 46 | 47 | /** 48 | * Must check if ModernChatSigningUtils.isChatMessageIllegal is false! 49 | * @param player Player to dispatch the message as. 50 | * @param message Message to "re-dispatch" 51 | */ 52 | public static void redispatchChatMessage(Player player, String message) { 53 | if (player.isConversing()) { 54 | Scheduler.runTask(InteractiveChat.plugin, () -> player.acceptConversationInput(message), player); 55 | if (!InteractiveChat.skipDetectSpamRateWhenDispatchingUnsignedPackets) { 56 | Scheduler.runTaskAsynchronously(InteractiveChat.plugin, () -> ModernChatSigningUtils.detectRateSpam(player, message)); 57 | } 58 | } else { 59 | Scheduler.runTaskAsynchronously(InteractiveChat.plugin, () -> { 60 | try { 61 | Object decorated = ModernChatSigningUtils.getChatDecorator(player, LegacyComponentSerializer.legacySection().deserialize(message)).get(); 62 | PlayerUtils.chatAsPlayer(player, message, decorated); 63 | if (!InteractiveChat.skipDetectSpamRateWhenDispatchingUnsignedPackets) { 64 | ModernChatSigningUtils.detectRateSpam(player, message); 65 | } 66 | } catch (InterruptedException | ExecutionException e) { 67 | e.printStackTrace(); 68 | } 69 | }); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/listeners/packet/listeners/PLibClientSettingPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.listeners.packet.listeners; 22 | 23 | import com.comphenix.protocol.PacketType; 24 | import com.comphenix.protocol.events.ListenerPriority; 25 | import com.comphenix.protocol.events.PacketAdapter; 26 | import com.comphenix.protocol.events.PacketContainer; 27 | import com.comphenix.protocol.events.PacketEvent; 28 | import com.loohp.interactivechat.InteractiveChat; 29 | import com.loohp.interactivechat.listeners.packet.ClientSettingsHandler; 30 | import com.loohp.interactivechat.nms.NMS; 31 | import com.loohp.interactivechat.platform.protocollib.ProtocolLibPlatform; 32 | import com.loohp.interactivechat.utils.MCVersion; 33 | import com.loohp.interactivechat.utils.PlayerUtils; 34 | import org.bukkit.entity.Player; 35 | 36 | public class PLibClientSettingPacket { 37 | 38 | public static void clientSettingsListener() { 39 | PacketAdapter.AdapterParameteters params = PacketAdapter.params() 40 | .listenerPriority(ListenerPriority.MONITOR) 41 | .plugin(InteractiveChat.plugin); 42 | 43 | if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_20_2)) { 44 | params.types(PacketType.Configuration.Client.CLIENT_INFORMATION); 45 | } else { 46 | params.types(PacketType.Play.Client.SETTINGS); 47 | } 48 | 49 | ProtocolLibPlatform.protocolManager.addPacketListener(new PacketAdapter(params) { 50 | @Override 51 | public void onPacketSending(PacketEvent event) { 52 | // do nothing 53 | } 54 | 55 | @Override 56 | public void onPacketReceiving(PacketEvent event) { 57 | if (event.isPlayerTemporary()) return; 58 | 59 | PacketContainer packet = event.getPacket(); 60 | Player player = event.getPlayer(); 61 | 62 | boolean colorSettings = NMS.getInstance().getColorSettingsFromClientInformationPacket(packet); 63 | boolean originalColorSettings = PlayerUtils.canChatColor(player); 64 | 65 | ClientSettingsHandler.handlePacketReceiving(colorSettings, originalColorSettings, player); 66 | } 67 | }); 68 | } 69 | } -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/main/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.main; 22 | 23 | import java.awt.GraphicsEnvironment; 24 | import java.lang.reflect.InvocationTargetException; 25 | import java.lang.reflect.Method; 26 | import java.util.Arrays; 27 | 28 | public class Main { 29 | 30 | public static void main(String[] args) { 31 | if (GraphicsEnvironment.isHeadless() || Arrays.asList(args).contains("--nogui")) { 32 | CMLMain.launch(args); 33 | } else { 34 | GUIMain.launch(args); 35 | } 36 | } 37 | 38 | public static void mainInteractiveChatDiscordSrvAddon(String[] args) { 39 | try { 40 | Class clazz = Class.forName("com.loohp.interactivechatdiscordsrvaddon.main.Main"); 41 | Method method = clazz.getMethod("run", String[].class); 42 | method.invoke(null, new Object[] {args}); 43 | } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/modules/ProcessCommands.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.modules; 22 | 23 | import com.loohp.interactivechat.objectholders.ProcessSenderResult; 24 | import com.loohp.interactivechat.registry.Registry; 25 | import com.loohp.interactivechat.utils.ComponentReplacing; 26 | import com.loohp.interactivechat.utils.InteractiveChatComponentSerializer; 27 | import net.kyori.adventure.text.Component; 28 | 29 | import java.util.UUID; 30 | import java.util.regex.Matcher; 31 | import java.util.regex.Pattern; 32 | 33 | public class ProcessCommands { 34 | 35 | public static final Pattern PATTERN_0 = Pattern.compile("(?:)"); 36 | public static final Pattern PATTERN_1 = Pattern.compile("(?:)"); 37 | 38 | public static final Pattern COLOR_IGNORE_PATTERN_0 = Pattern.compile("(?:(?:§.)*<(?:§.)*c(?:§.)*m(?:§.)*d(?:§.)*=((?:(?:§.)*[0-9a-f]){8}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){12})(?:§.)*>)"); 39 | public static final Pattern COLOR_IGNORE_PATTERN_1 = Pattern.compile("(?:(?:§.)*<(?:§.)*c(?:§.)*m(?:§.)*d(?:§.)*=((?:(?:§.)*[0-9a-f]){8}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){4}(?:§.)*-(?:(?:§.)*[0-9a-f]){12}):(.*)(?:§.)*>)"); 40 | 41 | public static ProcessSenderResult process(Component component) { 42 | UUID uuid = null; 43 | String text = InteractiveChatComponentSerializer.plainText().serialize(component); 44 | Matcher matcher0 = PATTERN_0.matcher(text); 45 | if (matcher0.find()) { 46 | uuid = UUID.fromString(matcher0.group(1)); 47 | } 48 | component = ComponentReplacing.replace(component, PATTERN_0.pattern(), false, (result, matchedComponents) -> { 49 | Component replacement = result.componentGroup(2); 50 | if (replacement == null) { 51 | return Component.empty(); 52 | } else { 53 | return ComponentReplacing.replace(replacement, Registry.ID_UNESCAPE_PATTERN.pattern(), Component.text(">")); 54 | } 55 | }); 56 | if (uuid == null) { 57 | Matcher matcher1 = PATTERN_1.matcher(text); 58 | if (matcher1.find()) { 59 | uuid = UUID.fromString(matcher1.group(1)); 60 | } 61 | } 62 | component = ComponentReplacing.replace(component, PATTERN_1.pattern(), Component.empty()); 63 | return new ProcessSenderResult(component, uuid); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/nms/NMS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.nms; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | 25 | import java.lang.reflect.InvocationTargetException; 26 | 27 | public class NMS { 28 | 29 | private static NMSWrapper instance; 30 | 31 | @SuppressWarnings({"unchecked", "deprecation"}) 32 | public synchronized static NMSWrapper getInstance() { 33 | if (instance != null) { 34 | return instance; 35 | } 36 | try { 37 | Class nmsImplClass = (Class) Class.forName("com.loohp.interactivechat.nms." + InteractiveChat.version.name()); 38 | instance = nmsImplClass.getConstructor().newInstance(); 39 | NMSWrapper.setup(instance, InteractiveChat.plugin); 40 | return instance; 41 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) { 42 | if (InteractiveChat.version.isSupported()) { 43 | throw new RuntimeException("Missing NMSWrapper implementation for version " + InteractiveChat.version.name(), e); 44 | } else { 45 | throw new RuntimeException("No NMSWrapper implementation for UNSUPPORTED version " + InteractiveChat.version.name(), e); 46 | } 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/BuiltInPlaceholder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.regex.Pattern; 24 | 25 | public class BuiltInPlaceholder extends ICPlaceholder { 26 | 27 | public BuiltInPlaceholder(Pattern keyword, String name, String description, String permission, long cooldown) { 28 | super(keyword, name, description, permission, cooldown); 29 | } 30 | 31 | @Override 32 | public boolean isBuildIn() { 33 | return true; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/CooldownResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class CooldownResult { 24 | 25 | private final CooldownOutcome outcome; 26 | private final long now; 27 | private final long cooldownExpireTime; 28 | private final ICPlaceholder placeholder; 29 | 30 | public CooldownResult(CooldownOutcome outcome, long now, long cooldownExpireTime, ICPlaceholder placeholder) { 31 | this.outcome = outcome; 32 | this.now = now; 33 | this.cooldownExpireTime = cooldownExpireTime; 34 | this.placeholder = placeholder; 35 | } 36 | 37 | public CooldownOutcome getOutcome() { 38 | return outcome; 39 | } 40 | 41 | public long getTimeNow() { 42 | return now; 43 | } 44 | 45 | public long getCooldownExpireTime() { 46 | return cooldownExpireTime; 47 | } 48 | 49 | public ICPlaceholder getPlaceholder() { 50 | return placeholder; 51 | } 52 | 53 | public enum CooldownOutcome { 54 | 55 | ALLOW(true), 56 | ALLOW_BYPASS(true), 57 | DENY_PLACEHOLDER(false), 58 | DENY_UNIVERSAL(false); 59 | 60 | private final boolean allowed; 61 | 62 | CooldownOutcome(boolean allowed) { 63 | this.allowed = allowed; 64 | } 65 | 66 | public boolean isAllowed() { 67 | return allowed; 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/Either.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.Objects; 24 | import java.util.function.Consumer; 25 | import java.util.function.Function; 26 | 27 | public class Either { 28 | 29 | public static Either left(L value) { 30 | return new Either<>(value, null, true); 31 | } 32 | 33 | public static Either left(L value, Class rightClass) { 34 | return new Either<>(value, null, true); 35 | } 36 | 37 | public static Either right(R value) { 38 | return new Either<>(null, value, false); 39 | } 40 | 41 | public static Either right(Class leftClass, R value) { 42 | return new Either<>(null, value, false); 43 | } 44 | 45 | private final L left; 46 | private final R right; 47 | private final boolean isLeft; 48 | 49 | private Either(L left, R right, boolean isLeft) { 50 | this.left = left; 51 | this.right = right; 52 | this.isLeft = isLeft; 53 | } 54 | 55 | public Object get() { 56 | return isLeft ? left : right; 57 | } 58 | 59 | public boolean isLeft() { 60 | return isLeft; 61 | } 62 | 63 | public boolean isRight() { 64 | return !isLeft; 65 | } 66 | 67 | public L getLeft() { 68 | return isLeft ? left : null; 69 | } 70 | 71 | public R getRight() { 72 | return isLeft ? null : right; 73 | } 74 | 75 | public T computeIf(Function leftFunction, Function rightFunction) { 76 | return isLeft ? leftFunction.apply(left) : rightFunction.apply(right); 77 | } 78 | 79 | public void consumeIf(Consumer leftConsumer, Consumer rightConsumer) { 80 | if (isLeft) { 81 | leftConsumer.accept(left); 82 | } else { 83 | rightConsumer.accept(right); 84 | } 85 | } 86 | 87 | @Override 88 | public boolean equals(Object o) { 89 | if (this == o) { 90 | return true; 91 | } 92 | if (o == null || getClass() != o.getClass()) { 93 | return false; 94 | } 95 | Either either = (Either) o; 96 | return isLeft == either.isLeft && Objects.equals(left, either.left) && Objects.equals(right, either.right); 97 | } 98 | 99 | @Override 100 | public int hashCode() { 101 | return Objects.hash(left, right, isLeft); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/ICInventoryHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import org.bukkit.inventory.Inventory; 24 | import org.bukkit.inventory.InventoryHolder; 25 | 26 | public class ICInventoryHolder implements InventoryHolder { 27 | 28 | public static final ICInventoryHolder INSTANCE = new ICInventoryHolder(); 29 | 30 | private ICInventoryHolder() { 31 | 32 | } 33 | 34 | @Override 35 | public Inventory getInventory() { 36 | return null; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/LegacyIdKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class LegacyIdKey { 24 | 25 | private String stringId; 26 | private byte byteId; 27 | private short damage; 28 | 29 | public LegacyIdKey(byte byteId, short damage) { 30 | this.byteId = byteId; 31 | this.damage = damage; 32 | } 33 | 34 | public LegacyIdKey(String stringId, short damage) { 35 | this.stringId = stringId; 36 | this.damage = damage; 37 | } 38 | 39 | public byte getByteId() { 40 | return byteId; 41 | } 42 | 43 | public boolean hasByteId() { 44 | return stringId == null; 45 | } 46 | 47 | public String getStringId() { 48 | return stringId; 49 | } 50 | 51 | public boolean hasStringId() { 52 | return stringId != null; 53 | } 54 | 55 | public short getDamage() { 56 | return damage; 57 | } 58 | 59 | public boolean isDamageDataValue() { 60 | return damage <= Byte.MAX_VALUE; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/LimitedQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.LinkedList; 24 | 25 | public class LimitedQueue extends LinkedList { 26 | 27 | private final int limit; 28 | 29 | public LimitedQueue(int limit) { 30 | this.limit = limit; 31 | } 32 | 33 | public int getLimit() { 34 | return limit; 35 | } 36 | 37 | @Override 38 | public boolean add(E o) { 39 | boolean added = super.add(o); 40 | while (added && size() > limit) { 41 | super.remove(); 42 | } 43 | return added; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/MentionTagConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import com.loohp.interactivechat.utils.CustomStringUtils; 24 | 25 | import java.util.regex.Pattern; 26 | 27 | public class MentionTagConverter { 28 | 29 | private String style; 30 | private Pattern reverse; 31 | 32 | public MentionTagConverter(String style) { 33 | this.style = style; 34 | this.reverse = Pattern.compile(CustomStringUtils.escapeMetaCharacters(style).replace("\\%s", "(.*?)")); 35 | } 36 | 37 | public String convertToTag(String find, String input) { 38 | return input.replace(find, getTagStyle(find)); 39 | } 40 | 41 | public String revertTags(String input) { 42 | return reverse.matcher(input).replaceAll("$1"); 43 | } 44 | 45 | public boolean containsTags(String input) { 46 | return reverse.matcher(input).find(); 47 | } 48 | 49 | public String getRawTagStyle() { 50 | return style; 51 | } 52 | 53 | public String getTagStyle(String find) { 54 | return style.replace("%s", find); 55 | } 56 | 57 | public Pattern getReversePattern() { 58 | return reverse; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/OffsetMatchResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.regex.MatchResult; 24 | 25 | public class OffsetMatchResult implements MatchResult { 26 | 27 | public static MatchResult wrap(MatchResult matchResult, int groupOffset) { 28 | return new OffsetMatchResult(matchResult, groupOffset); 29 | } 30 | 31 | private MatchResult backingResult; 32 | private int groupOffset; 33 | 34 | private OffsetMatchResult(MatchResult backingResult, int groupOffset) { 35 | this.backingResult = backingResult; 36 | this.groupOffset = groupOffset; 37 | } 38 | 39 | @Override 40 | public int start() { 41 | return backingResult.start(); 42 | } 43 | 44 | @Override 45 | public int start(int group) { 46 | return backingResult.start(getOffsetGroup(group)); 47 | } 48 | 49 | @Override 50 | public int end() { 51 | return backingResult.end(); 52 | } 53 | 54 | @Override 55 | public int end(int group) { 56 | return backingResult.end(getOffsetGroup(group)); 57 | } 58 | 59 | @Override 60 | public String group() { 61 | return backingResult.group(); 62 | } 63 | 64 | @Override 65 | public String group(int group) { 66 | return backingResult.group(getOffsetGroup(group)); 67 | } 68 | 69 | @Override 70 | public int groupCount() { 71 | return Math.max(0, backingResult.groupCount() - groupOffset); 72 | } 73 | 74 | public int getOffsetGroup(int group) { 75 | return group == 0 ? 0 : group + groupOffset; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/OutboundPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import org.bukkit.entity.Player; 24 | 25 | public class OutboundPacket { 26 | 27 | private final Player reciever; 28 | private final Object packet; 29 | 30 | /** 31 | * Simple outbound packet class, used to store packets that will be sent later on to a player. 32 | * 33 | * @param reciever Receiver of the packet. 34 | * @param packet Will be cast to the platform-dependent object later. For ProtocolLib: PacketContainer. For PacketEvents: PacketWrapper. 35 | */ 36 | public OutboundPacket(Player reciever, Object packet) { 37 | this.reciever = reciever; 38 | this.packet = packet; 39 | } 40 | 41 | public Player getReciever() { 42 | return reciever; 43 | } 44 | 45 | public Object getPacket() { 46 | return packet; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/PermissionCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class PermissionCache { 24 | 25 | private final long time; 26 | private boolean value; 27 | 28 | public PermissionCache(boolean value, long time) { 29 | this.value = value; 30 | this.time = time; 31 | } 32 | 33 | public boolean getValue() { 34 | return value; 35 | } 36 | 37 | public void setValue(boolean value) { 38 | this.value = value; 39 | } 40 | 41 | public long getTime() { 42 | return time; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/ProcessSenderResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import net.kyori.adventure.text.Component; 24 | 25 | import java.util.UUID; 26 | 27 | public class ProcessSenderResult { 28 | 29 | private final Component component; 30 | private final UUID sender; 31 | 32 | public ProcessSenderResult(Component component, UUID sender) { 33 | this.component = component; 34 | this.sender = sender; 35 | } 36 | 37 | public Component getComponent() { 38 | return component; 39 | } 40 | 41 | public UUID getSender() { 42 | return sender; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/ReplaceTextBundle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.Objects; 24 | 25 | public class ReplaceTextBundle implements Comparable { 26 | 27 | private final String placeholder; 28 | private final ICPlayer player; 29 | private final String replaceText; 30 | 31 | public ReplaceTextBundle(String placeholder, ICPlayer player, String replaceText) { 32 | this.placeholder = placeholder; 33 | this.player = player; 34 | this.replaceText = replaceText; 35 | } 36 | 37 | public String getPlaceholder() { 38 | return placeholder; 39 | } 40 | 41 | public ICPlayer getPlayer() { 42 | return player; 43 | } 44 | 45 | public String getReplaceText() { 46 | return replaceText; 47 | } 48 | 49 | @Override 50 | public int compareTo(ReplaceTextBundle anotherReplaceTextBundle) { 51 | int compare = Integer.compare(placeholder.length(), anotherReplaceTextBundle.placeholder.length()); 52 | if (compare != 0) { 53 | return compare; 54 | } else { 55 | return Integer.compare(replaceText.length(), anotherReplaceTextBundle.replaceText.length()); 56 | } 57 | } 58 | 59 | @Override 60 | public boolean equals(Object o) { 61 | if (this == o) { 62 | return true; 63 | } 64 | if (o == null || getClass() != o.getClass()) { 65 | return false; 66 | } 67 | ReplaceTextBundle that = (ReplaceTextBundle) o; 68 | return placeholder.equals(that.placeholder) && player.equals(that.player) && replaceText.equals(that.replaceText); 69 | } 70 | 71 | @Override 72 | public int hashCode() { 73 | return Objects.hash(placeholder, player, replaceText); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/SignedMessageModificationData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | import java.util.UUID; 24 | 25 | public class SignedMessageModificationData { 26 | 27 | private UUID sender; 28 | private long time; 29 | private String originalMessage; 30 | private String modifiedMessage; 31 | 32 | public SignedMessageModificationData(UUID sender, long time, String originalMessage, String modifiedMessage) { 33 | this.sender = sender; 34 | this.time = time; 35 | this.originalMessage = originalMessage; 36 | this.modifiedMessage = modifiedMessage; 37 | } 38 | 39 | public UUID getSender() { 40 | return sender; 41 | } 42 | 43 | public long getTime() { 44 | return time; 45 | } 46 | 47 | public String getOriginalMessage() { 48 | return originalMessage; 49 | } 50 | 51 | public String getModifiedMessage() { 52 | return modifiedMessage; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/objectholders/WrappedString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.objectholders; 22 | 23 | public class WrappedString { 24 | 25 | private String string; 26 | 27 | public WrappedString(String string) { 28 | this.string = string; 29 | } 30 | 31 | public WrappedString() { 32 | this(""); 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public String setString(String string) { 40 | return this.string = string; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return string; 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | final int prime = 31; 51 | int result = 1; 52 | result = prime * result + ((string == null) ? 0 : string.hashCode()); 53 | return result; 54 | } 55 | 56 | @Override 57 | public boolean equals(Object obj) { 58 | if (this == obj) { 59 | return true; 60 | } 61 | if (!(obj instanceof WrappedString)) { 62 | return false; 63 | } 64 | WrappedString other = (WrappedString) obj; 65 | if (string == null) { 66 | return other.string == null; 67 | } else { 68 | return string.equals(other.string); 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/platform/ProtocolPlatform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.platform; 22 | 23 | import com.loohp.interactivechat.objectholders.CustomTabCompletionAction; 24 | import net.kyori.adventure.text.Component; 25 | import org.bukkit.command.CommandSender; 26 | import org.bukkit.entity.Player; 27 | import org.bukkit.plugin.Plugin; 28 | 29 | import java.util.List; 30 | import java.util.UUID; 31 | 32 | public interface ProtocolPlatform { 33 | 34 | Plugin getRegisteredPlugin(); 35 | 36 | void initialize(); 37 | 38 | void onBungeecordModeEnabled(); 39 | 40 | void sendTabCompletionPacket(Player player, CustomTabCompletionAction action, List list); 41 | 42 | void sendUnprocessedChatMessage(CommandSender sender, UUID uuid, Component component); 43 | 44 | boolean hasChatSigning(); 45 | 46 | int getProtocolVersion(Player player); 47 | 48 | Player newTemporaryPlayer(String name, UUID uuid); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/platform/protocollib/ProtocolLibAsyncChatSendingExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.platform.protocollib; 22 | 23 | import com.comphenix.protocol.events.PacketContainer; 24 | import com.loohp.interactivechat.InteractiveChat; 25 | import com.loohp.interactivechat.objectholders.AsyncChatSendingExecutor; 26 | import com.loohp.interactivechat.objectholders.OutboundPacket; 27 | import com.loohp.platformscheduler.ScheduledTask; 28 | import com.loohp.platformscheduler.Scheduler; 29 | 30 | import java.util.function.LongSupplier; 31 | 32 | public class ProtocolLibAsyncChatSendingExecutor extends AsyncChatSendingExecutor { 33 | 34 | public ProtocolLibAsyncChatSendingExecutor(LongSupplier executionWaitTime, long killThreadAfter) { 35 | super(executionWaitTime, killThreadAfter); 36 | } 37 | 38 | @Override 39 | public ScheduledTask packetSender() { 40 | return Scheduler.runTaskTimer(InteractiveChat.plugin, () -> { 41 | while (!sendingQueue.isEmpty()) { 42 | OutboundPacket out = sendingQueue.poll(); 43 | try { 44 | if (out.getReciever().isOnline()) { 45 | ProtocolLibPlatform.protocolManager.sendServerPacket(out.getReciever(), (PacketContainer) out.getPacket(), false); 46 | } 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | }, 0, 1); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/bungee/metrics/Charts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.bungee.metrics; 22 | 23 | import com.loohp.interactivechat.proxy.bungee.InteractiveChatBungee; 24 | 25 | import java.util.concurrent.Callable; 26 | 27 | public class Charts { 28 | 29 | public static void setup(Metrics metrics) { 30 | 31 | metrics.addCustomChart(new Metrics.SingleLineChart("total_plugin_messages_relayed_per_interval", new Callable() { 32 | @Override 33 | public Integer call() throws Exception { 34 | long amount = InteractiveChatBungee.pluginMessagesCounter.getAndSet(0); 35 | return (int) Math.min(Integer.MAX_VALUE, amount); 36 | } 37 | })); 38 | 39 | metrics.addCustomChart(new Metrics.SingleLineChart("servers_managed_by_bungeecord_with_interactivechat", new Callable() { 40 | @Override 41 | public Integer call() throws Exception { 42 | long amount = InteractiveChatBungee.getBackendInteractiveChatInfo().values().stream().filter(each -> each.hasInteractiveChat()).count(); 43 | return (int) Math.min(Integer.MAX_VALUE, amount); 44 | } 45 | })); 46 | 47 | metrics.addCustomChart(new Metrics.SimplePie("accurate_sender_parser_enabled", new Callable() { 48 | @Override 49 | public String call() throws Exception { 50 | return InteractiveChatBungee.useAccurateSenderFinder ? "Enabled" : "Disabled"; 51 | } 52 | })); 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/objectholders/ChatPacketType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.objectholders; 22 | 23 | public enum ChatPacketType { 24 | 25 | LEGACY_CHAT(false), 26 | CLIENT_CHAT(false), 27 | SYSTEM_CHAT(false), 28 | PLAYER_CHAT(false), 29 | CHAT_PREVIEW(true), 30 | LEGACY_TITLE(false), 31 | TITLE(false), 32 | SUBTITLE(false), 33 | ACTION_BAR(false); 34 | 35 | private final boolean preview; 36 | 37 | ChatPacketType(boolean preview) { 38 | this.preview = preview; 39 | } 40 | 41 | public boolean isPreview() { 42 | return preview; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/objectholders/ForwardedMessageData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.objectholders; 22 | 23 | public class ForwardedMessageData { 24 | 25 | private String message; 26 | private ChatPacketType packetType; 27 | private long timeStamp; 28 | 29 | public ForwardedMessageData(String message, ChatPacketType packetType, long timeStamp) { 30 | this.message = message; 31 | this.packetType = packetType; 32 | this.timeStamp = timeStamp; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | public ChatPacketType getPacketType() { 40 | return packetType; 41 | } 42 | 43 | public long getTimeStamp() { 44 | return timeStamp; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/objectholders/ProxyHandlePacketTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.objectholders; 22 | 23 | import java.util.Collections; 24 | import java.util.EnumSet; 25 | import java.util.List; 26 | import java.util.Set; 27 | 28 | public class ProxyHandlePacketTypes { 29 | 30 | public static final ProxyHandlePacketTypes ALL = new ProxyHandlePacketTypes(EnumSet.allOf(ProxyPacketType.class)); 31 | 32 | public static ProxyHandlePacketTypes fromStringList(List types) { 33 | Set set = EnumSet.noneOf(ProxyPacketType.class); 34 | for (String type : types) { 35 | set.add(ProxyPacketType.valueOf(type.toUpperCase())); 36 | } 37 | return new ProxyHandlePacketTypes(set); 38 | } 39 | 40 | private final Set types; 41 | 42 | public ProxyHandlePacketTypes(Set types) { 43 | this.types = Collections.unmodifiableSet(types); 44 | } 45 | 46 | public Set getTypes() { 47 | return types; 48 | } 49 | 50 | public boolean hasType(ProxyPacketType type) { 51 | return types.contains(type); 52 | } 53 | 54 | public enum ProxyPacketType { 55 | 56 | CHAT, SYSTEM_CHAT, ACTIONBAR, TITLE; 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/objectholders/ProxyPlayerCooldownManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.objectholders; 22 | 23 | import com.loohp.interactivechat.objectholders.ICPlaceholder; 24 | 25 | import java.util.ArrayList; 26 | import java.util.Collection; 27 | import java.util.Iterator; 28 | import java.util.List; 29 | import java.util.Map; 30 | import java.util.UUID; 31 | import java.util.concurrent.ConcurrentHashMap; 32 | 33 | public class ProxyPlayerCooldownManager { 34 | 35 | private final Map universalTimestamps; 36 | private final Map> placeholderTimestamps; 37 | 38 | public ProxyPlayerCooldownManager(Collection keywords) { 39 | this.universalTimestamps = new ConcurrentHashMap<>(); 40 | this.placeholderTimestamps = new ConcurrentHashMap<>(); 41 | reloadPlaceholders(keywords); 42 | } 43 | 44 | public void reloadPlaceholders(Collection placeholders) { 45 | List placeholderList = new ArrayList<>(placeholders); 46 | Iterator itr = placeholderTimestamps.keySet().iterator(); 47 | while (itr.hasNext()) { 48 | UUID internalId = itr.next(); 49 | if (placeholderList.stream().noneMatch(each -> each.getInternalId().equals(internalId))) { 50 | itr.remove(); 51 | } 52 | } 53 | for (ICPlaceholder keyword : placeholderList) { 54 | placeholderTimestamps.putIfAbsent(keyword.getInternalId(), new ConcurrentHashMap<>()); 55 | } 56 | } 57 | 58 | public long getPlayerUniversalLastTimestamp(UUID uuid) { 59 | Long time = universalTimestamps.get(uuid); 60 | return time == null ? -1 : time; 61 | } 62 | 63 | public void setPlayerUniversalLastTimestamp(UUID uuid, long time) { 64 | universalTimestamps.put(uuid, time); 65 | } 66 | 67 | public long getPlayerPlaceholderLastTimestamp(UUID uuid, UUID internalId) { 68 | Map mapping = placeholderTimestamps.get(internalId); 69 | if (mapping == null) { 70 | return -1; 71 | } 72 | Long time = mapping.get(uuid); 73 | return time == null ? -1 : time; 74 | } 75 | 76 | public void setPlayerPlaceholderLastTimestamp(UUID uuid, UUID internalId, long time) { 77 | Map mapping = placeholderTimestamps.get(internalId); 78 | if (mapping == null) { 79 | return; 80 | } 81 | mapping.put(uuid, time); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/velocity/ICChannelIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.velocity; 22 | 23 | import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; 24 | 25 | public class ICChannelIdentifier { 26 | 27 | public static final MinecraftChannelIdentifier INSTANCE = MinecraftChannelIdentifier.from("interchat:main"); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/velocity/VelocityPluginDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.velocity; 22 | 23 | import org.json.simple.JSONObject; 24 | 25 | public class VelocityPluginDescription { 26 | 27 | private final String id; 28 | private final String name; 29 | private final String version; 30 | 31 | public VelocityPluginDescription(JSONObject json) { 32 | this.id = json.get("id").toString(); 33 | this.name = json.get("name").toString(); 34 | this.version = json.get("version").toString(); 35 | } 36 | 37 | public String getId() { 38 | return id; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public String getVersion() { 46 | return version; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/proxy/velocity/metrics/Charts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.proxy.velocity.metrics; 22 | 23 | import com.loohp.interactivechat.proxy.velocity.InteractiveChatVelocity; 24 | 25 | import java.util.concurrent.Callable; 26 | 27 | public class Charts { 28 | 29 | public static void setup(Metrics metrics) { 30 | 31 | metrics.addCustomChart(new Metrics.SingleLineChart("total_plugin_messages_relayed_per_interval", new Callable() { 32 | @Override 33 | public Integer call() throws Exception { 34 | long amount = InteractiveChatVelocity.pluginMessagesCounter.getAndSet(0); 35 | return (int) Math.min(Integer.MAX_VALUE, amount); 36 | } 37 | })); 38 | 39 | metrics.addCustomChart(new Metrics.SingleLineChart("servers_managed_by_velocity_with_interactivechat", new Callable() { 40 | @Override 41 | public Integer call() throws Exception { 42 | long amount = InteractiveChatVelocity.getBackendInteractiveChatInfo().values().stream().filter(each -> each.hasInteractiveChat()).count(); 43 | return (int) Math.min(Integer.MAX_VALUE, amount); 44 | } 45 | })); 46 | 47 | metrics.addCustomChart(new Metrics.SimplePie("accurate_sender_parser_enabled", new Callable() { 48 | @Override 49 | public String call() throws Exception { 50 | return InteractiveChatVelocity.useAccurateSenderFinder ? "Enabled" : "Disabled"; 51 | } 52 | })); 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/registry/Registry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.registry; 22 | 23 | import com.loohp.interactivechat.objectholders.MentionTagConverter; 24 | import com.loohp.interactivechat.utils.ComponentReplacing; 25 | import net.kyori.adventure.text.Component; 26 | 27 | import java.util.Arrays; 28 | import java.util.Collections; 29 | import java.util.HashSet; 30 | import java.util.Set; 31 | import java.util.function.Function; 32 | import java.util.regex.Pattern; 33 | 34 | public class Registry { 35 | 36 | public static final String PLUGIN_MESSAGING_PROTOCOL_IDENTIFIER = "InteractiveChatBungeePing"; 37 | public static final int PLUGIN_MESSAGING_PROTOCOL_VERSION = 20; 38 | 39 | public static final int INTERACTIVE_CHAT_DISCORD_SRV_ADDON_COMPATIBLE_VERSION = 47; 40 | 41 | public static final Pattern ID_PATTERN = Pattern.compile("(?:<(cmd|chat)=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(:(.*?):)?>)"); 42 | public static final Function ID_PATTERN_REPLACEMENT = result -> result.group(4) == null ? Component.empty() : result.componentGroup(4); 43 | public static final Pattern CHR_ID_PATTERN = Pattern.compile("(?:<(cmd|chat)=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(\\\\:(.*?)\\\\:)?>)"); 44 | public static final Pattern ID_ESCAPE_PATTERN = Pattern.compile(">"); 45 | public static final Pattern ID_UNESCAPE_PATTERN = Pattern.compile("\\\\>"); 46 | 47 | public static final MentionTagConverter MENTION_TAG_CONVERTER = new MentionTagConverter(""); 48 | 49 | public static final int MINECRAFT_1_16_PROTOCOL_VERSION = 735; 50 | public static final int MINECRAFT_1_19_1_PROTOCOL_VERSION = 760; 51 | 52 | public static final Set PROXY_PASSTHROUGH_RELAY_PACKETS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( 53 | 0x00, 54 | 0x01, 55 | 0x02, 56 | 0x03, 57 | 0x04, 58 | 0x05, 59 | 0x06, 60 | 0x0E, 61 | 0x0F, 62 | 0x11, 63 | 0x12, 64 | 0x14, 65 | 0xFF 66 | ))); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/updater/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.updater; 22 | 23 | public class Version implements Comparable { 24 | 25 | private final String version; 26 | 27 | public Version(String version) { 28 | if (version == null) { 29 | throw new IllegalArgumentException("Version can not be null"); 30 | } 31 | if (!version.matches("[0-9]+(\\.[0-9]+)*")) { 32 | throw new IllegalArgumentException("Invalid version format"); 33 | } 34 | this.version = version; 35 | } 36 | 37 | public String get() { 38 | return this.version; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return get(); 44 | } 45 | 46 | @Override 47 | public int compareTo(Version that) { 48 | if (that == null) { 49 | return 1; 50 | } 51 | String[] thisParts = this.get().split("\\."); 52 | String[] thatParts = that.get().split("\\."); 53 | int length = Math.max(thisParts.length, thatParts.length); 54 | for (int i = 0; i < length; i++) { 55 | int thisPart = i < thisParts.length ? 56 | Integer.parseInt(thisParts[i]) : 0; 57 | int thatPart = i < thatParts.length ? 58 | Integer.parseInt(thatParts[i]) : 0; 59 | if (thisPart < thatPart) { 60 | return -1; 61 | } 62 | if (thisPart > thatPart) { 63 | return 1; 64 | } 65 | } 66 | return 0; 67 | } 68 | 69 | @Override 70 | public boolean equals(Object that) { 71 | if (this == that) { 72 | return true; 73 | } 74 | if (that == null) { 75 | return false; 76 | } 77 | if (this.getClass() != that.getClass()) { 78 | return false; 79 | } 80 | return this.compareTo((Version) that) == 0; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/BookUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import net.kyori.adventure.inventory.Book; 24 | import net.kyori.adventure.text.Component; 25 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 26 | import net.md_5.bungee.api.chat.BaseComponent; 27 | import org.bukkit.inventory.ItemStack; 28 | import org.bukkit.inventory.meta.BookMeta; 29 | 30 | import java.util.List; 31 | import java.util.stream.Collectors; 32 | 33 | public class BookUtils { 34 | 35 | public static boolean isTextBook(ItemStack item) { 36 | return item.getItemMeta() instanceof BookMeta; 37 | } 38 | 39 | public static List getPages(BookMeta bookMeta) { 40 | return bookMeta.spigot().getPages().stream().map(each -> ChatComponentType.BaseComponentArray.convertFrom(each)).collect(Collectors.toList()); 41 | } 42 | 43 | public static void setPages(BookMeta bookMeta, List pages, boolean legacyRGB) { 44 | bookMeta.spigot().setPages(pages.stream().map(each -> (BaseComponent[]) ChatComponentType.BaseComponentArray.convertTo(each, legacyRGB)).collect(Collectors.toList())); 45 | } 46 | 47 | public static Book toAdventure(BookMeta meta) { 48 | return Book.book(LegacyComponentSerializer.legacySection().deserializeOr(meta.getTitle(), Component.empty()), LegacyComponentSerializer.legacySection().deserializeOr(meta.getAuthor(), Component.empty()), getPages(meta)); 49 | } 50 | 51 | public static void fromAdventure(BookMeta bookMeta, Book book, boolean legacyRGB) { 52 | String title = LegacyComponentSerializer.legacySection().serialize(book.title()); 53 | bookMeta.setTitle(title.isEmpty() ? null : title); 54 | String author = LegacyComponentSerializer.legacySection().serialize(book.author()); 55 | bookMeta.setAuthor(author.isEmpty() ? null : author); 56 | setPages(bookMeta, book.pages(), legacyRGB); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/ClassUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.lang.reflect.Array; 24 | 25 | public class ClassUtils { 26 | 27 | public static Class arrayType(Class type) { 28 | return Array.newInstance(type, 0).getClass(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.util.Collection; 24 | import java.util.function.Predicate; 25 | 26 | public class CollectionUtils { 27 | 28 | public static void filter(Collection collection, Predicate predicate) { 29 | collection.removeIf(t -> !predicate.test(t)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/ComponentModernizing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import net.kyori.adventure.text.Component; 24 | import net.kyori.adventure.text.ComponentLike; 25 | import net.kyori.adventure.text.TextComponent; 26 | import net.kyori.adventure.text.TranslatableComponent; 27 | import net.kyori.adventure.text.format.Style.Merge; 28 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.regex.Pattern; 33 | 34 | public class ComponentModernizing { 35 | 36 | public static final Pattern COLOR_CODE_PATTERN = Pattern.compile("\u00a7."); 37 | 38 | public static Component modernize(Component component) { 39 | component = ComponentFlattening.flatten(component); 40 | List children = new ArrayList<>(component.children()); 41 | for (int i = 0; i < children.size(); i++) { 42 | Component child = children.get(i); 43 | if (child instanceof TextComponent) { 44 | TextComponent text = (TextComponent) child; 45 | String content = text.content(); 46 | TextComponent modern = LegacyComponentSerializer.legacySection().deserialize(content); 47 | String modernContent = COLOR_CODE_PATTERN.matcher(modern.content()).replaceAll(""); 48 | modern = modern.content(modernContent); 49 | modern = modern.style(modern.style().merge(text.style(), Merge.Strategy.IF_ABSENT_ON_TARGET)); 50 | children.set(i, modern); 51 | } else if (child instanceof TranslatableComponent) { 52 | TranslatableComponent trans = (TranslatableComponent) child; 53 | List withs = new ArrayList<>(ComponentLike.asComponents(trans.arguments())); 54 | withs.replaceAll(arg -> modernize(arg)); 55 | trans = trans.arguments(withs); 56 | children.set(i, trans); 57 | } 58 | } 59 | return ComponentCompacting.optimize(component.children(children)); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/CustomArrayUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.lang.reflect.Array; 24 | import java.util.Arrays; 25 | 26 | public class CustomArrayUtils { 27 | 28 | public static byte[][] divideArray(byte[] source, int chunkSize) { 29 | int length = (int) Math.ceil(source.length / (double) chunkSize); 30 | if (length <= 1) { 31 | return new byte[][] {source}; 32 | } 33 | byte[][] ret = new byte[length][]; 34 | int start = 0; 35 | for (int i = 0; i < ret.length; i++) { 36 | int end = start + chunkSize; 37 | ret[i] = Arrays.copyOfRange(source, start, Math.min(end, source.length)); 38 | start += chunkSize; 39 | } 40 | return ret; 41 | } 42 | 43 | public static boolean allNull(Object src) { 44 | if (src == null) { 45 | return true; 46 | } 47 | if (!src.getClass().isArray()) { 48 | return false; 49 | } 50 | for (int i = 0; i < Array.getLength(src); i++) { 51 | if (Array.get(src, i) != null) { 52 | return false; 53 | } 54 | } 55 | return true; 56 | } 57 | 58 | public static boolean anyNull(Object src) { 59 | if (src == null) { 60 | return true; 61 | } 62 | if (!src.getClass().isArray()) { 63 | return false; 64 | } 65 | for (int i = 0; i < Array.getLength(src); i++) { 66 | if (Array.get(src, i) == null) { 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.io.File; 24 | import java.io.FileInputStream; 25 | import java.io.IOException; 26 | import java.io.InputStream; 27 | import java.nio.file.FileSystem; 28 | import java.nio.file.FileSystems; 29 | import java.nio.file.Files; 30 | import java.nio.file.Path; 31 | 32 | public class FileUtils { 33 | 34 | private static final ClassLoader NULL_CLASSLOADER = null; 35 | 36 | public static void removeFolderRecursively(File folder) { 37 | if (folder.exists()) { 38 | File[] files = folder.listFiles(); 39 | for (File file : files) { 40 | if (file.isDirectory()) { 41 | removeFolderRecursively(file); 42 | } else { 43 | if (!file.delete()) { 44 | file.deleteOnExit(); 45 | } 46 | } 47 | } 48 | if (!folder.delete()) { 49 | folder.deleteOnExit(); 50 | } 51 | } 52 | } 53 | 54 | public static long copy(File from, File to) throws IOException { 55 | FileInputStream stream = new FileInputStream(from); 56 | long result = Files.copy(stream, to.toPath()); 57 | stream.close(); 58 | return result; 59 | } 60 | 61 | public static long copy(InputStream from, File to) throws IOException { 62 | return Files.copy(from, to.toPath()); 63 | } 64 | 65 | public static void copyZipEntry(File zipFile, String fileName, File outputFile) throws IOException { 66 | try (FileSystem fileSystem = FileSystems.newFileSystem(zipFile.toPath(), NULL_CLASSLOADER)) { 67 | Path fileToExtract = fileSystem.getPath(fileName); 68 | Files.copy(fileToExtract, outputFile.toPath()); 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/FilledMapUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.loohp.interactivechat.nms.NMS; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.inventory.ItemStack; 26 | import org.bukkit.inventory.meta.MapMeta; 27 | import org.bukkit.map.MapCursor; 28 | import org.bukkit.map.MapView; 29 | 30 | import java.util.List; 31 | 32 | public class FilledMapUtils { 33 | 34 | public static boolean isFilledMap(ItemStack itemStack) { 35 | try { 36 | return itemStack != null && itemStack.getItemMeta() != null && itemStack.getItemMeta() instanceof MapMeta; 37 | } catch (Exception e) { 38 | return false; 39 | } 40 | } 41 | 42 | public static MapView getMapView(ItemStack itemStack) { 43 | return NMS.getInstance().getMapView(itemStack); 44 | } 45 | 46 | public static int getMapId(ItemStack itemStack) { 47 | return NMS.getInstance().getMapId(itemStack); 48 | } 49 | 50 | public static boolean isContextual(MapView mapView) { 51 | return NMS.getInstance().isContextual(mapView); 52 | } 53 | 54 | public static byte[] getColors(MapView mapView, Player player) { 55 | return NMS.getInstance().getColors(mapView, player); 56 | } 57 | 58 | public static List getCursors(MapView mapView, Player player) { 59 | return NMS.getInstance().getCursors(mapView, player); 60 | } 61 | 62 | public static List toNMSMapIconList(List mapCursors) { 63 | return NMS.getInstance().toNMSMapIconList(mapCursors); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/IgnoreUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.Zrips.CMI.CMI; 24 | import com.Zrips.CMI.Containers.CMIUser; 25 | import com.earth2me.essentials.Essentials; 26 | import com.earth2me.essentials.User; 27 | import com.loohp.interactivechat.InteractiveChat; 28 | import mineverse.Aust1n46.chat.api.MineverseChatAPI; 29 | import mineverse.Aust1n46.chat.api.MineverseChatPlayer; 30 | import org.bukkit.Bukkit; 31 | 32 | import java.util.UUID; 33 | 34 | public class IgnoreUtils { 35 | 36 | public static boolean isIgnore(UUID source, UUID target) { 37 | if (InteractiveChat.ventureChatHook) { 38 | MineverseChatPlayer venturePlayer = MineverseChatAPI.getMineverseChatPlayer(source); 39 | if (venturePlayer != null && venturePlayer.getIgnores().contains(target)) { 40 | return true; 41 | } 42 | } 43 | 44 | if (InteractiveChat.cmiHook) { 45 | CMIUser user = CMI.getInstance().getPlayerManager().getUser(source); 46 | if (user != null && user.isIgnoring(target)) { 47 | return true; 48 | } 49 | } 50 | 51 | if (InteractiveChat.essentialsHook) { 52 | Essentials ess3 = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); 53 | User sourceUser = ess3.getUser(source); 54 | User targetUser = ess3.getUser(target); 55 | return sourceUser != null && targetUser != null && sourceUser.isIgnoredPlayer(targetUser); 56 | } 57 | 58 | return false; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/ItemStackUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.loohp.interactivechat.nms.NMS; 24 | import com.loohp.interactivechat.objectholders.ICMaterial; 25 | import net.kyori.adventure.text.Component; 26 | import net.kyori.adventure.text.format.TextDecoration; 27 | import net.md_5.bungee.api.ChatColor; 28 | import org.bukkit.Material; 29 | import org.bukkit.inventory.ItemStack; 30 | import org.bukkit.inventory.meta.ItemMeta; 31 | 32 | import java.util.List; 33 | 34 | public class ItemStackUtils { 35 | 36 | private static final ItemStack AIR = new ItemStack(Material.AIR); 37 | 38 | public static Component getDisplayName(ItemStack itemstack) { 39 | return getDisplayName(itemstack, true); 40 | } 41 | 42 | public static Component getDisplayName(ItemStack itemstack, boolean applyStyle) { 43 | return getDisplayName(itemstack, applyStyle, true); 44 | } 45 | 46 | public static Component getDisplayName(ItemStack itemstack, boolean applyStyle, boolean removeClickAndHover) { 47 | if (itemstack == null) { 48 | itemstack = AIR.clone(); 49 | } 50 | ICMaterial icMaterial = ICMaterial.from(itemstack); 51 | ItemMeta itemMeta = itemstack.getItemMeta(); 52 | 53 | Component component = Component.empty().append(NMS.getInstance().getItemStackDisplayName(itemstack)); 54 | 55 | if (applyStyle) { 56 | if (itemMeta != null && itemMeta.hasDisplayName()) { 57 | component = component.decorate(TextDecoration.ITALIC); 58 | } 59 | 60 | ChatColor rarityChatColor = NMS.getInstance().getRarityColor(itemstack); 61 | if (rarityChatColor != null) { 62 | component = component.colorIfAbsent(ColorUtils.toTextColor(rarityChatColor)); 63 | } 64 | } 65 | 66 | if (removeClickAndHover) { 67 | component = ComponentStyling.stripEvents(component); 68 | } 69 | return component; 70 | } 71 | 72 | public static List getLore(ItemStack itemstack) { 73 | ItemMeta meta = itemstack.getItemMeta(); 74 | if (meta == null) { 75 | return null; 76 | } 77 | if (!meta.hasLore()) { 78 | return null; 79 | } 80 | return NMS.getInstance().getItemStackLore(itemstack); 81 | } 82 | 83 | public static ItemStack toBukkitCopy(Object handle) { 84 | return NMS.getInstance().toBukkitCopy(handle); 85 | } 86 | 87 | public static Object toNMSCopy(ItemStack itemstack) { 88 | return NMS.getInstance().toNMSCopy(itemstack); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/NBTParsingUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.loohp.interactivechat.nms.NMS; 24 | import net.querz.nbt.io.NamedTag; 25 | import net.querz.nbt.tag.CompoundTag; 26 | import net.querz.nbt.tag.Tag; 27 | 28 | import java.io.IOException; 29 | 30 | public class NBTParsingUtils { 31 | 32 | public static Tag fromSNBT(String snbt) throws IOException { 33 | try { 34 | boolean isList = snbt.trim().startsWith("["); 35 | if (isList) { 36 | snbt = "{List:" + snbt + "}"; 37 | } 38 | NamedTag namedTag = NMS.getInstance().fromSNBT(snbt); 39 | if (namedTag == null) { 40 | return null; 41 | } 42 | if (isList) { 43 | return ((CompoundTag) namedTag.getTag()).getListTag("List"); 44 | } 45 | return namedTag.getTag(); 46 | } catch (Exception e) { 47 | throw new IOException("Unable to parse SNBT: " + snbt, e); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/PotionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.loohp.interactivechat.InteractiveChat; 24 | import org.bukkit.potion.PotionType; 25 | 26 | import java.util.EnumMap; 27 | import java.util.Map; 28 | 29 | public class PotionUtils { 30 | 31 | private static final Map potionMapping = new EnumMap<>(PotionType.class); 32 | 33 | static { 34 | if (!InteractiveChat.version.isLegacy()) { 35 | potionMapping.put(PotionType.WATER, "water"); 36 | potionMapping.put(PotionType.MUNDANE, "mundane"); 37 | potionMapping.put(PotionType.THICK, "thick"); 38 | potionMapping.put(PotionType.AWKWARD, "awkward"); 39 | potionMapping.put(PotionType.NIGHT_VISION, "night_vision"); 40 | potionMapping.put(PotionType.INVISIBILITY, "invisibility"); 41 | potionMapping.put(PotionType.JUMP, "leaping"); 42 | potionMapping.put(PotionType.FIRE_RESISTANCE, "fire_resistance"); 43 | potionMapping.put(PotionType.SPEED, "swiftness"); 44 | potionMapping.put(PotionType.SLOWNESS, "slowness"); 45 | potionMapping.put(PotionType.TURTLE_MASTER, "turtle_master"); 46 | potionMapping.put(PotionType.WATER_BREATHING, "water_breathing"); 47 | potionMapping.put(PotionType.INSTANT_HEAL, "healing"); 48 | potionMapping.put(PotionType.INSTANT_DAMAGE, "harming"); 49 | potionMapping.put(PotionType.POISON, "poison"); 50 | potionMapping.put(PotionType.REGEN, "regeneration"); 51 | potionMapping.put(PotionType.STRENGTH, "strength"); 52 | potionMapping.put(PotionType.WEAKNESS, "weakness"); 53 | potionMapping.put(PotionType.LUCK, "luck"); 54 | potionMapping.put(PotionType.SLOW_FALLING, "slow_falling"); 55 | potionMapping.put(PotionType.UNCRAFTABLE, "empty"); 56 | } 57 | } 58 | 59 | public static String getVanillaPotionName(PotionType type) { 60 | if (potionMapping.containsKey(type)) { 61 | return potionMapping.get(type); 62 | } 63 | return potionMapping.get(PotionType.UNCRAFTABLE); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/RarityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.loohp.interactivechat.nms.NMS; 24 | import net.md_5.bungee.api.ChatColor; 25 | import org.bukkit.Material; 26 | import org.bukkit.inventory.ItemStack; 27 | 28 | public class RarityUtils { 29 | 30 | public static ChatColor getRarityColor(ItemStack item) { 31 | return NMS.getInstance().getRarityColor(item); 32 | } 33 | 34 | public static ChatColor getRarityColor(Material material) { 35 | if (!material.equals(Material.AIR)) { 36 | return getRarityColor(new ItemStack(material)); 37 | } 38 | return ChatColor.WHITE; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/SoundUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.cryptomorin.xseries.XSound; 24 | import org.bukkit.Sound; 25 | 26 | import java.util.Optional; 27 | 28 | public class SoundUtils { 29 | 30 | public static boolean isMinecraftSound(String string) { 31 | Optional opt = XSound.matchXSound(string); 32 | if (opt.isPresent()) { 33 | XSound xSound = opt.get(); 34 | return xSound.parseSound() != null; 35 | } 36 | return false; 37 | } 38 | 39 | public static Sound parseSound(String string) { 40 | Optional opt = XSound.matchXSound(string); 41 | if (opt.isPresent()) { 42 | XSound xSound = opt.get(); 43 | return xSound.parseSound(); 44 | } 45 | return null; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.text.DecimalFormat; 24 | import java.time.Instant; 25 | import java.time.LocalDateTime; 26 | import java.time.ZoneId; 27 | import java.time.temporal.ChronoUnit; 28 | 29 | public class TimeUtils { 30 | 31 | public static final DecimalFormat FORMAT = new DecimalFormat("00"); 32 | 33 | public static String getReadableTimeBetween(long from, long to) { 34 | LocalDateTime start = LocalDateTime.ofInstant(Instant.ofEpochMilli(from), ZoneId.systemDefault()); 35 | LocalDateTime now = LocalDateTime.ofInstant(Instant.ofEpochMilli(to), ZoneId.systemDefault()); 36 | long hrs = ChronoUnit.HOURS.between(start, now); 37 | long mins = ChronoUnit.MINUTES.between(start, now); 38 | long secs = ChronoUnit.SECONDS.between(start, now); 39 | return (hrs == 0 ? "" : (hrs + ":")) + FORMAT.format(mins % 60) + ":" + FORMAT.format(secs % 60); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/UUIDUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.nio.ByteBuffer; 24 | import java.nio.ByteOrder; 25 | import java.nio.charset.StandardCharsets; 26 | import java.util.UUID; 27 | 28 | public class UUIDUtils { 29 | 30 | public static UUID toUUID(int[] array) { 31 | return new UUID((long) array[0] << 32 | (long) array[1] & 4294967295L, (long) array[2] << 32 | (long) array[3] & 4294967295L); 32 | } 33 | 34 | public static int[] toIntArray(UUID uuid) { 35 | long most = uuid.getMostSignificantBits(); 36 | long least = uuid.getLeastSignificantBits(); 37 | return new int[] {(int) (most >> 32), (int) most, (int) (least >> 32), (int) least}; 38 | } 39 | 40 | public static byte[] toByteArray(UUID uuid) { 41 | byte[] array = new byte[16]; 42 | ByteBuffer.wrap(array).order(ByteOrder.BIG_ENDIAN).putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()); 43 | return array; 44 | } 45 | 46 | public static UUID fromOfflinePlayerName(String name) { 47 | return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/WrappedChatComponentUtils.java: -------------------------------------------------------------------------------- 1 | package com.loohp.interactivechat.utils; 2 | 3 | import com.comphenix.protocol.wrappers.WrappedChatComponent; 4 | import com.loohp.interactivechat.nms.NMS; 5 | 6 | public class WrappedChatComponentUtils { 7 | 8 | public static WrappedChatComponent fromJson(String json) { 9 | return WrappedChatComponent.fromHandle(NMS.getInstance().deserializeChatComponent(json)); 10 | } 11 | 12 | public static String toJson(WrappedChatComponent component) { 13 | return NMS.getInstance().serializeChatComponent(component.getHandle()); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/XMaterialUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import com.cryptomorin.xseries.XMaterial; 24 | 25 | import java.util.Optional; 26 | 27 | public class XMaterialUtils { 28 | 29 | public static Optional matchXMaterial(int id, byte data) { 30 | if (id < 0 || id > 2267 || data < 0) { 31 | return Optional.empty(); 32 | } 33 | for (XMaterial materials : XMaterial.VALUES) { 34 | if (materials.getData() == data && materials.getId() == id) { 35 | return Optional.of(materials); 36 | } 37 | } 38 | return Optional.empty(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/com/loohp/interactivechat/utils/ZipUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of InteractiveChat4. 3 | * 4 | * Copyright (C) 2020 - 2025. LoohpJames 5 | * Copyright (C) 2020 - 2025. 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 | 21 | package com.loohp.interactivechat.utils; 22 | 23 | import java.io.BufferedOutputStream; 24 | import java.io.File; 25 | import java.io.FileOutputStream; 26 | import java.io.IOException; 27 | import java.util.zip.ZipEntry; 28 | import java.util.zip.ZipInputStream; 29 | 30 | public class ZipUtils { 31 | 32 | public static void extract(ZipInputStream zip, File target) throws IOException { 33 | try { 34 | ZipEntry entry; 35 | 36 | while ((entry = zip.getNextEntry()) != null) { 37 | File file = new File(target, entry.getName()); 38 | 39 | if (!file.toPath().normalize().startsWith(target.toPath())) { 40 | throw new IOException("Bad zip entry"); 41 | } 42 | 43 | if (entry.isDirectory()) { 44 | file.mkdirs(); 45 | continue; 46 | } 47 | 48 | byte[] buffer = new byte[4096]; 49 | file.getParentFile().mkdirs(); 50 | BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); 51 | int count; 52 | 53 | while ((count = zip.read(buffer)) != -1) { 54 | out.write(buffer, 0, count); 55 | } 56 | 57 | out.close(); 58 | } 59 | } finally { 60 | zip.close(); 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /common/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: InteractiveChatBungee 2 | main: com.loohp.interactivechat.proxy.bungee.InteractiveChatBungee 3 | version: ${project.version} 4 | author: LOOHP 5 | -------------------------------------------------------------------------------- /common/src/main/resources/config_proxy.yml: -------------------------------------------------------------------------------- 1 | #Do not change this value 2 | ConfigVersion: "${project.version}" 3 | 4 | Settings: 5 | #Make sure this setting is the same on all servers in your network 6 | UseAccurateSenderParser: true 7 | 8 | TagEveryIdentifiableMessage: false 9 | 10 | #Handle messages from the Proxy 11 | #You probably won't want to touch this 12 | HandleProxyMessage: true 13 | 14 | #All types 15 | # CHAT - Player's chat messages 16 | # SYSTEM_CHAT - Server's messages 17 | # TITLE 18 | # ACTIONBAR 19 | HandlePacketType: 20 | - CHAT 21 | - SYSTEM_CHAT 22 | - TITLE 23 | - ACTIONBAR 24 | 25 | #A list of private message commands on your server 26 | #The plugin will attempt to parse placeholder inside these commands. 27 | #This list is in REGEX, so you can do some more advanced matches. 28 | CommandsToParse: 29 | - "(?i)/emsg .*" 30 | - "(?i)/msg .*" 31 | - "(?i)/pm .*" 32 | - "(?i)/tell .*" 33 | - "(?i)/r .*" 34 | 35 | #You might want to adjust this option if you have other plugins listening to the chat 36 | #And it is interfering with InteractiveChat's placeholders 37 | #Valid options are 38 | #. 39 | #For bungeecord: 40 | #LOWEST, LOW, NORMAL, HIGH/DEFAULT, HIGHEST 41 | #. 42 | #For Velocity: 43 | #FIRST, EARLY, NORMAL, LATE/DEFAULT, LAST 44 | ChatEventPriority: DEFAULT 45 | -------------------------------------------------------------------------------- /common/src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LOOHP/InteractiveChat/273cdaa529d52da0ce240f1f745ee148d9c522cc/common/src/main/resources/icon.png -------------------------------------------------------------------------------- /common/src/main/resources/storage.yml: -------------------------------------------------------------------------------- 1 | #Accepted storage types are SQLITE and MYSQL 2 | StorageType: SQLITE 3 | 4 | #This part is only relevant if you use MYSQL 5 | MYSQL: 6 | Host: localhost 7 | Port: 3306 8 | Database: InteractiveChat 9 | Username: mysql 10 | Password: password -------------------------------------------------------------------------------- /common/src/main/resources/velocity-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "interactivechatvelocity", 3 | "name": "InteractiveChatVelocity", 4 | "version": "${project.version}", 5 | "authors": ["LOOHP"], 6 | "dependencies": [], 7 | "main": "com.loohp.interactivechat.proxy.velocity.InteractiveChatVelocity" 8 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 25 | 4.0.0 26 | 27 | com.loohp 28 | InteractiveChat-Parent 29 | 4.3.3.0 30 | pom 31 | 32 | 33 | UTF-8 34 | 35 | 36 | 37 | 38 | 39 | dmulloy2-repo 40 | https://repo.dmulloy2.net/repository/public/ 41 | 42 | 43 | 44 | 45 | abstraction 46 | V1_8 47 | V1_8_3 48 | V1_8_4 49 | V1_9 50 | V1_9_4 51 | V1_10 52 | V1_11 53 | V1_12 54 | V1_13 55 | V1_13_1 56 | V1_14 57 | V1_15 58 | V1_16 59 | V1_16_2 60 | V1_16_4 61 | V1_17 62 | V1_18 63 | V1_18_2 64 | V1_19 65 | V1_19_3 66 | V1_19_4 67 | V1_20 68 | V1_20_2 69 | V1_20_3 70 | V1_20_5 71 | V1_20_6 72 | V1_21 73 | V1_21_1 74 | V1_21_2 75 | V1_21_3 76 | V1_21_4 77 | V1_21_5 78 | V1_21_6 79 | V1_21_7 80 | V1_21_8 81 | V1_21_9 82 | V1_21_10 83 | common 84 | 85 | --------------------------------------------------------------------------------