├── .gitignore
├── API
├── pom.xml
└── src
│ └── main
│ └── java
│ └── su
│ └── nightexpress
│ └── sunlight
│ └── api
│ ├── MenuType.java
│ ├── event
│ └── SunlightTeleportEvent.java
│ └── type
│ └── TeleportType.java
├── Core
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── su
│ │ └── nightexpress
│ │ └── sunlight
│ │ ├── Placeholders.java
│ │ ├── SunLightAPI.java
│ │ ├── SunLightPlugin.java
│ │ ├── api
│ │ └── event
│ │ │ ├── PlayerPrivateMessageEvent.java
│ │ │ └── PlayerTeleportRequestEvent.java
│ │ ├── command
│ │ ├── CommandArguments.java
│ │ ├── CommandConfig.java
│ │ ├── CommandFlags.java
│ │ ├── CommandPerms.java
│ │ ├── CommandRegistry.java
│ │ ├── CommandTools.java
│ │ ├── NodeCreator.java
│ │ ├── cooldown
│ │ │ ├── ArgumentPattern.java
│ │ │ └── CommandCooldown.java
│ │ ├── list
│ │ │ ├── AirCommand.java
│ │ │ ├── BroadcastCommand.java
│ │ │ ├── CondenseCommand.java
│ │ │ ├── ContainerCommands.java
│ │ │ ├── DimensionCommand.java
│ │ │ ├── DisposalCommand.java
│ │ │ ├── EnchantCommand.java
│ │ │ ├── EnderchestCommand.java
│ │ │ ├── ExperienceCommand.java
│ │ │ ├── FireCommands.java
│ │ │ ├── FlyCommand.java
│ │ │ ├── FlySpeedCommand.java
│ │ │ ├── FoodLevelCommand.java
│ │ │ ├── GameModeCommand.java
│ │ │ ├── HatCommand.java
│ │ │ ├── HealthCommand.java
│ │ │ ├── IgnoreCommands.java
│ │ │ ├── InventoryCommand.java
│ │ │ ├── ItemCommands.java
│ │ │ ├── MobCommand.java
│ │ │ ├── NearCommand.java
│ │ │ ├── NickCommand.java
│ │ │ ├── PlayerInfoCommand.java
│ │ │ ├── ReloadCommand.java
│ │ │ ├── SkullCommand.java
│ │ │ ├── SmiteCommand.java
│ │ │ ├── SpawnerCommand.java
│ │ │ ├── SpeedCommand.java
│ │ │ ├── StaffCommand.java
│ │ │ ├── SudoCommand.java
│ │ │ ├── SuicideCommand.java
│ │ │ ├── TeleportCommands.java
│ │ │ ├── TimeCommands.java
│ │ │ └── WeatherCommands.java
│ │ ├── mode
│ │ │ ├── ModifyMode.java
│ │ │ └── ToggleMode.java
│ │ └── template
│ │ │ ├── CommandTemplate.java
│ │ │ ├── DirectCommandTemplate.java
│ │ │ └── GroupCommandTemplate.java
│ │ ├── config
│ │ ├── Config.java
│ │ ├── Lang.java
│ │ └── Perms.java
│ │ ├── core
│ │ ├── CoreManager.java
│ │ ├── cooldown
│ │ │ ├── CooldownInfo.java
│ │ │ └── CooldownType.java
│ │ ├── listener
│ │ │ └── CoreListener.java
│ │ ├── menu
│ │ │ ├── IgnoreListMenu.java
│ │ │ └── IgnoreSettingsMenu.java
│ │ └── user
│ │ │ ├── IgnoredUser.java
│ │ │ └── settings
│ │ │ ├── Parser.java
│ │ │ ├── Setting.java
│ │ │ ├── SettingRegistry.java
│ │ │ └── SettingValue.java
│ │ ├── data
│ │ ├── DataHandler.java
│ │ ├── UserManager.java
│ │ ├── serialize
│ │ │ ├── CooldownSerializer.java
│ │ │ ├── IgnoredUserSerializer.java
│ │ │ ├── UserInfoSerializer.java
│ │ │ └── UserSettingsSerializer.java
│ │ └── user
│ │ │ ├── SunUser.java
│ │ │ └── UserSettings.java
│ │ ├── hook
│ │ ├── HookId.java
│ │ └── impl
│ │ │ └── PlaceholderHook.java
│ │ ├── module
│ │ ├── Module.java
│ │ ├── ModuleId.java
│ │ ├── ModuleInfo.java
│ │ ├── ModuleManager.java
│ │ ├── afk
│ │ │ ├── AfkModule.java
│ │ │ ├── AfkState.java
│ │ │ ├── command
│ │ │ │ └── AfkCommand.java
│ │ │ ├── config
│ │ │ │ ├── AfkConfig.java
│ │ │ │ ├── AfkLang.java
│ │ │ │ └── AfkPerms.java
│ │ │ ├── event
│ │ │ │ └── PlayerAfkEvent.java
│ │ │ └── listener
│ │ │ │ └── AfkListener.java
│ │ ├── backlocation
│ │ │ ├── BackLocationModule.java
│ │ │ ├── command
│ │ │ │ ├── BackCommand.java
│ │ │ │ └── DeathBackCommand.java
│ │ │ ├── config
│ │ │ │ ├── BackLocationConfig.java
│ │ │ │ ├── BackLocationLang.java
│ │ │ │ └── BackLocationPerms.java
│ │ │ ├── data
│ │ │ │ ├── LocationType.java
│ │ │ │ └── StoredLocation.java
│ │ │ └── listener
│ │ │ │ └── BackLocationListener.java
│ │ ├── bans
│ │ │ ├── BansModule.java
│ │ │ ├── command
│ │ │ │ ├── BaseCommands.java
│ │ │ │ ├── HistoryCommands.java
│ │ │ │ ├── ListCommands.java
│ │ │ │ ├── PunishCommands.java
│ │ │ │ └── UnPunishCommands.java
│ │ │ ├── config
│ │ │ │ ├── BansConfig.java
│ │ │ │ ├── BansLang.java
│ │ │ │ └── BansPerms.java
│ │ │ ├── data
│ │ │ │ └── BansDataHandler.java
│ │ │ ├── listener
│ │ │ │ └── BansListener.java
│ │ │ ├── menu
│ │ │ │ ├── HistoryMenu.java
│ │ │ │ ├── PunishmentsMenu.java
│ │ │ │ └── SortMode.java
│ │ │ ├── punishment
│ │ │ │ ├── LegacyPunishment.java
│ │ │ │ ├── PunishData.java
│ │ │ │ ├── PunishedIP.java
│ │ │ │ ├── PunishedPlayer.java
│ │ │ │ ├── PunishmentReason.java
│ │ │ │ └── PunishmentType.java
│ │ │ └── util
│ │ │ │ ├── BanTime.java
│ │ │ │ ├── Placeholders.java
│ │ │ │ ├── RankDuration.java
│ │ │ │ └── TimeUnit.java
│ │ ├── chat
│ │ │ ├── ChannelManager.java
│ │ │ ├── ChatChannel.java
│ │ │ ├── ChatModule.java
│ │ │ ├── PlayerChatData.java
│ │ │ ├── command
│ │ │ │ ├── ChannelCommands.java
│ │ │ │ ├── ClearChatCommand.java
│ │ │ │ ├── MentionsCommand.java
│ │ │ │ ├── PrivateMessageCommands.java
│ │ │ │ └── RoleplayCommands.java
│ │ │ ├── config
│ │ │ │ ├── ChatConfig.java
│ │ │ │ ├── ChatLang.java
│ │ │ │ └── ChatPerms.java
│ │ │ ├── discord
│ │ │ │ └── DiscordHandler.java
│ │ │ ├── event
│ │ │ │ ├── AsyncSunlightPlayerChatEvent.java
│ │ │ │ └── SunlightPreHandleChatEvent.java
│ │ │ ├── format
│ │ │ │ ├── FormatComponent.java
│ │ │ │ └── FormatContainer.java
│ │ │ ├── handler
│ │ │ │ ├── ChatMessageHandler.java
│ │ │ │ ├── CommandHandler.java
│ │ │ │ └── PrivateMessageHandler.java
│ │ │ ├── listener
│ │ │ │ └── ChatListener.java
│ │ │ ├── mention
│ │ │ │ ├── GroupMention.java
│ │ │ │ ├── Mention.java
│ │ │ │ └── PlayerMention.java
│ │ │ ├── module
│ │ │ │ ├── announcer
│ │ │ │ │ ├── AnnounceListener.java
│ │ │ │ │ ├── AnnounceManager.java
│ │ │ │ │ └── Announcer.java
│ │ │ │ ├── deathmessage
│ │ │ │ │ ├── DeathMessage.java
│ │ │ │ │ ├── DeathMessageListener.java
│ │ │ │ │ └── DeathMessageManager.java
│ │ │ │ ├── joinquit
│ │ │ │ │ ├── DisplayMode.java
│ │ │ │ │ ├── JoinMessage.java
│ │ │ │ │ ├── JoinMessageListener.java
│ │ │ │ │ └── JoinMessageManager.java
│ │ │ │ └── spy
│ │ │ │ │ ├── SpyCommands.java
│ │ │ │ │ ├── SpyListener.java
│ │ │ │ │ ├── SpyManager.java
│ │ │ │ │ └── SpyType.java
│ │ │ ├── report
│ │ │ │ ├── ReportHandler.java
│ │ │ │ ├── ReportPacketsHandler.java
│ │ │ │ └── ReportProtocolHandler.java
│ │ │ ├── rule
│ │ │ │ ├── ChatRule.java
│ │ │ │ ├── RuleCreator.java
│ │ │ │ ├── RuleData.java
│ │ │ │ └── RuleManager.java
│ │ │ └── util
│ │ │ │ ├── ChatUtils.java
│ │ │ │ └── Placeholders.java
│ │ ├── customtext
│ │ │ ├── CustomText.java
│ │ │ ├── CustomTextModule.java
│ │ │ ├── command
│ │ │ │ └── CustomTextCommands.java
│ │ │ └── config
│ │ │ │ ├── CTextLang.java
│ │ │ │ └── CTextPerms.java
│ │ ├── extras
│ │ │ ├── ExtrasModule.java
│ │ │ ├── chairs
│ │ │ │ ├── ChairsCommands.java
│ │ │ │ ├── ChairsListener.java
│ │ │ │ └── ChairsManager.java
│ │ │ ├── chestsort
│ │ │ │ ├── SortCommand.java
│ │ │ │ ├── SortListener.java
│ │ │ │ ├── SortManager.java
│ │ │ │ └── SortRule.java
│ │ │ ├── config
│ │ │ │ ├── ExtrasConfig.java
│ │ │ │ ├── ExtrasLang.java
│ │ │ │ └── ExtrasPerms.java
│ │ │ └── listener
│ │ │ │ ├── ExtrasGenericListener.java
│ │ │ │ └── PhysicsExplosionListener.java
│ │ ├── godmode
│ │ │ ├── GodListener.java
│ │ │ ├── GodModule.java
│ │ │ ├── command
│ │ │ │ └── GodCommands.java
│ │ │ └── config
│ │ │ │ ├── GodConfig.java
│ │ │ │ ├── GodLang.java
│ │ │ │ └── GodPerms.java
│ │ ├── homes
│ │ │ ├── HomesModule.java
│ │ │ ├── command
│ │ │ │ ├── HomeAdminCommands.java
│ │ │ │ └── HomeCommands.java
│ │ │ ├── config
│ │ │ │ ├── HomesConfig.java
│ │ │ │ ├── HomesLang.java
│ │ │ │ └── HomesPerms.java
│ │ │ ├── event
│ │ │ │ ├── PlayerHomeCreateEvent.java
│ │ │ │ ├── PlayerHomeRemoveEvent.java
│ │ │ │ └── PlayerHomeTeleportEvent.java
│ │ │ ├── impl
│ │ │ │ ├── Home.java
│ │ │ │ └── HomeType.java
│ │ │ ├── listener
│ │ │ │ └── HomeListener.java
│ │ │ ├── menu
│ │ │ │ ├── HomeMenu.java
│ │ │ │ └── HomesMenu.java
│ │ │ └── util
│ │ │ │ ├── HomesCache.java
│ │ │ │ └── Placeholders.java
│ │ ├── kits
│ │ │ ├── Kit.java
│ │ │ ├── KitsModule.java
│ │ │ ├── command
│ │ │ │ └── KitCommands.java
│ │ │ ├── config
│ │ │ │ ├── KitsConfig.java
│ │ │ │ ├── KitsLang.java
│ │ │ │ └── KitsPerms.java
│ │ │ ├── editor
│ │ │ │ ├── KitListEditor.java
│ │ │ │ └── KitSettingsEditor.java
│ │ │ ├── listener
│ │ │ │ └── KitBindListener.java
│ │ │ ├── menu
│ │ │ │ ├── KitPreviewMenu.java
│ │ │ │ └── KitsMenu.java
│ │ │ └── util
│ │ │ │ ├── KitsUtils.java
│ │ │ │ └── Placeholders.java
│ │ ├── nerfphantoms
│ │ │ ├── PhantomsModule.java
│ │ │ ├── command
│ │ │ │ └── NoPhantomCommand.java
│ │ │ ├── config
│ │ │ │ ├── PhantomsConfig.java
│ │ │ │ ├── PhantomsLang.java
│ │ │ │ └── PhantomsPerms.java
│ │ │ └── listener
│ │ │ │ └── PhantomsListener.java
│ │ ├── ptp
│ │ │ ├── Mode.java
│ │ │ ├── PTPModule.java
│ │ │ ├── TeleportRequest.java
│ │ │ ├── command
│ │ │ │ ├── AcceptCommands.java
│ │ │ │ ├── PTPCommand.java
│ │ │ │ ├── RequestCommands.java
│ │ │ │ └── ToggleCommand.java
│ │ │ ├── config
│ │ │ │ ├── PTPConfig.java
│ │ │ │ ├── PTPLang.java
│ │ │ │ └── PTPPerms.java
│ │ │ └── listener
│ │ │ │ └── PTPListener.java
│ │ ├── rtp
│ │ │ ├── RTPModule.java
│ │ │ ├── command
│ │ │ │ └── RTPCommands.java
│ │ │ ├── config
│ │ │ │ ├── RTPConfig.java
│ │ │ │ ├── RTPLang.java
│ │ │ │ └── RTPPerms.java
│ │ │ ├── impl
│ │ │ │ ├── LocationFinder.java
│ │ │ │ └── RangeInfo.java
│ │ │ └── listener
│ │ │ │ └── RTPListener.java
│ │ ├── scoreboard
│ │ │ ├── ScoreboardModule.java
│ │ │ ├── board
│ │ │ │ ├── Board.java
│ │ │ │ ├── BoardConfig.java
│ │ │ │ ├── BoardProvider.java
│ │ │ │ └── impl
│ │ │ │ │ ├── AbstractBoard.java
│ │ │ │ │ ├── PacketBoard.java
│ │ │ │ │ └── ProtocolBoard.java
│ │ │ ├── command
│ │ │ │ └── ScoreboardCommand.java
│ │ │ ├── config
│ │ │ │ ├── SBConfig.java
│ │ │ │ ├── SBLang.java
│ │ │ │ └── SBPerms.java
│ │ │ └── listener
│ │ │ │ └── ScoreboardListener.java
│ │ ├── spawns
│ │ │ ├── SpawnsModule.java
│ │ │ ├── command
│ │ │ │ └── SpawnCommands.java
│ │ │ ├── config
│ │ │ │ ├── SpawnsConfig.java
│ │ │ │ ├── SpawnsLang.java
│ │ │ │ └── SpawnsPerms.java
│ │ │ ├── editor
│ │ │ │ ├── SpawnListEditor.java
│ │ │ │ └── SpawnSettingsEditor.java
│ │ │ ├── event
│ │ │ │ └── PlayerSpawnTeleportEvent.java
│ │ │ ├── impl
│ │ │ │ └── Spawn.java
│ │ │ ├── listener
│ │ │ │ └── SpawnListener.java
│ │ │ └── util
│ │ │ │ └── Placeholders.java
│ │ ├── tab
│ │ │ ├── TabModule.java
│ │ │ ├── config
│ │ │ │ └── TabConfig.java
│ │ │ ├── handler
│ │ │ │ ├── NametagHandler.java
│ │ │ │ ├── PacketsTagHandler.java
│ │ │ │ └── ProtocolTagHandler.java
│ │ │ ├── impl
│ │ │ │ ├── NameTagFormat.java
│ │ │ │ ├── TabListFormat.java
│ │ │ │ └── TabNameFormat.java
│ │ │ └── listener
│ │ │ │ └── TabListener.java
│ │ ├── vanish
│ │ │ ├── VanishListener.java
│ │ │ ├── VanishModule.java
│ │ │ ├── command
│ │ │ │ └── VanishCommand.java
│ │ │ └── config
│ │ │ │ ├── VanishConfig.java
│ │ │ │ ├── VanishLang.java
│ │ │ │ └── VanishPerms.java
│ │ ├── warmups
│ │ │ ├── WarmupsModule.java
│ │ │ ├── config
│ │ │ │ ├── WarmupsConfig.java
│ │ │ │ ├── WarmupsLang.java
│ │ │ │ └── WarmupsPerms.java
│ │ │ ├── impl
│ │ │ │ ├── TeleportWarmup.java
│ │ │ │ ├── Warmup.java
│ │ │ │ └── WarmupType.java
│ │ │ └── listener
│ │ │ │ └── WarmupsListener.java
│ │ ├── warps
│ │ │ ├── WarpsModule.java
│ │ │ ├── command
│ │ │ │ ├── WarpCommands.java
│ │ │ │ └── WarpShortcutCommand.java
│ │ │ ├── config
│ │ │ │ ├── WarpsConfig.java
│ │ │ │ ├── WarpsLang.java
│ │ │ │ └── WarpsPerms.java
│ │ │ ├── event
│ │ │ │ └── PlayerWarpTeleportEvent.java
│ │ │ ├── impl
│ │ │ │ └── Warp.java
│ │ │ ├── menu
│ │ │ │ ├── DisplayInfo.java
│ │ │ │ ├── WarpListMenu.java
│ │ │ │ └── WarpSettingsMenu.java
│ │ │ ├── type
│ │ │ │ ├── SortType.java
│ │ │ │ └── WarpType.java
│ │ │ └── util
│ │ │ │ ├── Placeholders.java
│ │ │ │ └── WarpUtils.java
│ │ └── worlds
│ │ │ ├── WorldsModule.java
│ │ │ ├── command
│ │ │ └── WorldCommands.java
│ │ │ ├── config
│ │ │ ├── WorldsConfig.java
│ │ │ ├── WorldsLang.java
│ │ │ └── WorldsPerms.java
│ │ │ ├── editor
│ │ │ ├── WorldGenerationEditor.java
│ │ │ ├── WorldListEditor.java
│ │ │ ├── WorldMainEditor.java
│ │ │ └── WorldRulesEditor.java
│ │ │ ├── impl
│ │ │ ├── WorldData.java
│ │ │ ├── WorldInventories.java
│ │ │ ├── WrappedWorld.java
│ │ │ └── generation
│ │ │ │ ├── FastNoiseLite.java
│ │ │ │ ├── FlatChunkGenerator.java
│ │ │ │ ├── PlainsChunkGenerator.java
│ │ │ │ └── VoidChunkGenerator.java
│ │ │ ├── listener
│ │ │ ├── InventoryListener.java
│ │ │ └── WorldsListener.java
│ │ │ └── util
│ │ │ ├── DeletionType.java
│ │ │ ├── Placeholders.java
│ │ │ └── WorldUtils.java
│ │ └── utils
│ │ ├── DynamicText.java
│ │ ├── SunUtils.java
│ │ ├── UserInfo.java
│ │ ├── pos
│ │ ├── BlockEyedPos.java
│ │ ├── BlockPos.java
│ │ └── WorldPos.java
│ │ └── teleport
│ │ └── Teleporter.java
│ └── resources
│ ├── lang
│ ├── messages_cn.yml
│ ├── messages_es.yml
│ ├── messages_pl.yml
│ └── messages_pt_br.yml
│ └── plugin.yml
├── LICENSE
├── MC_1_21_4
├── pom.xml
└── src
│ └── main
│ └── java
│ └── su
│ └── nightexpress
│ └── sunlight
│ └── nms
│ └── mc_1_21_4
│ ├── MC_1_21_4.java
│ └── container
│ ├── PlayerEnderChest.java
│ └── PlayerInventory.java
├── MC_1_21_5
├── pom.xml
├── pom.xml.versionsBackup
└── src
│ └── main
│ └── java
│ └── su
│ └── nightexpress
│ └── sunlight
│ └── nms
│ └── mc_1_21_5
│ ├── MC_1_21_5.java
│ └── container
│ ├── PlayerEnderChest.java
│ └── PlayerInventory.java
├── NMS
├── pom.xml
└── src
│ └── main
│ └── java
│ └── su
│ └── nightexpress
│ └── sunlight
│ └── nms
│ └── SunNMS.java
├── README.md
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /target/
3 | /pom.xml.versionsBackup
4 | /API/target/
5 | /API/pom.xml.versionsBackup
6 | /Core/target/
7 | /Core/pom.xml.versionsBackup
8 | /NMS/pom.xml.versionsBackup
9 | /NMS/target/
10 | /MC_1_21_4/target/
11 | /MC_1_21_4/pom.xml.versionsBackup
12 | /MC_1_21_5/target/
13 | /MC_1_21_5/pom.xml.versionsBackup
14 | /.paper-nms/
15 |
--------------------------------------------------------------------------------
/API/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | su.nightexpress.sunlight
8 | SunLight
9 | 3.13.2
10 |
11 |
12 | API
13 |
14 |
15 | 21
16 | 21
17 | UTF-8
18 |
19 |
20 |
--------------------------------------------------------------------------------
/API/src/main/java/su/nightexpress/sunlight/api/MenuType.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.api;
2 |
3 | public enum MenuType {
4 | ANVIL,
5 | CRAFTING,
6 | ENCHANTMENT,
7 | GRINDSTONE,
8 | LOOM,
9 | SMITHING,
10 | CARTOGRAPHY,
11 | STONECUTTER;
12 | }
13 |
--------------------------------------------------------------------------------
/API/src/main/java/su/nightexpress/sunlight/api/type/TeleportType.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.api.type;
2 |
3 | public enum TeleportType {
4 | HOME,
5 | WARP,
6 | SPAWN,
7 | PTP,
8 | BACK,
9 | DEATH_BACK,
10 | OTHER
11 | }
12 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/Placeholders.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.util.text.tag.Tags;
5 |
6 | public class Placeholders extends su.nightexpress.nightcore.util.Placeholders {
7 |
8 | public static final String PAPI_AFK_MODE = "%sunlight_afk_mode%";
9 |
10 | @NotNull
11 | public static String listEntry(@NotNull String str) {
12 | return Tags.LIGHT_YELLOW.enclose("●") + " " + Tags.LIGHT_GRAY.enclose(str);
13 | }
14 |
15 | @NotNull
16 | public static String badEntry(@NotNull String str) {
17 | return Tags.LIGHT_RED.enclose("✘") + " " + Tags.LIGHT_GRAY.enclose(str);
18 | }
19 |
20 | @NotNull
21 | public static String goodEntry(@NotNull String str) {
22 | return Tags.LIGHT_GREEN.enclose("✔") + " " + Tags.LIGHT_GRAY.enclose(str);
23 | }
24 |
25 | public static final String GENERIC_MESSAGE = "%message%";
26 | public static final String GENERIC_FORMAT = "%format%";
27 | public static final String GENERIC_COMMAND = "%command%";
28 | public static final String GENERIC_AMOUNT = "%amount%";
29 | public static final String GENERIC_LEVEL = "%level%";
30 | public static final String GENERIC_CURRENT = "%current%";
31 | public static final String GENERIC_MAX = "%max%";
32 | public static final String GENERIC_TICKS = "%ticks%";
33 | public static final String GENERIC_SOURCE = "%source%";
34 | public static final String GENERIC_TARGET = "%target%";
35 | public static final String GENERIC_RESULT = "%result%";
36 | public static final String GENERIC_STATE = "%state%";
37 | public static final String GENERIC_TYPE = "%type%";
38 | public static final String GENERIC_ITEM = "%item%";
39 | public static final String GENERIC_TIME = "%time%";
40 | public static final String GENERIC_NAME = "%name%";
41 | public static final String GENERIC_VALUE = "%value%";
42 | public static final String GENERIC_WORLD = "%world%";
43 | public static final String GENERIC_TOTAL = "%total%";
44 | public static final String GENERIC_GLOBAL = "%global%";
45 | public static final String GENERIC_RADIUS = "%radius%";
46 | public static final String GENERIC_COOLDOWN = "%cooldown%";
47 | public static final String GENERIC_AVAILABLE = "%available%";
48 | }
49 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/SunLightAPI.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import org.jetbrains.annotations.Nullable;
5 | import su.nightexpress.sunlight.module.ModuleManager;
6 | import su.nightexpress.sunlight.module.warmups.WarmupsModule;
7 | import su.nightexpress.sunlight.nms.SunNMS;
8 |
9 | public class SunLightAPI {
10 |
11 | private static SunLightPlugin plugin;
12 |
13 | static void load(@NotNull SunLightPlugin instance) {
14 | plugin = instance;
15 | }
16 |
17 | static void clear() {
18 | plugin = null;
19 | }
20 |
21 | @NotNull
22 | public static SunLightPlugin getPlugin() {
23 | if (plugin == null) throw new IllegalStateException("API is not yet initialized!");
24 |
25 | return plugin;
26 | }
27 |
28 | @NotNull
29 | public static SunNMS getInternals() {
30 | return getPlugin().getSunNMS();
31 | }
32 |
33 | @NotNull
34 | public static ModuleManager getModuleManager() {
35 | return getPlugin().getModuleManager();
36 | }
37 |
38 | @Nullable
39 | public static WarmupsModule getWarmupsModule() {
40 | return getModuleManager().getModule(WarmupsModule.class).orElse(null);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/api/event/PlayerPrivateMessageEvent.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.api.event;
2 |
3 | import org.bukkit.command.CommandSender;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.Event;
6 | import org.bukkit.event.HandlerList;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class PlayerPrivateMessageEvent extends Event implements Cancellable {
10 |
11 | private static final HandlerList handlerList = new HandlerList();
12 |
13 | private final CommandSender sender;
14 | private final CommandSender target;
15 | private final String message;
16 |
17 | private boolean isCancelled;
18 |
19 | public PlayerPrivateMessageEvent(
20 | @NotNull CommandSender sender,
21 | @NotNull CommandSender target,
22 | @NotNull String message
23 | ) {
24 | this.sender = sender;
25 | this.target = target;
26 | this.message = message;
27 | }
28 |
29 | public static HandlerList getHandlerList() {
30 | return handlerList;
31 | }
32 |
33 | @NotNull
34 | @Override
35 | public HandlerList getHandlers() {
36 | return handlerList;
37 | }
38 |
39 | @Override
40 | public boolean isCancelled() {
41 | return isCancelled;
42 | }
43 |
44 | @Override
45 | public void setCancelled(boolean cancelled) {
46 | isCancelled = cancelled;
47 | }
48 |
49 | @NotNull
50 | public CommandSender getSender() {
51 | return this.sender;
52 | }
53 |
54 | @NotNull
55 | public CommandSender getTarget() {
56 | return this.target;
57 | }
58 |
59 | @NotNull
60 | public String getMessage() {
61 | return this.message;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/api/event/PlayerTeleportRequestEvent.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.api.event;
2 |
3 | import org.bukkit.event.Cancellable;
4 | import org.bukkit.event.Event;
5 | import org.bukkit.event.HandlerList;
6 | import org.jetbrains.annotations.NotNull;
7 | import su.nightexpress.sunlight.module.ptp.TeleportRequest;
8 |
9 | public class PlayerTeleportRequestEvent extends Event implements Cancellable {
10 |
11 | private static final HandlerList handlerList = new HandlerList();
12 |
13 | private final TeleportRequest request;
14 |
15 | private boolean isCancelled;
16 |
17 | public PlayerTeleportRequestEvent(@NotNull TeleportRequest request) {
18 | this.request = request;
19 | }
20 |
21 | public static HandlerList getHandlerList() {
22 | return handlerList;
23 | }
24 |
25 | @NotNull
26 | @Override
27 | public HandlerList getHandlers() {
28 | return handlerList;
29 | }
30 |
31 | @Override
32 | public boolean isCancelled() {
33 | return isCancelled;
34 | }
35 |
36 | @NotNull
37 | public TeleportRequest getRequest() {
38 | return this.request;
39 | }
40 |
41 | @Override
42 | public void setCancelled(boolean cancelled) {
43 | this.isCancelled = cancelled;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/CommandConfig.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.config.ConfigValue;
5 | import su.nightexpress.nightcore.util.Lists;
6 | import su.nightexpress.sunlight.Placeholders;
7 | import su.nightexpress.sunlight.command.cooldown.ArgumentPattern;
8 | import su.nightexpress.sunlight.command.cooldown.CommandCooldown;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | public class CommandConfig {
15 |
16 | public static final ConfigValue DEBUG_REGISTER_LOG = ConfigValue.create("Debug.RegisterLog",
17 | false,
18 | "Controls whether command register info will be printed in server console."
19 | );
20 |
21 | public static final ConfigValue UNREGISTER_CONFLICTS = ConfigValue.create("Unregister_Conflicts",
22 | false,
23 | "Sets whether or not commands with similar names/aliases should be unregistered from the server",
24 | "if they're overlaps with the SunLight commands.",
25 | "Warning: Setting this on 'true' may result both positive and negative effects."
26 | );
27 |
28 | @NotNull
29 | public static List getDefaultCooldowns() {
30 | List list = new ArrayList<>();
31 |
32 | CommandCooldown healCooldown = new CommandCooldown(
33 | "heal",
34 | Lists.newSet("heal", "health"),
35 | Lists.newSet(
36 | new ArgumentPattern(Lists.newList(Lists.newSet("heal"))),
37 | new ArgumentPattern(Lists.newList(Lists.newSet("health", "hp"), Lists.newSet("restore")))
38 | ),
39 | Map.of("vip", 60, "gold", 30)
40 | );
41 |
42 | CommandCooldown homeCooldown = new CommandCooldown(
43 | "home",
44 | Lists.newSet("home", "homes"),
45 | Lists.newSet(
46 | new ArgumentPattern(Lists.newList(Lists.newSet("home"))),
47 | new ArgumentPattern(Lists.newList(Lists.newSet("homes"), Lists.newSet("teleport")))
48 | ),
49 | Map.of(Placeholders.DEFAULT, 30, "vip", 0)
50 | );
51 |
52 | list.add(healCooldown);
53 | list.add(homeCooldown);
54 |
55 | return list;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/CommandFlags.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command;
2 |
3 | import org.bukkit.World;
4 | import org.jetbrains.annotations.NotNull;
5 | import su.nightexpress.nightcore.command.experimental.builder.ContentFlagBuilder;
6 | import su.nightexpress.nightcore.command.experimental.builder.SimpleFlagBuilder;
7 | import su.nightexpress.nightcore.command.experimental.flag.FlagTypes;
8 |
9 | public class CommandFlags {
10 |
11 | public static final String SILENT = "s";
12 | public static final String WORLD = "w";
13 |
14 | @NotNull
15 | public static SimpleFlagBuilder silent() {
16 | return FlagTypes.simple(SILENT);
17 | }
18 |
19 | @NotNull
20 | public static ContentFlagBuilder world() {
21 | return FlagTypes.world(WORLD);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/NodeCreator.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.command.experimental.builder.NodeBuilder;
5 | import su.nightexpress.nightcore.config.FileConfig;
6 | import su.nightexpress.sunlight.command.template.CommandTemplate;
7 |
8 | public interface NodeCreator> {
9 |
10 | @NotNull B create(@NotNull CommandTemplate template, @NotNull FileConfig config);
11 | }
12 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/cooldown/ArgumentPattern.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.cooldown;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.util.Lists;
5 |
6 | import java.util.*;
7 |
8 | public class ArgumentPattern {
9 |
10 | public static final String OR = "\\|";
11 | public static final String UNKNOWN_ARGUMENT = "?";
12 |
13 | private final List> arguments;
14 |
15 | public ArgumentPattern(@NotNull List> arguments) {
16 | this.arguments = arguments;
17 | }
18 |
19 | @NotNull
20 | public static ArgumentPattern from(@NotNull String str) {
21 | String[] split = str.split(" ");
22 | List> arguments = new ArrayList<>();
23 |
24 | for (String arg : split) {
25 | Set values = new HashSet<>(Arrays.asList(arg.split(OR)));
26 | arguments.add(Lists.modify(values, String::toLowerCase));
27 | }
28 |
29 | return new ArgumentPattern(arguments);
30 | }
31 |
32 | @NotNull
33 | public String asString() {
34 | StringBuilder builder = new StringBuilder();
35 |
36 | this.arguments.forEach(values -> {
37 | if (!builder.isEmpty()) builder.append(" ");
38 | builder.append(String.join("|", values));
39 | });
40 |
41 | return builder.toString();
42 | }
43 |
44 | public boolean isApplicable(String[] commandLine) {
45 | if (commandLine.length < this.arguments.size()) return false;
46 |
47 | for (int index = 0; index < commandLine.length; index++) {
48 | if (!this.isArgument(commandLine[index], index)) {
49 | return false;
50 | }
51 | }
52 |
53 | return true;
54 | }
55 |
56 | public boolean isArgument(@NotNull String argument, int index) {
57 | if (index >= this.arguments.size()) return false;
58 |
59 | Set values = this.arguments.get(index);
60 |
61 | return values.contains(UNKNOWN_ARGUMENT) || values.contains(argument.toLowerCase());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/list/ReloadCommand.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.list;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.command.experimental.CommandContext;
5 | import su.nightexpress.nightcore.command.experimental.argument.ArgumentTypes;
6 | import su.nightexpress.nightcore.command.experimental.argument.ParsedArguments;
7 | import su.nightexpress.nightcore.command.experimental.node.ChainedNode;
8 | import su.nightexpress.nightcore.command.experimental.node.DirectNode;
9 | import su.nightexpress.sunlight.SunLightPlugin;
10 | import su.nightexpress.sunlight.command.CommandPerms;
11 | import su.nightexpress.sunlight.config.Lang;
12 | import su.nightexpress.sunlight.module.Module;
13 |
14 | public class ReloadCommand {
15 |
16 | // TODO Better fields + locale
17 |
18 | public static void inject(@NotNull SunLightPlugin plugin, @NotNull ChainedNode node) {
19 | node.addChildren(DirectNode.builder(plugin, "reload")
20 | .permission(CommandPerms.RELOAD)
21 | .description("Reload the plugin or module.")
22 | .withArgument(ArgumentTypes.string("module").withSamples(tabContext -> plugin.getModuleManager().getModules().stream().map(Module::getId).toList()))
23 | .executes((context, arguments) -> execute(plugin, context, arguments))
24 | );
25 | }
26 |
27 | public static boolean execute(@NotNull SunLightPlugin plugin, @NotNull CommandContext context, @NotNull ParsedArguments arguments) {
28 | if (arguments.hasArgument("module")) {
29 | String moduleId = arguments.getStringArgument("module");
30 | Module module = plugin.getModuleManager().getModule(moduleId);
31 | if (module != null) {
32 | plugin.getLang().reload();
33 | module.getConfig().reload();
34 | module.reload();
35 | context.send(module.getName() + " reloaded.");
36 | }
37 | }
38 | else {
39 | plugin.reload();
40 | context.send(Lang.COMMAND_RELOAD_DONE.getMessage(plugin));
41 | }
42 |
43 | return true;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/list/SuicideCommand.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.list;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.jetbrains.annotations.NotNull;
5 | import su.nightexpress.nightcore.command.experimental.CommandContext;
6 | import su.nightexpress.nightcore.command.experimental.argument.ParsedArguments;
7 | import su.nightexpress.nightcore.command.experimental.builder.DirectNodeBuilder;
8 | import su.nightexpress.nightcore.command.experimental.node.DirectNode;
9 | import su.nightexpress.nightcore.config.FileConfig;
10 | import su.nightexpress.sunlight.command.CommandPerms;
11 | import su.nightexpress.sunlight.command.CommandRegistry;
12 | import su.nightexpress.sunlight.command.template.CommandTemplate;
13 | import su.nightexpress.sunlight.Placeholders;
14 | import su.nightexpress.sunlight.SunLightPlugin;
15 | import su.nightexpress.sunlight.config.Lang;
16 |
17 | public class SuicideCommand {
18 |
19 | public static final String NODE = "suicide";
20 |
21 | public static void load(@NotNull SunLightPlugin plugin) {
22 | CommandRegistry.registerDirectExecutor(NODE, (template, config) -> builder(plugin, template, config));
23 |
24 | CommandRegistry.addSimpleTemplate(NODE);
25 | }
26 |
27 | @NotNull
28 | public static DirectNodeBuilder builder(@NotNull SunLightPlugin plugin, @NotNull CommandTemplate template, @NotNull FileConfig config) {
29 | return DirectNode.builder(plugin, template.getAliases())
30 | .playerOnly()
31 | .description(Lang.COMMAND_SUICIDE_DESC)
32 | .permission(CommandPerms.SUICIDE)
33 | .executes((context, arguments) -> execute(plugin, context, arguments))
34 | ;
35 | }
36 |
37 | public static boolean execute(@NotNull SunLightPlugin plugin, @NotNull CommandContext context, @NotNull ParsedArguments arguments) {
38 | Player target = context.getPlayerOrThrow();
39 | target.setHealth(0);
40 | Lang.COMMAND_SUICIDE_DONE.getMessage().replace(Placeholders.forPlayer(target)).broadcast();
41 | return true;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/mode/ModifyMode.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.mode;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.function.BiFunction;
6 |
7 | public enum ModifyMode {
8 |
9 | ADD(Double::sum),
10 | SET((in, amount) -> amount),
11 | REMOVE((in, amount) -> in - amount);
12 |
13 | private final BiFunction function;
14 |
15 | ModifyMode(@NotNull BiFunction function) {
16 | this.function = function;
17 | }
18 |
19 | public double modify(double input, double amount) {
20 | return this.function.apply(input, amount);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/mode/ToggleMode.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.mode;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.function.Function;
6 |
7 | public enum ToggleMode {
8 |
9 | ON(in -> true),
10 | OFF(in -> false),
11 | TOGGLE(in -> !in);
12 |
13 | private final Function function;
14 |
15 | ToggleMode(@NotNull Function function) {
16 | this.function = function;
17 | }
18 |
19 | public boolean apply(boolean input) {
20 | return this.function.apply(input);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/template/CommandTemplate.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.template;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.config.FileConfig;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Arrays;
8 | import java.util.List;
9 | import java.util.function.Consumer;
10 |
11 | public abstract class CommandTemplate {
12 |
13 | protected final String[] aliases;
14 |
15 | public CommandTemplate(@NotNull String[] aliases) {
16 | this.aliases = aliases;
17 | }
18 |
19 | public static DirectCommandTemplate direct(@NotNull String[] aliases, @NotNull String nodeId) {
20 | return DirectCommandTemplate.create(aliases, nodeId);
21 | }
22 |
23 | public static GroupCommandTemplate group(@NotNull String[] aliases,
24 | @NotNull String description,
25 | @NotNull String permission,
26 | DirectCommandTemplate... templates) {
27 | return GroupCommandTemplate.create(aliases, description, permission, Arrays.asList(templates));
28 | }
29 |
30 | public static GroupCommandTemplate group(@NotNull String[] aliases,
31 | @NotNull String description,
32 | @NotNull String permission,
33 | @NotNull Consumer> consumer) {
34 | List templates = new ArrayList<>();
35 | consumer.accept(templates);
36 |
37 | return GroupCommandTemplate.create(aliases, description, permission, templates);
38 | }
39 |
40 | public abstract void write(@NotNull FileConfig config, @NotNull String path);
41 |
42 | @NotNull
43 | public String[] getAliases() {
44 | return aliases;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/command/template/DirectCommandTemplate.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.command.template;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.config.ConfigValue;
5 | import su.nightexpress.nightcore.config.FileConfig;
6 |
7 | public class DirectCommandTemplate extends CommandTemplate {
8 |
9 | private final String nodeId;
10 | private final boolean fallback;
11 |
12 | public DirectCommandTemplate(@NotNull String[] aliases, @NotNull String nodeId, boolean fallback) {
13 | super(aliases);
14 | this.nodeId = nodeId;
15 | this.fallback = fallback;
16 | }
17 |
18 | @NotNull
19 | public static DirectCommandTemplate create(@NotNull String[] aliases, @NotNull String nodeId) {
20 | return new DirectCommandTemplate(aliases, nodeId, false);
21 | }
22 |
23 | @NotNull
24 | public static DirectCommandTemplate read(@NotNull FileConfig config, @NotNull String path) {
25 | String[] aliases = ConfigValue.create(path + ".Aliases", new String[0]).read(config);
26 | String nodeId = ConfigValue.create(path + ".Executor", "null").read(config);
27 | boolean fallback = ConfigValue.create(path + ".Fallback", false).read(config);
28 |
29 | return new DirectCommandTemplate(aliases, nodeId, fallback);
30 | }
31 |
32 | public void write(@NotNull FileConfig config, @NotNull String path) {
33 | config.set(path + ".Aliases", String.join(",", this.aliases));
34 | config.set(path + ".Executor", this.nodeId);
35 | config.set(path + ".Fallback", this.fallback);
36 | }
37 |
38 | @NotNull
39 | public String getNodeId() {
40 | return nodeId;
41 | }
42 |
43 | public boolean isFallback() {
44 | return fallback;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/config/Config.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.config;
2 |
3 | import su.nightexpress.nightcore.config.ConfigValue;
4 | import su.nightexpress.sunlight.utils.SunUtils;
5 |
6 | public class Config {
7 |
8 | public static final String DIR_MENU = "/menu/";
9 |
10 | public static final ConfigValue GENERAL_DATE_FORMAT = ConfigValue.create("General.Date_Format",
11 | "dd/MM/yyyy HH:mm:ss",
12 | "Sets the global date format used in various plugin modules."
13 | ).whenRead(SunUtils::setDateFormatter);
14 |
15 | public static final ConfigValue GENERAL_TIME_FORMAT = ConfigValue.create("General.Time_Format",
16 | "HH:mm:ss",
17 | "Sets the global time format used in various plugin modules."
18 | ).whenRead(SunUtils::setTimeFormatter);
19 |
20 | public static final ConfigValue CONSOLE_NAME = ConfigValue.create("General.ConsoleName",
21 | "Console",
22 | "Sets name for the console command sender.",
23 | "Used in some messages when you send private messages, execute bans, and other actions from console."
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/config/Perms.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.config;
2 |
3 | import su.nightexpress.nightcore.util.wrapper.UniPermission;
4 | import su.nightexpress.sunlight.Placeholders;
5 |
6 | public class Perms {
7 |
8 | public static final String PREFIX = "sunlight.";
9 | public static final String PREFIX_COMMAND = PREFIX + "command.";
10 | public static final String PREFIX_BYPASS = PREFIX + "bypass.";
11 |
12 | public static final UniPermission PLUGIN = new UniPermission(PREFIX + Placeholders.WILDCARD);
13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD);
14 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD);
15 |
16 | public static final UniPermission BYPASS_COMMAND_COOLDOWN = new UniPermission(PREFIX_BYPASS + "command.cooldown");
17 | public static final UniPermission BYPASS_TELEPORT_REQUESTS_DISABLED = new UniPermission(PREFIX_BYPASS + "teleport.requests.disabled");
18 | public static final UniPermission BYPASS_IGNORE_PM = new UniPermission(PREFIX_BYPASS + "ignore.pm");
19 | public static final UniPermission BYPASS_IGNORE_TELEPORTS = new UniPermission(PREFIX_BYPASS + "ignore.teleports");
20 |
21 |
22 | static {
23 | PLUGIN.addChildren(COMMAND, BYPASS);
24 |
25 | BYPASS.addChildren(
26 | BYPASS_COMMAND_COOLDOWN,
27 | BYPASS_TELEPORT_REQUESTS_DISABLED,
28 | BYPASS_IGNORE_PM, BYPASS_IGNORE_TELEPORTS
29 | );
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/CoreManager.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.jetbrains.annotations.NotNull;
5 | import su.nightexpress.nightcore.manager.AbstractManager;
6 | import su.nightexpress.nightcore.util.CommandUtil;
7 | import su.nightexpress.nightcore.util.TimeUtil;
8 | import su.nightexpress.sunlight.Placeholders;
9 | import su.nightexpress.sunlight.SunLightPlugin;
10 | import su.nightexpress.sunlight.command.CommandRegistry;
11 | import su.nightexpress.sunlight.command.cooldown.CommandCooldown;
12 | import su.nightexpress.sunlight.config.Lang;
13 | import su.nightexpress.sunlight.config.Perms;
14 | import su.nightexpress.sunlight.core.cooldown.CooldownInfo;
15 | import su.nightexpress.sunlight.core.listener.CoreListener;
16 | import su.nightexpress.sunlight.data.user.SunUser;
17 |
18 | public class CoreManager extends AbstractManager {
19 |
20 | public CoreManager(@NotNull SunLightPlugin plugin) {
21 | super(plugin);
22 | }
23 |
24 | @Override
25 | protected void onLoad() {
26 | this.addListener(new CoreListener(this.plugin));
27 | }
28 |
29 | @Override
30 | protected void onShutdown() {
31 |
32 | }
33 |
34 | public boolean checkCommandCooldown(@NotNull Player player, @NotNull String commandMessage) {
35 | if (player.hasPermission(Perms.BYPASS_COMMAND_COOLDOWN)) return true;
36 |
37 | String commandName = CommandUtil.getCommandName(commandMessage);
38 |
39 | CommandCooldown cooldown = CommandRegistry.getCooldown(commandName);
40 | if (cooldown == null || !cooldown.isApplicable(commandName, commandMessage)) return true;
41 |
42 | SunUser user = plugin.getUserManager().getUserData(player);
43 |
44 | CooldownInfo cooldownInfo = user.getCooldown(cooldown).orElse(null);
45 | if (cooldownInfo != null) {
46 | long expireDate = cooldownInfo.getExpireDate();
47 | String time = TimeUtil.formatDuration(expireDate);
48 |
49 | (expireDate < 0 ? Lang.CORE_COMMAND_COOLDOWN_ONE_TIME : Lang.CORE_COMMAND_COOLDOWN_DEFAULT).getMessage()
50 | .replace(Placeholders.GENERIC_TIME, time).replace(Placeholders.GENERIC_COMMAND, commandMessage)
51 | .send(player);
52 | return false;
53 | }
54 |
55 | int seconds = cooldown.getCooldown(player);
56 | if (seconds == 0) return true;
57 |
58 | user.addCooldown(CooldownInfo.of(cooldown, seconds));
59 | this.plugin.getUserManager().scheduleSave(user);
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/cooldown/CooldownInfo.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.cooldown;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.sunlight.command.cooldown.CommandCooldown;
5 | import su.nightexpress.sunlight.module.kits.Kit;
6 | import su.nightexpress.sunlight.module.warps.impl.Warp;
7 |
8 | public class CooldownInfo {
9 |
10 | private final CooldownType type;
11 | private final String objectId;
12 | private final long expireDate;
13 |
14 | public CooldownInfo(@NotNull CooldownType type, @NotNull String objectId, long expireDate) {
15 | this.type = type;
16 | this.objectId = objectId.toLowerCase();
17 | this.expireDate = expireDate;
18 | }
19 |
20 | @NotNull
21 | public static CooldownInfo of(@NotNull Kit kit) {
22 | long expireDate = kit.getCooldown() < 0 ? -1L : System.currentTimeMillis() + kit.getCooldown() * 1000L;
23 | return new CooldownInfo(CooldownType.KIT, kit.getId(), expireDate);
24 | }
25 |
26 | @NotNull
27 | public static CooldownInfo of(@NotNull Warp warp) {
28 | return new CooldownInfo(CooldownType.WARP, warp.getId(), System.currentTimeMillis() + warp.getVisitCooldown() * 1000L);
29 | }
30 |
31 | @NotNull
32 | public static CooldownInfo of(@NotNull CommandCooldown command, int cooldown) {
33 | return new CooldownInfo(CooldownType.COMMAND, command.getId(), System.currentTimeMillis() + cooldown * 1000L);
34 | }
35 |
36 | public boolean isSimilar(@NotNull CooldownInfo other) {
37 | return this.isSimilar(other.getObjectId());
38 | }
39 |
40 | public boolean isSimilar(@NotNull String otherId) {
41 | return this.getObjectId().equalsIgnoreCase(otherId);
42 | }
43 |
44 | public boolean isPermanent() {
45 | return this.getExpireDate() < 0L;
46 | }
47 |
48 | public boolean isExpired() {
49 | return !this.isPermanent() && System.currentTimeMillis() >= this.getExpireDate();
50 | }
51 |
52 | @NotNull
53 | public CooldownType getType() {
54 | return type;
55 | }
56 |
57 | @NotNull
58 | public String getObjectId() {
59 | return objectId;
60 | }
61 |
62 | public long getExpireDate() {
63 | return expireDate;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/cooldown/CooldownType.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.cooldown;
2 |
3 | public enum CooldownType {
4 | COMMAND, KIT, WARP
5 | }
6 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/user/settings/Parser.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.user.settings;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.util.NumberUtil;
5 |
6 | import java.util.function.Function;
7 |
8 | public interface Parser {
9 |
10 | @NotNull T fromString(@NotNull String string);
11 |
12 | @NotNull String toString(@NotNull Object value);
13 |
14 | @NotNull
15 | static Parser simple(@NotNull Function parser) {
16 |
17 | return new Parser<>() {
18 | @Override
19 | @NotNull
20 | public T fromString(@NotNull String string) {
21 | return parser.apply(string);
22 | }
23 |
24 | @Override
25 | @NotNull
26 | public String toString(@NotNull Object value) {
27 | return String.valueOf(value);
28 | }
29 | };
30 |
31 | }
32 |
33 | Parser BOOLEAN = simple(Boolean::parseBoolean);
34 |
35 | Parser INTEGER = simple(string -> NumberUtil.getAnyInteger(string, 0));
36 |
37 | Parser INTEGER_ABS = simple(string -> NumberUtil.getInteger(string, 0));
38 |
39 | Parser DOUBLE = simple(string -> NumberUtil.getAnyDouble(string, 0));
40 |
41 | Parser DOUBLE_ABS = simple(string -> NumberUtil.getDouble(string, 0));
42 |
43 | Parser LONG = simple(string -> (long) NumberUtil.getAnyInteger(string, 0));
44 |
45 | Parser LONG_ABS = simple(string -> (long) NumberUtil.getInteger(string, 0));
46 |
47 | Parser STRING = simple(string -> string);
48 | }
49 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/user/settings/Setting.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.user.settings;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | public class Setting {
6 |
7 | private final String name;
8 | private final Class clazz;
9 | private final T defaultValue;
10 | private final Parser parser;
11 | private final boolean persistent;
12 |
13 | public Setting(@NotNull String name, @NotNull Class clazz, @NotNull T defaultValue, @NotNull Parser parser, boolean persistent) {
14 | this.name = name.toLowerCase().replace(" ", "_");
15 | this.clazz = clazz;
16 | this.defaultValue = defaultValue;
17 | this.parser = parser;
18 | this.persistent = persistent;
19 | }
20 |
21 | @NotNull
22 | public static Setting create(@NotNull String name, @NotNull Boolean defaultValue, boolean persistent) {
23 | return new Setting<>(name, Boolean.class, defaultValue, Parser.BOOLEAN, persistent);
24 | }
25 |
26 | @NotNull
27 | public static Setting create(@NotNull String name, @NotNull Integer defaultValue, boolean persistent) {
28 | return new Setting<>(name, Integer.class, defaultValue, Parser.INTEGER, persistent);
29 | }
30 |
31 | @NotNull
32 | public static Setting create(@NotNull String name, @NotNull Long defaultValue, boolean persistent) {
33 | return new Setting<>(name, Long.class, defaultValue, Parser.LONG, persistent);
34 | }
35 |
36 | @NotNull
37 | public static Setting create(@NotNull String name, @NotNull String defaultValue, boolean persistent) {
38 | return new Setting<>(name, String.class, defaultValue, Parser.STRING, persistent);
39 | }
40 |
41 | @NotNull
42 | public T fromString(@NotNull String string) {
43 | return this.parser.fromString(string);
44 | }
45 |
46 | @NotNull
47 | public String toString(@NotNull Object value) {
48 | return this.parser.toString(value);
49 | }
50 |
51 | @NotNull
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | @NotNull
57 | public Class getClazz() {
58 | return clazz;
59 | }
60 |
61 | @NotNull
62 | public Parser getParser() {
63 | return parser;
64 | }
65 |
66 | @NotNull
67 | public T getDefaultValue() {
68 | return defaultValue;
69 | }
70 |
71 | public boolean isPersistent() {
72 | return persistent;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/user/settings/SettingRegistry.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.user.settings;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import org.jetbrains.annotations.Nullable;
5 |
6 | import java.util.Collection;
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | public class SettingRegistry {
11 |
12 | private static final Map> REGISTRY = new HashMap<>();
13 |
14 | public static final Setting CUSTOM_NAME = register(Setting.create("custom_name", "", true));
15 | public static final Setting ACCEPT_PM = register(Setting.create("accept_pm", true, true));
16 |
17 | @NotNull
18 | public static Setting register(@NotNull String name, @NotNull Class clazz, @NotNull T defaultValue, @NotNull Parser parser, boolean persistent) {
19 | return register(new Setting<>(name, clazz, defaultValue, parser, persistent));
20 | }
21 |
22 | @NotNull
23 | public static Setting register(@NotNull Setting setting) {
24 | REGISTRY.put(setting.getName(), setting);
25 | return setting;
26 | }
27 |
28 | @Nullable
29 | public static Setting> getByName(@NotNull String name) {
30 | return REGISTRY.get(name);
31 | }
32 |
33 | @NotNull
34 | public static Collection> values() {
35 | return REGISTRY.values();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/core/user/settings/SettingValue.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.core.user.settings;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | public class SettingValue {
6 |
7 | private final T value;
8 |
9 | public SettingValue(@NotNull T value) {
10 | this.value = value;
11 | }
12 |
13 | @NotNull
14 | public static SettingValue of(@NotNull T value) {
15 | return new SettingValue<>(value);
16 | }
17 |
18 | @NotNull
19 | public T getValue() {
20 | return value;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/data/UserManager.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.data;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import su.nightexpress.nightcore.database.AbstractUserManager;
5 | import su.nightexpress.sunlight.SunLightPlugin;
6 | import su.nightexpress.sunlight.core.menu.IgnoreListMenu;
7 | import su.nightexpress.sunlight.core.menu.IgnoreSettingsMenu;
8 | import su.nightexpress.sunlight.data.user.SunUser;
9 |
10 | import java.util.UUID;
11 |
12 | public class UserManager extends AbstractUserManager {
13 |
14 | private IgnoreListMenu ignoreListMenu;
15 | private IgnoreSettingsMenu ignoreSettingsMenu;
16 |
17 | public UserManager(@NotNull SunLightPlugin plugin) {
18 | super(plugin);
19 | }
20 |
21 | @Override
22 | protected void onLoad() {
23 | super.onLoad();
24 |
25 | this.ignoreListMenu = new IgnoreListMenu(this.plugin);
26 | this.ignoreSettingsMenu = new IgnoreSettingsMenu(this.plugin);
27 | }
28 |
29 | @Override
30 | protected void onShutdown() {
31 | super.onShutdown();
32 | this.ignoreListMenu.clear();
33 | this.ignoreSettingsMenu.clear();
34 | }
35 |
36 | @Override
37 | @NotNull
38 | public SunUser createUserData(@NotNull UUID uuid, @NotNull String name) {
39 | return SunUser.create(this.plugin, uuid, name);
40 | }
41 |
42 | @NotNull
43 | @Deprecated
44 | public IgnoreListMenu getIgnoreListMenu() {
45 | return ignoreListMenu;
46 | }
47 |
48 | @NotNull
49 | @Deprecated
50 | public IgnoreSettingsMenu getIgnoreSettingsMenu() {
51 | return ignoreSettingsMenu;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/data/serialize/CooldownSerializer.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.data.serialize;
2 |
3 | import com.google.gson.*;
4 | import su.nightexpress.nightcore.util.StringUtil;
5 | import su.nightexpress.sunlight.core.cooldown.CooldownInfo;
6 | import su.nightexpress.sunlight.core.cooldown.CooldownType;
7 |
8 | import java.lang.reflect.Type;
9 |
10 | public class CooldownSerializer implements JsonSerializer, JsonDeserializer {
11 |
12 | @Override
13 | public CooldownInfo deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
14 | JsonObject object = element.getAsJsonObject();
15 |
16 | CooldownType cooldownType = StringUtil.getEnum(object.get("type").getAsString(), CooldownType.class).orElse(null);
17 | if (cooldownType == null) return null;
18 |
19 | String objectId = object.get("objectId").getAsString();
20 | long expireDate = object.get("expireDate").getAsLong();
21 |
22 | return new CooldownInfo(cooldownType, objectId, expireDate);
23 | }
24 |
25 | @Override
26 | public JsonElement serialize(CooldownInfo info, Type type, JsonSerializationContext context) {
27 | JsonObject object = new JsonObject();
28 | object.addProperty("type", info.getType().name());
29 | object.addProperty("objectId", info.getObjectId());
30 | object.addProperty("expireDate", info.getExpireDate());
31 | return object;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/data/serialize/IgnoredUserSerializer.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.data.serialize;
2 |
3 | import com.google.gson.*;
4 | import com.google.gson.reflect.TypeToken;
5 | import su.nightexpress.sunlight.core.user.IgnoredUser;
6 | import su.nightexpress.sunlight.utils.UserInfo;
7 |
8 | import java.lang.reflect.Type;
9 |
10 | public class IgnoredUserSerializer implements JsonSerializer, JsonDeserializer {
11 |
12 | @Override
13 | public IgnoredUser deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
14 | JsonObject object = element.getAsJsonObject();
15 | if (!object.has("userInfo")) return null;
16 |
17 | UserInfo userInfo = context.deserialize(object.get("userInfo"), new TypeToken(){}.getType());
18 | boolean ignoreChat = object.get("ignoreChat").getAsBoolean();
19 | boolean ignoreConversation = object.get("ignoreConversation").getAsBoolean();
20 | boolean ignoreTeleports = object.get("ignoreTeleports").getAsBoolean();
21 |
22 | return new IgnoredUser(userInfo, ignoreChat, ignoreConversation, ignoreTeleports);
23 | }
24 |
25 | @Override
26 | public JsonElement serialize(IgnoredUser ignoredUser, Type type, JsonSerializationContext context) {
27 | JsonObject object = new JsonObject();
28 | object.add("userInfo", context.serialize(ignoredUser.getUserInfo()));
29 | object.addProperty("ignoreChat", ignoredUser.isHideChatMessages());
30 | object.addProperty("ignoreConversation", ignoredUser.isDenyConversations());
31 | object.addProperty("ignoreTeleports", ignoredUser.isDenyTeleports());
32 | return object;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/data/serialize/UserInfoSerializer.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.data.serialize;
2 |
3 | import com.google.gson.*;
4 | import su.nightexpress.sunlight.utils.UserInfo;
5 |
6 | import java.lang.reflect.Type;
7 | import java.util.UUID;
8 |
9 | public class UserInfoSerializer implements JsonSerializer, JsonDeserializer {
10 |
11 | @Override
12 | public UserInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
13 | JsonObject object = json.getAsJsonObject();
14 |
15 | UUID id = UUID.fromString(object.get("id").getAsString());
16 | String name = object.get("name").getAsString();
17 |
18 | return new UserInfo(id, name);
19 | }
20 |
21 | @Override
22 | public JsonElement serialize(UserInfo userInfo, Type typeOfSrc, JsonSerializationContext context) {
23 | JsonObject object = new JsonObject();
24 |
25 | object.addProperty("id", userInfo.getId().toString());
26 | object.addProperty("name", userInfo.getName());
27 |
28 | return object;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Core/src/main/java/su/nightexpress/sunlight/data/serialize/UserSettingsSerializer.java:
--------------------------------------------------------------------------------
1 | package su.nightexpress.sunlight.data.serialize;
2 |
3 | import com.google.gson.*;
4 | import com.google.gson.reflect.TypeToken;
5 | import su.nightexpress.sunlight.core.user.settings.SettingValue;
6 | import su.nightexpress.sunlight.core.user.settings.Setting;
7 | import su.nightexpress.sunlight.data.user.UserSettings;
8 | import su.nightexpress.sunlight.core.user.settings.SettingRegistry;
9 |
10 | import java.lang.reflect.Type;
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | public class UserSettingsSerializer implements JsonSerializer, JsonDeserializer {
15 |
16 | @Override
17 | public UserSettings deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
18 | JsonObject object = json.getAsJsonObject();
19 |
20 | Map settings = context.deserialize(object.get("settings"), new TypeToken