├── .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>(){}.getType()); 21 | if (settings == null) settings = new HashMap<>(); 22 | 23 | Map> settingsReal = new HashMap<>(); 24 | settings.forEach((name, valueRaw) -> { 25 | Setting setting = SettingRegistry.getByName(name); 26 | if (setting == null) return; 27 | 28 | settingsReal.put(setting.getName(), SettingValue.of(setting.fromString(valueRaw))); 29 | }); 30 | 31 | return new UserSettings(settingsReal); 32 | } 33 | 34 | @Override 35 | public JsonElement serialize(UserSettings settings, Type type, JsonSerializationContext context) { 36 | JsonObject object = new JsonObject(); 37 | Map settingsRaw = new HashMap<>(); 38 | 39 | settings.getValues().forEach((name, value) -> { 40 | Setting setting = SettingRegistry.getByName(name); 41 | if (setting == null || !setting.isPersistent()) return; 42 | 43 | settingsRaw.put(setting.getName(), setting.toString(value.getValue())); 44 | }); 45 | 46 | object.add("settings", context.serialize(settingsRaw)); 47 | return object; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/data/user/UserSettings.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.data.user; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.sunlight.core.user.settings.Setting; 5 | import su.nightexpress.sunlight.core.user.settings.SettingValue; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | public class UserSettings { 11 | 12 | private final Map> values; 13 | 14 | public UserSettings() { 15 | this(new HashMap<>()); 16 | } 17 | 18 | public UserSettings(@NotNull Map> values) { 19 | this.values = values; 20 | } 21 | 22 | @NotNull 23 | public Map> getValues() { 24 | return values; 25 | } 26 | 27 | public boolean has(@NotNull Setting setting) { 28 | return this.values.containsKey(setting.getName()); 29 | } 30 | 31 | public void set(@NotNull Setting setting, @NotNull T value) { 32 | this.values.put(setting.getName(), SettingValue.of(value)); 33 | } 34 | 35 | @NotNull 36 | public T get(@NotNull Setting setting) { 37 | return this.get(setting.getName(), setting.getClazz(), setting.getDefaultValue()); 38 | } 39 | 40 | @NotNull 41 | public T get(@NotNull String name, @NotNull Class clazz, @NotNull T defaultValue) { 42 | name = name.toLowerCase(); 43 | 44 | SettingValue value = this.values.getOrDefault(name, SettingValue.of(defaultValue)); 45 | 46 | Object result = value.getValue(); 47 | if (clazz.isAssignableFrom(result.getClass())) { 48 | return clazz.cast(result); 49 | } 50 | else { 51 | throw new IllegalArgumentException("Setting '" + name + "' is defined as " + result.getClass().getSimpleName() + ", not " + clazz.getSimpleName()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/hook/HookId.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.hook; 2 | 3 | import su.nightexpress.nightcore.util.Plugins; 4 | 5 | public class HookId { 6 | 7 | public static final String PROTOCOL_LIB = "ProtocolLib"; 8 | public static final String PACKET_EVENTS = "packetevents"; 9 | public static final String DISCORD_SRV = "DiscordSRV"; 10 | 11 | public static boolean hasDiscordSRV() { 12 | return Plugins.isInstalled(DISCORD_SRV); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ModuleId.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module; 2 | 3 | public class ModuleId { 4 | 5 | public static final String AFK = "afk"; 6 | public static final String BANS = "bans"; 7 | public static final String BACK_LOCATION = "back_location"; 8 | public static final String CHAT = "chat"; 9 | public static final String CUSTOM_TEXT = "custom_text"; 10 | public static final String EXTRAS = "extras"; 11 | public static final String GOD_MODE = "godmode"; 12 | public static final String MENU = "menu"; 13 | public static final String NERF_PHANTOMS = "nerf_phantoms"; 14 | public static final String HOMES = "homes"; 15 | public static final String KITS = "kits"; 16 | public static final String PTP = "ptp"; 17 | public static final String RTP = "rtp"; 18 | public static final String SCOREBOARD = "scoreboard"; 19 | public static final String SPAWNS = "spawns"; 20 | public static final String TAB = "tab"; 21 | public static final String VANISH = "vanish"; 22 | public static final String WARMUPS = "warmups"; 23 | public static final String WARPS = "warps"; 24 | public static final String WORLDS = "worlds"; 25 | } 26 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ModuleInfo.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | public class ModuleInfo { 6 | 7 | private Class configClass; 8 | private Class langClass; 9 | private Class permissionsClass; 10 | 11 | public ModuleInfo() { 12 | 13 | } 14 | 15 | @Nullable 16 | public Class getConfigClass() { 17 | return configClass; 18 | } 19 | 20 | public ModuleInfo setConfigClass(@Nullable Class configClass) { 21 | this.configClass = configClass; 22 | return this; 23 | } 24 | 25 | @Nullable 26 | public Class getLangClass() { 27 | return langClass; 28 | } 29 | 30 | public ModuleInfo setLangClass(@Nullable Class langClass) { 31 | this.langClass = langClass; 32 | return this; 33 | } 34 | 35 | @Nullable 36 | public Class getPermissionsClass() { 37 | return permissionsClass; 38 | } 39 | 40 | public ModuleInfo setPermissionsClass(@Nullable Class permissionsClass) { 41 | this.permissionsClass = permissionsClass; 42 | return this; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/afk/config/AfkLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.afk.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | 6 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 7 | import static su.nightexpress.sunlight.Placeholders.*; 8 | 9 | public class AfkLang { 10 | 11 | public static final LangString COMMAND_AFK_DESC = LangString.of("Afk.Command.Afk.Desc", "Toggle AFK mode."); 12 | 13 | public static final LangText COMMAND_AFK_DONE_OTHERS = LangText.of("Afk.Command.Afk.Done.Others", 14 | LIGHT_GRAY.wrap("Set " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + " afk mode: " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".")); 15 | 16 | public static final LangText AFK_ENTER = LangText.of("Afk.Mode.Enter", 17 | TAG_NO_PREFIX, 18 | LIGHT_GRAY.wrap("Player " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + " is AFK now.") 19 | ); 20 | 21 | public static final LangText AFK_EXIT = LangText.of("Afk.Mode.Exit", 22 | TAG_NO_PREFIX, 23 | LIGHT_GRAY.wrap("Player " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + " returned after " + LIGHT_YELLOW.wrap(GENERIC_TIME) + " of afk.") 24 | ); 25 | 26 | public static final LangText AFK_NOTIFY_PM = LangText.of("Afk.Notify.PrivateMessage", 27 | TAG_NO_PREFIX, 28 | LIGHT_GRAY.wrap("Player " + LIGHT_RED.wrap(PLAYER_DISPLAY_NAME) + " is AFK and may not respond.") 29 | ); 30 | 31 | public static final LangText AFK_NOTIFY_TELEPORT = LangText.of("Afk.Notify.TeleportRequest", 32 | TAG_NO_PREFIX, 33 | LIGHT_GRAY.wrap("Player " + LIGHT_RED.wrap(PLAYER_DISPLAY_NAME) + " is AFK and may not respond.") 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/afk/config/AfkPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.afk.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.config.Perms; 5 | import su.nightexpress.sunlight.Placeholders; 6 | 7 | public class AfkPerms { 8 | 9 | private static final String PREFIX = Perms.PREFIX + "afk."; 10 | private static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 14 | 15 | public static final UniPermission COMMAND_AFK = new UniPermission(PREFIX_COMMAND + "afk"); 16 | public static final UniPermission COMMAND_AFK_OTHERS = new UniPermission(PREFIX_COMMAND + "afk.others"); 17 | 18 | static { 19 | Perms.PLUGIN.addChildren(MODULE); 20 | 21 | MODULE.addChildren(COMMAND); 22 | 23 | COMMAND.addChildren(COMMAND_AFK, COMMAND_AFK_OTHERS); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/afk/event/PlayerAfkEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.afk.event; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import su.nightexpress.sunlight.module.afk.AfkState; 9 | 10 | public class PlayerAfkEvent extends Event { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final Player player; 15 | private final AfkState state; 16 | 17 | public PlayerAfkEvent(@NotNull Player player, @NotNull AfkState state) { 18 | super(!Bukkit.isPrimaryThread()); 19 | this.player = player; 20 | this.state = state; 21 | } 22 | 23 | public static HandlerList getHandlerList() { 24 | return HANDLER_LIST; 25 | } 26 | 27 | @NotNull 28 | @Override 29 | public HandlerList getHandlers() { 30 | return HANDLER_LIST; 31 | } 32 | 33 | @NotNull 34 | public Player getPlayer() { 35 | return this.player; 36 | } 37 | 38 | @NotNull 39 | public AfkState getState() { 40 | return state; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/backlocation/config/BackLocationPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.backlocation.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class BackLocationPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "backlocation."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 15 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 16 | 17 | public static final UniPermission COMMAND_BACK = new UniPermission(PREFIX_COMMAND + "back"); 18 | public static final UniPermission COMMAND_BACK_OTHERS = new UniPermission(PREFIX_COMMAND + "back.others"); 19 | public static final UniPermission COMMAND_DEATHBACK = new UniPermission(PREFIX_COMMAND + "deathback"); 20 | public static final UniPermission COMMAND_DEATHBACK_OTHERS = new UniPermission(PREFIX_COMMAND + "deathback.others"); 21 | 22 | public static final UniPermission BYPASS_PREVIOUS_WORLDS = new UniPermission(PREFIX_BYPASS + "previous.worlds"); 23 | public static final UniPermission BYPASS_PREVIOUS_CAUSES = new UniPermission(PREFIX_BYPASS + "previous.causes"); 24 | public static final UniPermission BYPASS_DEATH_WORLDS = new UniPermission(PREFIX_BYPASS + "death.worlds"); 25 | 26 | static { 27 | Perms.PLUGIN.addChildren(MODULE); 28 | 29 | MODULE.addChildren(COMMAND, BYPASS); 30 | 31 | COMMAND.addChildren( 32 | COMMAND_BACK, COMMAND_BACK_OTHERS, 33 | COMMAND_DEATHBACK, COMMAND_DEATHBACK_OTHERS 34 | ); 35 | 36 | BYPASS.addChildren( 37 | BYPASS_PREVIOUS_CAUSES, BYPASS_PREVIOUS_WORLDS, 38 | BYPASS_DEATH_WORLDS 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/backlocation/data/LocationType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.backlocation.data; 2 | 3 | public enum LocationType { 4 | PREVIOUS, DEATH 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/backlocation/data/StoredLocation.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.backlocation.data; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.World; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.concurrent.TimeUnit; 10 | 11 | public class StoredLocation { 12 | 13 | private final String worldName; 14 | //private final BlockPos blockPos; 15 | private final double x; 16 | private final double y; 17 | private final double z; 18 | private final long expireDate; 19 | 20 | public StoredLocation(@NotNull String worldName, double x, double y, double z, int duration) { 21 | this.worldName = worldName; 22 | this.x = x; 23 | this.y = y; 24 | this.z = z; 25 | this.expireDate = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(duration, TimeUnit.SECONDS); 26 | } 27 | 28 | public boolean isExpired() { 29 | return System.currentTimeMillis() >= this.expireDate; 30 | } 31 | 32 | public boolean isValid() { 33 | return this.getWorld() != null; 34 | } 35 | 36 | @Nullable 37 | public World getWorld() { 38 | return Bukkit.getWorld(this.worldName); 39 | } 40 | 41 | @Nullable 42 | public Location toLocation() { 43 | World world = this.getWorld(); 44 | if (world == null) return null; 45 | 46 | return new Location(world, x, y, z); 47 | 48 | //return this.blockPos.toLocation(world); 49 | } 50 | 51 | @NotNull 52 | public String getWorldName() { 53 | return worldName; 54 | } 55 | 56 | // @NotNull 57 | // public BlockPos getBlockPos() { 58 | // return blockPos; 59 | // } 60 | 61 | public long getExpireDate() { 62 | return expireDate; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/menu/SortMode.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.menu; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.sunlight.module.bans.punishment.PunishData; 5 | import su.nightexpress.sunlight.module.bans.punishment.PunishedIP; 6 | import su.nightexpress.sunlight.module.bans.punishment.PunishedPlayer; 7 | 8 | import java.util.Comparator; 9 | 10 | public enum SortMode { 11 | 12 | NAME((data1, data2) -> { 13 | if (data1 instanceof PunishedIP ip1 && data2 instanceof PunishedIP ip2) { 14 | return ip1.getAddress().compareTo(ip2.getAddress()); 15 | } 16 | if (data1 instanceof PunishedPlayer player1 && data2 instanceof PunishedPlayer player2) { 17 | return player1.getPlayerName().compareTo(player2.getPlayerName()); 18 | } 19 | return 0; 20 | }), 21 | DATE(Comparator.comparingLong(PunishData::getCreateDate).reversed()), 22 | PUNISHER(Comparator.comparing(PunishData::getAdmin)), 23 | REASON(Comparator.comparing(PunishData::getReason)); 24 | 25 | private final Comparator comparator; 26 | 27 | SortMode(@NotNull Comparator comparator) { 28 | this.comparator = comparator; 29 | } 30 | 31 | @NotNull 32 | public Comparator getComparator() { 33 | return comparator; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/LegacyPunishment.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | import su.nightexpress.nightcore.util.Colorizer; 6 | import su.nightexpress.sunlight.utils.SunUtils; 7 | 8 | import java.util.UUID; 9 | 10 | public class LegacyPunishment { 11 | 12 | private final UUID id; 13 | private final PunishmentType type; 14 | private final String user; 15 | private final String reason; 16 | private final String admin; 17 | private final long createdDate; 18 | private final boolean isIp; 19 | 20 | private UUID userId; 21 | private final long expireDate; 22 | 23 | public LegacyPunishment( 24 | @NotNull UUID id, 25 | @Nullable UUID userId, 26 | @NotNull PunishmentType type, 27 | @NotNull String user, 28 | @NotNull String reason, 29 | @NotNull String admin, 30 | long createdDate, 31 | long expireDate 32 | ) { 33 | this.id = id; 34 | this.type = type; 35 | this.user = user; 36 | this.userId = userId; 37 | this.reason = Colorizer.restrip(reason); 38 | this.admin = admin; 39 | this.createdDate = createdDate; 40 | this.expireDate = expireDate; 41 | this.isIp = SunUtils.isInetAddress(this.getUser()); 42 | } 43 | 44 | @NotNull 45 | public UUID getId() { 46 | return id; 47 | } 48 | 49 | @Nullable 50 | public UUID getUserId() { 51 | return userId; 52 | } 53 | 54 | public void setUserId(@NotNull UUID userId) { 55 | this.userId = userId; 56 | } 57 | 58 | @NotNull 59 | public PunishmentType getType() { 60 | return type; 61 | } 62 | 63 | @NotNull 64 | public String getUser() { 65 | return this.user; 66 | } 67 | 68 | public boolean isIp() { 69 | return isIp; 70 | } 71 | 72 | @NotNull 73 | public String getReason() { 74 | return this.reason; 75 | } 76 | 77 | @NotNull 78 | public String getAdmin() { 79 | return this.admin; 80 | } 81 | 82 | public long getCreatedDate() { 83 | return this.createdDate; 84 | } 85 | 86 | public long getExpireDate() { 87 | return this.expireDate; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/PunishData.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.nightcore.util.placeholder.Placeholder; 6 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 7 | import su.nightexpress.sunlight.module.bans.util.Placeholders; 8 | 9 | import java.util.UUID; 10 | 11 | public abstract class PunishData implements Placeholder { 12 | 13 | private final UUID id; 14 | private final String reason; 15 | private final String admin; 16 | private final long createDate; 17 | 18 | protected final PlaceholderMap placeholderMap; 19 | 20 | private long expireDate; 21 | 22 | public PunishData(@NotNull UUID id, @NotNull String reason, @NotNull String admin, long createDate, long expireDate) { 23 | this.id = id; 24 | this.reason = reason; 25 | this.admin = admin; 26 | this.createDate = createDate; 27 | this.expireDate = expireDate; 28 | this.placeholderMap = Placeholders.forPunishData(this); 29 | } 30 | 31 | @Override 32 | @NotNull 33 | public PlaceholderMap getPlaceholders() { 34 | return this.placeholderMap; 35 | } 36 | 37 | public abstract boolean isApplicable(@NotNull Player player); 38 | 39 | public void expire() { 40 | this.expireDate = System.currentTimeMillis(); 41 | } 42 | 43 | public boolean isActive() { 44 | return !this.isExpired(); 45 | } 46 | 47 | public boolean isExpired() { 48 | return !this.isPermanent() && System.currentTimeMillis() >= this.getExpireDate(); 49 | } 50 | 51 | public boolean isPermanent() { 52 | return this.getExpireDate() < 0; 53 | } 54 | 55 | @NotNull 56 | public UUID getId() { 57 | return id; 58 | } 59 | 60 | @NotNull 61 | public String getReason() { 62 | return reason; 63 | } 64 | 65 | @NotNull 66 | public String getAdmin() { 67 | return admin; 68 | } 69 | 70 | public long getCreateDate() { 71 | return createDate; 72 | } 73 | 74 | public long getExpireDate() { 75 | return expireDate; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/PunishedIP.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.module.bans.util.Placeholders; 6 | import su.nightexpress.sunlight.utils.SunUtils; 7 | 8 | import java.util.UUID; 9 | 10 | public class PunishedIP extends PunishData { 11 | 12 | private final String address; 13 | 14 | public PunishedIP(@NotNull UUID id, @NotNull String address, @NotNull String reason, @NotNull String admin, long createDate, long expireDate) { 15 | super(id, reason, admin, createDate, expireDate); 16 | this.address = address; 17 | 18 | this.placeholderMap.add(Placeholders.forPunishedIP(this)); 19 | } 20 | 21 | @Override 22 | public boolean isApplicable(@NotNull Player player) { 23 | return SunUtils.getRawAddress(player).equalsIgnoreCase(this.getAddress()); 24 | } 25 | 26 | @NotNull 27 | public String getAddress() { 28 | return address; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/PunishedPlayer.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.module.bans.util.Placeholders; 6 | 7 | import java.util.UUID; 8 | 9 | public class PunishedPlayer extends PunishData { 10 | 11 | private final UUID playerId; 12 | private String playerName; 13 | 14 | public PunishedPlayer(@NotNull UUID id, @NotNull UUID playerId, @NotNull String playerName, @NotNull String reason, @NotNull String admin, long createDate, long expireDate) { 15 | super(id, reason, admin, createDate, expireDate); 16 | this.playerId = playerId; 17 | this.playerName = playerName; 18 | 19 | this.placeholderMap.add(Placeholders.forPunishedPlayer(this)); 20 | } 21 | 22 | public boolean updateName(@NotNull String name) { 23 | if (!this.playerName.equalsIgnoreCase(name)) { 24 | this.playerName = name; 25 | return true; 26 | } 27 | return false; 28 | } 29 | 30 | @Override 31 | public boolean isApplicable(@NotNull Player player) { 32 | return this.getPlayerName().equalsIgnoreCase(player.getName()); 33 | } 34 | 35 | @NotNull 36 | public UUID getPlayerId() { 37 | return playerId; 38 | } 39 | 40 | @NotNull 41 | public String getPlayerName() { 42 | return playerName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/PunishmentReason.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 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 PunishmentReason { 8 | 9 | private String text; 10 | 11 | public PunishmentReason(@NotNull String text) { 12 | this.setText(text); 13 | } 14 | 15 | @NotNull 16 | public static PunishmentReason read(@NotNull FileConfig config, @NotNull String path) { 17 | String message = ConfigValue.create(path + ".Message", "Violation of the rules.").read(config); 18 | 19 | return new PunishmentReason(message); 20 | } 21 | 22 | public void write(@NotNull FileConfig config, @NotNull String path) { 23 | config.set(path + ".Message", this.getText()); 24 | } 25 | 26 | @NotNull 27 | public String getText() { 28 | return text; 29 | } 30 | 31 | public void setText(@NotNull String text) { 32 | this.text = text; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/punishment/PunishmentType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.punishment; 2 | 3 | public enum PunishmentType { 4 | BAN, MUTE, WARN, 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/util/BanTime.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class BanTime { 6 | 7 | public static final BanTime PERMANENT = new BanTime(TimeUnit.PERMANENT, 0L); 8 | 9 | private final TimeUnit timeUnit; 10 | private final long amount; 11 | 12 | public BanTime(@NotNull TimeUnit timeUnit, long amount) { 13 | this.timeUnit = timeUnit; 14 | this.amount = Math.abs(amount); 15 | } 16 | 17 | public long toTimestamp() { 18 | if (this.timeUnit == TimeUnit.PERMANENT) return -1L; 19 | 20 | return System.currentTimeMillis() + this.getInMillis(); 21 | } 22 | 23 | public long getInMillis() { 24 | return this.amount * this.timeUnit.getModifier() + 100L; // 100L for better time format. 25 | } 26 | 27 | public boolean isPermanent() { 28 | return this.timeUnit == TimeUnit.PERMANENT; 29 | } 30 | 31 | @NotNull 32 | public TimeUnit getTimeUnit() { 33 | return timeUnit; 34 | } 35 | 36 | public long getAmount() { 37 | return amount; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/util/Placeholders.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.util.TimeUtil; 5 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 6 | import su.nightexpress.sunlight.config.Lang; 7 | import su.nightexpress.sunlight.module.bans.punishment.PunishData; 8 | import su.nightexpress.sunlight.module.bans.punishment.PunishedIP; 9 | import su.nightexpress.sunlight.module.bans.punishment.PunishedPlayer; 10 | import su.nightexpress.sunlight.utils.SunUtils; 11 | 12 | public class Placeholders extends su.nightexpress.sunlight.Placeholders { 13 | 14 | public static final String PUNISHMENT_TYPE = "%punishment_type%"; 15 | public static final String PUNISHMENT_TARGET = "%punishment_user%"; 16 | public static final String PUNISHMENT_REASON = "%punishment_reason%"; 17 | public static final String PUNISHMENT_PUNISHER = "%punishment_punisher%"; 18 | public static final String PUNISHMENT_CREATION_DATE = "%punishment_date_created%"; 19 | public static final String PUNISHMENT_EXPIRATION_DATE = "%punishment_date_expired%"; 20 | public static final String PUNISHMENT_EXPIRES_IN = "%punishment_expires_in%"; 21 | 22 | @NotNull 23 | public static PlaceholderMap forPunishData(@NotNull PunishData punishData) { 24 | return new PlaceholderMap() 25 | .add(PUNISHMENT_REASON, punishData.getReason()) 26 | .add(PUNISHMENT_PUNISHER, () -> SunUtils.getSenderName(punishData.getAdmin())) 27 | .add(PUNISHMENT_EXPIRES_IN, () -> !punishData.isPermanent() ? TimeUtil.formatDuration(punishData.getExpireDate()) : Lang.OTHER_NEVER.getString()) 28 | .add(PUNISHMENT_CREATION_DATE, () -> SunUtils.formatDate(punishData.getCreateDate())) 29 | .add(PUNISHMENT_EXPIRATION_DATE, () -> !punishData.isPermanent() ? SunUtils.formatDate(punishData.getExpireDate()) : Lang.OTHER_NEVER.getString()) 30 | ; 31 | } 32 | 33 | @NotNull 34 | public static PlaceholderMap forPunishedPlayer(@NotNull PunishedPlayer punishedPlayer) { 35 | return new PlaceholderMap() 36 | .add(PUNISHMENT_TARGET, () -> SunUtils.getSenderName(punishedPlayer.getPlayerName())) 37 | ; 38 | } 39 | 40 | @NotNull 41 | public static PlaceholderMap forPunishedIP(@NotNull PunishedIP punishedIP) { 42 | return new PlaceholderMap() 43 | .add(PUNISHMENT_TARGET, punishedIP.getAddress()) 44 | ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/util/RankDuration.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.config.FileConfig; 5 | 6 | public class RankDuration { 7 | 8 | private final int amount; 9 | private final TimeUnit timeUnit; 10 | 11 | public RankDuration(int amount, @NotNull TimeUnit timeUnit) { 12 | this.amount = amount; 13 | this.timeUnit = timeUnit; 14 | } 15 | 16 | @NotNull 17 | public static RankDuration read(@NotNull FileConfig cfg, @NotNull String path) { 18 | int amount = cfg.getInt(path + ".Amount", -1); 19 | TimeUnit timeUnit = cfg.getEnum(path + ".TimeUnit", TimeUnit.class, TimeUnit.SECONDS); 20 | return new RankDuration(amount, timeUnit); 21 | } 22 | 23 | public void write(@NotNull FileConfig cfg, @NotNull String path) { 24 | cfg.set(path + ".Amount", this.getAmount()); 25 | cfg.set(path + ".TimeUnit", this.getTimeUnit().name()); 26 | } 27 | 28 | public int getAmount() { 29 | return amount; 30 | } 31 | 32 | @NotNull 33 | public TimeUnit getTimeUnit() { 34 | return timeUnit; 35 | } 36 | 37 | public long getInMillis() { 38 | return this.getTimeUnit().getModifier() * this.getAmount(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/bans/util/TimeUnit.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.bans.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public enum TimeUnit { 7 | 8 | PERMANENT(-1L, new String[]{"permanent"}), 9 | SECONDS(1000L, new String[]{"sec", "s"}), 10 | MINUTES(1000L * 60L, new String[]{"min"}), 11 | HOURS(1000L * 60L * 60L, new String[]{"hour", "h"}), 12 | DAYS(1000L * 60L * 60L * 24L, new String[]{"day", "d"}), 13 | WEEKS(1000L * 60L * 60L * 24L * 7L, new String[]{"week", "w"}), 14 | MONTHS(1000L * 60L * 60L * 24L * 30L, new String[]{"mon"}), 15 | YEARS(1000L * 60L * 60L * 24L * 365L, new String[]{"year", "y"}), 16 | ; 17 | 18 | 19 | @Nullable 20 | public static TimeUnit byName(@NotNull String name) { 21 | for (TimeUnit timeUnit : TimeUnit.values()) { 22 | for (String alias : timeUnit.getAliases()) { 23 | if (alias.equalsIgnoreCase(name)) { 24 | return timeUnit; 25 | } 26 | } 27 | } 28 | return null; 29 | } 30 | 31 | private final long modifier; 32 | private String[] aliases; 33 | 34 | TimeUnit(long modifier, String[] aliases) { 35 | this.modifier = modifier; 36 | this.aliases = aliases; 37 | } 38 | 39 | public long getAbsolute(long millis) { 40 | return millis / this.modifier; 41 | } 42 | 43 | public long getModifier() { 44 | return this.modifier; 45 | } 46 | 47 | public String[] getAliases() { 48 | return aliases; 49 | } 50 | 51 | public void setAliases(String[] aliases) { 52 | this.aliases = aliases; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/command/ClearChatCommand.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.command; 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.SunLightPlugin; 11 | import su.nightexpress.sunlight.command.CommandRegistry; 12 | import su.nightexpress.sunlight.command.template.CommandTemplate; 13 | import su.nightexpress.sunlight.module.chat.config.ChatPerms; 14 | import su.nightexpress.sunlight.module.chat.config.ChatLang; 15 | import su.nightexpress.sunlight.module.chat.util.Placeholders; 16 | import su.nightexpress.sunlight.utils.SunUtils; 17 | 18 | import java.util.Collection; 19 | 20 | public class ClearChatCommand { 21 | 22 | public static final String NODE = "clearchat"; 23 | 24 | public static void load(@NotNull SunLightPlugin plugin) { 25 | CommandRegistry.registerDirectExecutor(NODE, (template, config) -> builder(plugin, template, config)); 26 | 27 | CommandRegistry.addSimpleTemplate(NODE); 28 | } 29 | 30 | @NotNull 31 | public static DirectNodeBuilder builder(@NotNull SunLightPlugin plugin, @NotNull CommandTemplate template, @NotNull FileConfig config) { 32 | return DirectNode.builder(plugin, template.getAliases()) 33 | .description(ChatLang.COMMAND_CLEAR_CHAT_DESC) 34 | .permission(ChatPerms.COMMAND_CLEARCHAT) 35 | .executes((context, arguments) -> execute(plugin, context, arguments)) 36 | ; 37 | } 38 | 39 | public static boolean execute(@NotNull SunLightPlugin plugin, @NotNull CommandContext context, @NotNull ParsedArguments arguments) { 40 | Collection players = plugin.getServer().getOnlinePlayers(); 41 | 42 | for (int i = 0; i < 100; i++) { 43 | players.forEach(player -> player.sendMessage(" ")); 44 | } 45 | 46 | ChatLang.COMMAND_CLEAR_CHAT_DONE.getMessage().replace(Placeholders.GENERIC_NAME, SunUtils.getSenderName(context.getSender())).broadcast(); 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/event/SunlightPreHandleChatEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.event; 2 | 3 | import org.bukkit.Bukkit; 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 | import su.nightexpress.sunlight.module.chat.ChatModule; 9 | import su.nightexpress.sunlight.module.chat.handler.ChatMessageHandler; 10 | 11 | public class SunlightPreHandleChatEvent extends Event implements Cancellable { 12 | 13 | public static final HandlerList handlerList = new HandlerList(); 14 | 15 | private final ChatModule module; 16 | private final ChatMessageHandler handler; 17 | 18 | private boolean cancelled; 19 | 20 | public SunlightPreHandleChatEvent(@NotNull ChatModule module, @NotNull ChatMessageHandler handler) { 21 | super(!Bukkit.isPrimaryThread()); 22 | this.module = module; 23 | this.handler = handler; 24 | } 25 | 26 | @NotNull 27 | public static HandlerList getHandlerList() { 28 | return handlerList; 29 | } 30 | 31 | @NotNull 32 | @Override 33 | public HandlerList getHandlers() { 34 | return handlerList; 35 | } 36 | 37 | @Override 38 | public boolean isCancelled() { 39 | return cancelled; 40 | } 41 | 42 | @Override 43 | public void setCancelled(boolean cancelled) { 44 | this.cancelled = cancelled; 45 | } 46 | 47 | @NotNull 48 | public ChatModule getModule() { 49 | return module; 50 | } 51 | 52 | @NotNull 53 | public ChatMessageHandler getHandler() { 54 | return handler; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/format/FormatComponent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.format; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.config.FileConfig; 5 | 6 | public class FormatComponent { 7 | 8 | private final String id; 9 | private final String text; 10 | 11 | public FormatComponent(@NotNull String id, @NotNull String text) { 12 | this.id = id.toLowerCase(); 13 | this.text = text; 14 | } 15 | 16 | @NotNull 17 | public static FormatComponent read(@NotNull FileConfig config, @NotNull String path, @NotNull String id) { 18 | String text = config.getString(path + ".Text", ""); 19 | return new FormatComponent(id, text); 20 | } 21 | 22 | public void write(@NotNull FileConfig config, @NotNull String path) { 23 | config.set(path + ".Text", this.text); 24 | } 25 | 26 | @NotNull 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | @NotNull 32 | public String getText() { 33 | return text; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/format/FormatContainer.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.format; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.nightcore.config.FileConfig; 6 | import su.nightexpress.nightcore.util.Players; 7 | import su.nightexpress.sunlight.module.chat.util.Placeholders; 8 | 9 | import java.util.Set; 10 | 11 | public class FormatContainer { 12 | 13 | private final int priority; 14 | private final String nameFormat; 15 | private final String messageFormat; 16 | private final Set applicableRanks; 17 | 18 | public FormatContainer(int priority, @NotNull String nameFormat, @NotNull String messageFormat, @NotNull Set applicableRanks) { 19 | this.priority = priority; 20 | this.nameFormat = nameFormat; 21 | this.messageFormat = messageFormat; 22 | this.applicableRanks = applicableRanks; 23 | } 24 | 25 | @NotNull 26 | public static FormatContainer read(@NotNull FileConfig config, @NotNull String path) { 27 | int priority = config.getInt(path + ".Priority"); 28 | String format = config.getString(path + ".Name", ""); 29 | String message = config.getString(path + ".Message", ""); 30 | Set applicableRanks = config.getStringSet(path + ".Ranks"); 31 | 32 | return new FormatContainer(priority, format, message, applicableRanks); 33 | } 34 | 35 | public void write(@NotNull FileConfig config, @NotNull String path) { 36 | config.set(path + ".Priority", this.getPriority()); 37 | config.set(path + ".Name", this.getNameFormat()); 38 | config.set(path + ".Message", this.getMessageFormat()); 39 | config.set(path + ".Ranks", this.getApplicableRanks()); 40 | } 41 | 42 | public boolean isApplicable(@NotNull Player player) { 43 | if (this.applicableRanks.isEmpty()) return false; 44 | if (this.applicableRanks.contains(Placeholders.WILDCARD)) return true; 45 | 46 | Set groups = Players.getPermissionGroups(player); 47 | return this.applicableRanks.stream().anyMatch(groups::contains); 48 | } 49 | 50 | public int getPriority() { 51 | return priority; 52 | } 53 | 54 | @NotNull 55 | public String getNameFormat() { 56 | return nameFormat; 57 | } 58 | 59 | @NotNull 60 | public String getMessageFormat() { 61 | return messageFormat; 62 | } 63 | 64 | @NotNull 65 | public Set getApplicableRanks() { 66 | return applicableRanks; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/mention/Mention.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.mention; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.module.chat.ChatChannel; 6 | 7 | import java.util.Set; 8 | 9 | public interface Mention { 10 | 11 | boolean hasPermission(@NotNull Player player); 12 | 13 | //boolean isApplicable(@NotNull Player player); 14 | 15 | @NotNull Set getAffectedPlayers(@NotNull ChatChannel channel); 16 | 17 | @NotNull String getFormat(); 18 | } 19 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/mention/PlayerMention.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.mention; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.module.chat.ChatChannel; 6 | import su.nightexpress.sunlight.module.chat.config.ChatConfig; 7 | import su.nightexpress.sunlight.module.chat.config.ChatPerms; 8 | import su.nightexpress.sunlight.module.chat.util.Placeholders; 9 | 10 | import java.util.Collections; 11 | import java.util.Set; 12 | 13 | public class PlayerMention implements Mention { 14 | 15 | private final Player target; 16 | 17 | public PlayerMention(@NotNull Player target) { 18 | this.target = target; 19 | } 20 | 21 | @Override 22 | public boolean hasPermission(@NotNull Player player) { 23 | return player.hasPermission(ChatPerms.MENTION) || player.hasPermission(ChatPerms.MENTION_PLAYER + this.target.getName().toLowerCase()); 24 | } 25 | 26 | @Override 27 | @NotNull 28 | public String getFormat() { 29 | return Placeholders.forPlayer(this.target).apply(ChatConfig.MENTIONS_FORMAT.get()); 30 | } 31 | 32 | @Override 33 | @NotNull 34 | public Set getAffectedPlayers(@NotNull ChatChannel channel) { 35 | return channel.contains(this.target) ? Set.of(this.target) : Collections.emptySet(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/announcer/AnnounceListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.announcer; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.player.PlayerQuitEvent; 6 | import org.jetbrains.annotations.NotNull; 7 | import su.nightexpress.nightcore.manager.AbstractListener; 8 | import su.nightexpress.sunlight.SunLightPlugin; 9 | 10 | import java.util.UUID; 11 | 12 | public class AnnounceListener extends AbstractListener { 13 | 14 | private final AnnounceManager manager; 15 | 16 | public AnnounceListener(@NotNull SunLightPlugin plugin, @NotNull AnnounceManager manager) { 17 | super(plugin); 18 | this.manager = manager; 19 | } 20 | 21 | @EventHandler(priority = EventPriority.MONITOR) 22 | public void onQuit(PlayerQuitEvent event) { 23 | UUID uuid = event.getPlayer().getUniqueId(); 24 | this.manager.getAnnouncers().forEach(announcer -> announcer.clearIndex(uuid)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/deathmessage/DeathMessage.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.deathmessage; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | import su.nightexpress.nightcore.config.FileConfig; 6 | import su.nightexpress.nightcore.util.Lists; 7 | import su.nightexpress.nightcore.util.random.Rnd; 8 | 9 | import java.util.List; 10 | 11 | public class DeathMessage { 12 | 13 | private final List messages; 14 | 15 | public DeathMessage(@NotNull List messages) { 16 | this.messages = messages; 17 | } 18 | 19 | @NotNull 20 | public static DeathMessage simple(@NotNull String message) { 21 | return new DeathMessage(Lists.newList(message)); 22 | } 23 | 24 | @NotNull 25 | public static DeathMessage read(@NotNull FileConfig config, @NotNull String path) { 26 | List messages = config.getStringList(path + ".Messages"); 27 | return new DeathMessage(messages); 28 | } 29 | 30 | public void write(@NotNull FileConfig config, @NotNull String path) { 31 | config.set(path + ".Messages", this.messages); 32 | } 33 | 34 | @Nullable 35 | public String selectMessage() { 36 | return this.messages.isEmpty() ? null : Rnd.get(this.messages); 37 | } 38 | 39 | @NotNull 40 | public List getMessages() { 41 | return messages; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/deathmessage/DeathMessageListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.deathmessage; 2 | 3 | import org.bukkit.damage.DamageSource; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.EventPriority; 7 | import org.bukkit.event.entity.EntityDamageEvent; 8 | import org.bukkit.event.entity.PlayerDeathEvent; 9 | import org.jetbrains.annotations.NotNull; 10 | import su.nightexpress.nightcore.manager.AbstractListener; 11 | import su.nightexpress.nightcore.util.Players; 12 | import su.nightexpress.sunlight.SunLightPlugin; 13 | 14 | public class DeathMessageListener extends AbstractListener { 15 | 16 | private final DeathMessageManager manager; 17 | 18 | public DeathMessageListener(@NotNull SunLightPlugin plugin, @NotNull DeathMessageManager manager) { 19 | super(plugin); 20 | this.manager = manager; 21 | } 22 | 23 | @SuppressWarnings("UnstableApiUsage") 24 | @EventHandler(priority = EventPriority.HIGHEST) 25 | public void onDeath(PlayerDeathEvent event) { 26 | event.setDeathMessage(null); 27 | 28 | Player player = event.getEntity(); 29 | EntityDamageEvent lastEvent = player.getLastDamageCause(); 30 | if (lastEvent == null) return; 31 | 32 | DamageSource damageSource = lastEvent.getDamageSource(); 33 | String message = this.manager.getMessage(player, damageSource); 34 | if (message == null) return; 35 | 36 | this.manager.getRecievers(player).forEach(entity -> Players.sendModernMessage(entity, message)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/joinquit/DisplayMode.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.joinquit; 2 | 3 | public enum DisplayMode { 4 | CHAT, ACTION_BAR 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/joinquit/JoinMessageListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.joinquit; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.manager.AbstractListener; 10 | import su.nightexpress.sunlight.SunLightPlugin; 11 | 12 | public class JoinMessageListener extends AbstractListener { 13 | 14 | private final JoinMessageManager manager; 15 | 16 | public JoinMessageListener(@NotNull SunLightPlugin plugin, @NotNull JoinMessageManager manager) { 17 | super(plugin); 18 | this.manager = manager; 19 | } 20 | 21 | @EventHandler(priority = EventPriority.HIGHEST) 22 | public void onChatJoinMessage(PlayerJoinEvent event) { 23 | event.setJoinMessage(null); 24 | 25 | Player player = event.getPlayer(); 26 | JoinMessage message = this.manager.getJoinMessage(player); 27 | if (message == null) return; 28 | 29 | message.display(this.plugin, player); 30 | } 31 | 32 | @EventHandler(priority = EventPriority.NORMAL) 33 | public void onChatQuitMessage(PlayerQuitEvent event) { 34 | event.setQuitMessage(null); 35 | 36 | Player player = event.getPlayer(); 37 | JoinMessage message = this.manager.getQuitMessage(player); 38 | if (message == null) return; 39 | 40 | message.display(this.plugin, player); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/spy/SpyListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.spy; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.player.PlayerCommandPreprocessEvent; 6 | import org.jetbrains.annotations.NotNull; 7 | import su.nightexpress.nightcore.manager.AbstractListener; 8 | import su.nightexpress.sunlight.SunLightPlugin; 9 | import su.nightexpress.sunlight.api.event.PlayerPrivateMessageEvent; 10 | import su.nightexpress.sunlight.module.chat.event.AsyncSunlightPlayerChatEvent; 11 | 12 | public class SpyListener extends AbstractListener { 13 | 14 | private final SpyManager spyManager; 15 | 16 | public SpyListener(@NotNull SunLightPlugin plugin, @NotNull SpyManager spyManager) { 17 | super(plugin); 18 | this.spyManager = spyManager; 19 | } 20 | 21 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 22 | public void onSpyChat(AsyncSunlightPlayerChatEvent event) { 23 | this.spyManager.handleSpyMode(event); 24 | } 25 | 26 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 27 | public void onSpyCommand(PlayerCommandPreprocessEvent event) { 28 | this.spyManager.handleSpyMode(event); 29 | } 30 | 31 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 32 | public void onSpySocial(PlayerPrivateMessageEvent event) { 33 | this.spyManager.handleSpyMode(event); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/module/spy/SpyType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.module.spy; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.sunlight.core.user.settings.Setting; 5 | import su.nightexpress.sunlight.core.user.settings.SettingRegistry; 6 | 7 | public enum SpyType { 8 | 9 | SOCIAL( 10 | Setting.create("spy_chat_social", false, true), 11 | Setting.create("spy_log_social", false, true) 12 | ), 13 | COMMAND( 14 | Setting.create("spy_chat_command", false, true), 15 | Setting.create("spy_log_command", false, true) 16 | ), 17 | CHAT( 18 | Setting.create("spy_chat_chat", false, true), 19 | Setting.create("spy_log_chat", false, true) 20 | ); 21 | 22 | private final Setting settingChat; 23 | private final Setting settingLog; 24 | 25 | SpyType(@NotNull Setting settingChat, @NotNull Setting settingLog) { 26 | this.settingChat = SettingRegistry.register(settingChat); 27 | this.settingLog = SettingRegistry.register(settingLog); 28 | } 29 | 30 | @NotNull 31 | public Setting getSettingChat() { 32 | return this.settingChat; 33 | } 34 | 35 | @NotNull 36 | public Setting getSettingLog() { 37 | return settingLog; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/report/ReportHandler.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.report; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.manager.SimpleManager; 5 | import su.nightexpress.sunlight.SunLightPlugin; 6 | 7 | public abstract class ReportHandler extends SimpleManager { 8 | 9 | public ReportHandler(@NotNull SunLightPlugin plugin) { 10 | super(plugin); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/rule/RuleData.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.rule; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.nightcore.config.ConfigValue; 6 | import su.nightexpress.nightcore.config.FileConfig; 7 | import su.nightexpress.nightcore.manager.AbstractFileData; 8 | import su.nightexpress.nightcore.util.Lists; 9 | import su.nightexpress.nightcore.util.Players; 10 | import su.nightexpress.sunlight.SunLightPlugin; 11 | 12 | import java.io.File; 13 | import java.util.*; 14 | 15 | public class RuleData extends AbstractFileData { 16 | 17 | private List commands; 18 | private Map ruleMap; 19 | 20 | public RuleData(@NotNull SunLightPlugin plugin, @NotNull File file) { 21 | super(plugin, file); 22 | this.commands = new ArrayList<>(); 23 | this.ruleMap = new HashMap<>(); 24 | } 25 | 26 | @Override 27 | protected boolean onLoad(@NotNull FileConfig config) { 28 | this.commands = ConfigValue.create("Punishments", 29 | Lists.newList(), 30 | "List of commands that will be executed when any rule is triggered." 31 | ).read(config); 32 | 33 | this.ruleMap = new HashMap<>(); 34 | for (String ruleId : config.getSection("Rules")) { 35 | String path = "Rules." + ruleId; 36 | 37 | if (!ConfigValue.create(path + ".Enabled", true, "Enables the rule.").read(config)) continue; 38 | 39 | ChatRule rule = ChatRule.read(config, path); 40 | 41 | this.ruleMap.put(ruleId.toLowerCase(), rule); 42 | } 43 | 44 | return true; 45 | } 46 | 47 | @Override 48 | protected void onSave(@NotNull FileConfig config) { 49 | config.set("Punishments", this.commands); 50 | config.remove("Rules"); 51 | this.ruleMap.forEach((sId, rule) -> rule.write(config, "Rules." + sId)); 52 | } 53 | 54 | @NotNull 55 | public Map getRuleMap() { 56 | return this.ruleMap; 57 | } 58 | 59 | @NotNull 60 | public List getCommands() { 61 | return this.commands; 62 | } 63 | 64 | public void punish(@NotNull Player player) { 65 | this.commands.forEach(command -> Players.dispatchCommand(player, command)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/chat/util/Placeholders.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.chat.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 5 | import su.nightexpress.sunlight.module.chat.format.FormatComponent; 6 | 7 | import java.util.Collection; 8 | import java.util.function.Function; 9 | 10 | public class Placeholders extends su.nightexpress.sunlight.Placeholders { 11 | 12 | public static final String CHANNEL_ID = "%channel_id%"; 13 | public static final String CHANNEL_NAME = "%channel_name%"; 14 | public static final String CHANNEL_RADIUS = "%channel_radius%"; 15 | 16 | public static final String ITEM_NAME = "%item_name%"; 17 | public static final String ITEM_VALUE = "%item_value%"; 18 | 19 | public static final String PLAYER_PREFIX = "%player_prefix%"; 20 | public static final String PLAYER_SUFFIX = "%player_suffix%"; 21 | public static final String PLAYER_NAME = "%player_name%"; 22 | public static final String PLAYER_DISPLAY_NAME = "%player_display_name%"; 23 | public static final String PLAYER_WORLD = "%player_world%"; 24 | 25 | @Deprecated 26 | public static final String FORMAT_PLAYER_NAME = "%format_player_name%"; 27 | @Deprecated 28 | public static final String FORMAT_PLAYER_MESSAGE = "%format_player_message%"; 29 | @Deprecated 30 | public static final String FORMAT_PLAYER_COLOR = "%format_player_color%"; 31 | 32 | public static final Function FORMAT_COMPONENT = component -> "%" + component.getId() + "%"; 33 | 34 | @NotNull 35 | public static PlaceholderMap forComponent(@NotNull FormatComponent component) { 36 | return new PlaceholderMap().add(FORMAT_COMPONENT.apply(component), component.getText()); 37 | } 38 | 39 | @NotNull 40 | public static PlaceholderMap forComponents(@NotNull Collection components) { 41 | PlaceholderMap map = new PlaceholderMap(); 42 | components.forEach(component -> map.add(FORMAT_COMPONENT.apply(component), component.getText())); 43 | return map; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/customtext/CustomText.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.customtext; 2 | 3 | import org.bukkit.command.CommandSender; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.nightcore.config.FileConfig; 6 | import su.nightexpress.nightcore.manager.AbstractFileData; 7 | import su.nightexpress.sunlight.SunLightPlugin; 8 | import su.nightexpress.sunlight.module.customtext.config.CTextPerms; 9 | 10 | import java.io.File; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class CustomText extends AbstractFileData { 15 | 16 | private String description; 17 | private List text; 18 | 19 | public CustomText(@NotNull SunLightPlugin plugin, @NotNull File file) { 20 | super(plugin, file); 21 | this.setText(new ArrayList<>()); 22 | } 23 | 24 | @Override 25 | protected boolean onLoad(@NotNull FileConfig config) { 26 | this.setDescription(config.getString("Description", "")); 27 | this.setText(config.getStringList("Text")); 28 | return true; 29 | } 30 | 31 | @Override 32 | protected void onSave(@NotNull FileConfig config) { 33 | config.set("Description", this.description); 34 | config.set("Text", this.text); 35 | } 36 | 37 | public boolean hasPermission(@NotNull CommandSender sender) { 38 | return sender.hasPermission(CTextPerms.TEXTS) || sender.hasPermission(this.getPermission()); 39 | } 40 | 41 | @NotNull 42 | public String getPermission() { 43 | return CTextPerms.PREFIX_TEXT + this.getId(); 44 | } 45 | 46 | @NotNull 47 | public String getDescription() { 48 | return description; 49 | } 50 | 51 | public void setDescription(@NotNull String description) { 52 | this.description = description; 53 | } 54 | 55 | @NotNull 56 | public List getText() { 57 | return text; 58 | } 59 | 60 | public void setText(@NotNull List text) { 61 | this.text = text; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/customtext/config/CTextLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.customtext.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | 6 | import static su.nightexpress.sunlight.Placeholders.*; 7 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 8 | 9 | public class CTextLang { 10 | 11 | 12 | public static final LangString COMMAND_TEXT_DESC = LangString.of("CustomText.Command.Text.Desc", "View a custom text."); 13 | 14 | public static final LangText ERROR_COMMAND_INVALID_TEXT_ARGUMENT = LangText.of("CustomText.Error.Command.Argument.InvalidCustomText", 15 | LIGHT_GRAY.wrap(LIGHT_RED.wrap(GENERIC_VALUE) + " is not a valid custom text!") 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/customtext/config/CTextPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.customtext.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class CTextPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "customtext."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_TEXT = PREFIX + "text."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 15 | public static final UniPermission TEXTS = new UniPermission(PREFIX_TEXT + Placeholders.WILDCARD); 16 | 17 | public static final UniPermission COMMAND_TEXT = new UniPermission(PREFIX_COMMAND + "text"); 18 | 19 | static { 20 | Perms.PLUGIN.addChildren(MODULE); 21 | 22 | MODULE.addChildren(COMMAND, TEXTS); 23 | 24 | COMMAND.addChildren( 25 | COMMAND_TEXT 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/ExtrasModule.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | import su.nightexpress.sunlight.SunLightPlugin; 6 | import su.nightexpress.sunlight.module.Module; 7 | import su.nightexpress.sunlight.module.ModuleInfo; 8 | import su.nightexpress.sunlight.module.extras.chairs.ChairsManager; 9 | import su.nightexpress.sunlight.module.extras.chestsort.SortManager; 10 | import su.nightexpress.sunlight.module.extras.config.ExtrasConfig; 11 | import su.nightexpress.sunlight.module.extras.config.ExtrasLang; 12 | import su.nightexpress.sunlight.module.extras.config.ExtrasPerms; 13 | import su.nightexpress.sunlight.module.extras.listener.ExtrasGenericListener; 14 | import su.nightexpress.sunlight.module.extras.listener.PhysicsExplosionListener; 15 | 16 | public class ExtrasModule extends Module { 17 | 18 | private ChairsManager chairsManager; 19 | private SortManager sortManager; 20 | 21 | public ExtrasModule(@NotNull SunLightPlugin plugin, @NotNull String id) { 22 | super(plugin, id); 23 | } 24 | 25 | @Override 26 | protected void gatherInfo(@NotNull ModuleInfo moduleInfo) { 27 | moduleInfo.setConfigClass(ExtrasConfig.class); 28 | moduleInfo.setLangClass(ExtrasLang.class); 29 | moduleInfo.setPermissionsClass(ExtrasPerms.class); 30 | } 31 | 32 | @Override 33 | protected void onModuleLoad() { 34 | if (ExtrasConfig.CHAIRS_ENABLED.get()) { 35 | this.chairsManager = new ChairsManager(this.plugin, this); 36 | this.chairsManager.setup(); 37 | } 38 | if (ExtrasConfig.CHEST_SORT_ENABLED.get()) { 39 | this.sortManager = new SortManager(this.plugin, this); 40 | this.sortManager.setup(); 41 | } 42 | if (ExtrasConfig.PHYSIC_EXPLOSIONS_ENABLED.get()) { 43 | this.addListener(new PhysicsExplosionListener(this.plugin)); 44 | } 45 | this.addListener(new ExtrasGenericListener(this.plugin, this)); 46 | } 47 | 48 | @Override 49 | protected void onModuleUnload() { 50 | if (this.chairsManager != null) this.chairsManager.shutdown(); 51 | if (this.sortManager != null) this.sortManager.shutdown(); 52 | } 53 | 54 | @Nullable 55 | public ChairsManager getChairsManager() { 56 | return chairsManager; 57 | } 58 | 59 | @Nullable 60 | public SortManager getChestSortManager() { 61 | return sortManager; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/chestsort/SortListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras.chestsort; 2 | 3 | import org.bukkit.GameMode; 4 | import org.bukkit.block.Barrel; 5 | import org.bukkit.block.Chest; 6 | import org.bukkit.block.DoubleChest; 7 | import org.bukkit.block.ShulkerBox; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.inventory.InventoryCloseEvent; 12 | import org.bukkit.inventory.Inventory; 13 | import org.bukkit.inventory.InventoryHolder; 14 | import org.jetbrains.annotations.NotNull; 15 | import su.nightexpress.nightcore.manager.AbstractListener; 16 | import su.nightexpress.sunlight.SunLightPlugin; 17 | import su.nightexpress.sunlight.data.user.SunUser; 18 | 19 | public class SortListener extends AbstractListener { 20 | 21 | private final SortManager manager; 22 | 23 | public SortListener(@NotNull SunLightPlugin plugin, @NotNull SortManager manager) { 24 | super(plugin); 25 | this.manager = manager; 26 | } 27 | 28 | @EventHandler(priority = EventPriority.HIGHEST) 29 | public void onSortInventoryClose(InventoryCloseEvent e) { 30 | Player player = (Player) e.getPlayer(); 31 | if (player.getGameMode() == GameMode.SPECTATOR) return; 32 | 33 | Inventory inventory = e.getInventory(); 34 | InventoryHolder holder = inventory.getHolder(); 35 | if (!(holder instanceof Chest) && !(holder instanceof DoubleChest) && !(holder instanceof ShulkerBox) && !(holder instanceof Barrel)) { 36 | return; 37 | } 38 | 39 | SunUser user = plugin.getUserManager().getUserData(player); 40 | if (!SortManager.isChestSortEnabled(user)) return; 41 | 42 | this.manager.sortInventory(inventory); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/chestsort/SortManager.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras.chestsort; 2 | 3 | import org.bukkit.inventory.Inventory; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.jetbrains.annotations.NotNull; 6 | import su.nightexpress.nightcore.manager.AbstractManager; 7 | import su.nightexpress.sunlight.SunLightPlugin; 8 | import su.nightexpress.sunlight.core.user.settings.SettingRegistry; 9 | import su.nightexpress.sunlight.data.user.SunUser; 10 | import su.nightexpress.sunlight.core.user.settings.Setting; 11 | import su.nightexpress.sunlight.module.extras.ExtrasModule; 12 | import su.nightexpress.sunlight.module.extras.config.ExtrasConfig; 13 | 14 | import java.util.Arrays; 15 | import java.util.Comparator; 16 | import java.util.List; 17 | 18 | public class SortManager extends AbstractManager { 19 | 20 | public static final Setting SETTING_CHEST_SORT = SettingRegistry.register(Setting.create("chest_sort", false, true)); 21 | 22 | //private final ExtrasModule module; 23 | 24 | public SortManager(@NotNull SunLightPlugin plugin, @NotNull ExtrasModule module) { 25 | super(plugin); 26 | //this.module = module; 27 | } 28 | 29 | @Override 30 | protected void onLoad() { 31 | this.loadCommands(); 32 | 33 | this.addListener(new SortListener(this.plugin, this)); 34 | } 35 | 36 | @Override 37 | protected void onShutdown() { 38 | 39 | } 40 | 41 | private void loadCommands() { 42 | SortCommand.load(this.plugin, this); 43 | } 44 | 45 | public static boolean isChestSortEnabled(@NotNull SunUser user) { 46 | return user.getSettings().get(SETTING_CHEST_SORT); 47 | } 48 | 49 | @NotNull 50 | private String getItemSortedId(@NotNull ItemStack item) { 51 | StringBuilder rules = new StringBuilder(); 52 | ExtrasConfig.CHEST_SORT_RULES.get().forEach(rule -> { 53 | rules.append(rule.getRule(item)); 54 | }); 55 | return rules.toString(); 56 | } 57 | 58 | public void sortInventory(@NotNull Inventory inventory) { 59 | List sorted = Arrays.stream(inventory.getContents()) 60 | .filter(item -> item != null && !item.getType().isAir()) 61 | .sorted(Comparator.comparing(this::getItemSortedId)).toList(); 62 | 63 | inventory.clear(); 64 | 65 | for (int slot = 0; slot < sorted.size(); slot++) { 66 | inventory.setItem(slot, sorted.get(slot)); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/chestsort/SortRule.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras.chestsort; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.jetbrains.annotations.NotNull; 6 | import su.nightexpress.nightcore.util.Colorizer; 7 | import su.nightexpress.nightcore.util.ItemUtil; 8 | 9 | import java.util.function.Function; 10 | 11 | public enum SortRule { 12 | 13 | IS_BLOCK(item -> { 14 | Material material = item.getType(); 15 | return material.isBlock() && material.isSolid() ? "A" : "B"; 16 | }), 17 | IS_ITEM(item -> { 18 | Material material = item.getType(); 19 | return !material.isBlock() || !material.isSolid() ? "A" : "B"; 20 | }), 21 | MATERIAL(item -> item.getType().name()), 22 | AMOUNT(item -> String.valueOf(item.getMaxStackSize() - item.getAmount())), 23 | NAME(item -> Colorizer.strip(ItemUtil.getItemName(item))) 24 | ; 25 | 26 | private final Function function; 27 | 28 | SortRule(@NotNull Function function) { 29 | this.function = function; 30 | } 31 | 32 | @NotNull 33 | public String getRule(@NotNull ItemStack item) { 34 | return this.function.apply(item); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/config/ExtrasLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | 6 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 7 | import static su.nightexpress.sunlight.Placeholders.*; 8 | 9 | public class ExtrasLang { 10 | 11 | public static final LangString COMMAND_CHAIRS_DESC = LangString.of("Extras.Command.Chairs.Desc", "Toggle Chairs."); 12 | public static final LangString COMMAND_SIT_DESC = LangString.of("Extras.Command.Sit.Desc", "Sit on a block."); 13 | public static final LangString COMMAND_CHEST_SORT_DESC = LangString.of("Extras.Command.ChestSort.Desc", "Toggle ChestSort."); 14 | 15 | public static final LangText COMMAND_CHAIRS_NOTIFY = LangText.of("Extras.Command.Chairs.Notify", 16 | LIGHT_GRAY.wrap("Set " + LIGHT_YELLOW.wrap("Chairs") + " on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 17 | ); 18 | 19 | public static final LangText COMMAND_CHAIRS_TARGET = LangText.of("Extras.Command.Chairs.Target", 20 | LIGHT_GRAY.wrap("Set " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + "'s " + LIGHT_YELLOW.wrap("Chairs") + " on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 21 | ); 22 | 23 | 24 | public static final LangText COMMAND_SIT_NOTIFY = LangText.of("Extras.Command.Sit.Notify", 25 | LIGHT_GRAY.wrap("You are sitting now.") 26 | ); 27 | 28 | public static final LangText COMMAND_SIT_TARGET = LangText.of("Extras.Command.Sit.Target", 29 | LIGHT_GRAY.wrap("Made " + LIGHT_YELLOW.wrap(PLAYER_NAME) + " to sit.") 30 | ); 31 | 32 | 33 | public static final LangText COMMAND_CHEST_SORT_NOTIFY = LangText.of("Extras.Command.ChestSort.Notify", 34 | LIGHT_GRAY.wrap("Set " + LIGHT_YELLOW.wrap("Chest Sort") + " on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 35 | ); 36 | 37 | public static final LangText COMMAND_CHEST_SORT_TARGET = LangText.of("Extras.Command.ChestSort.Target", 38 | LIGHT_GRAY.wrap("Set " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + "'s " + LIGHT_YELLOW.wrap("Chest Sort") + " on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 39 | ); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/extras/config/ExtrasPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.extras.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.config.Perms; 5 | import su.nightexpress.sunlight.Placeholders; 6 | 7 | public class ExtrasPerms { 8 | 9 | private static final String PREFIX = Perms.PREFIX + "extras."; 10 | private static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD, "Access to all Extras module functions."); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD, "Access to all Extras module commands."); 14 | 15 | public static final UniPermission COMMAND_CHAIRS = new UniPermission(PREFIX_COMMAND + "chairs"); 16 | public static final UniPermission COMMAND_CHAIRS_OTHERS = new UniPermission(PREFIX_COMMAND + "chairs.others"); 17 | public static final UniPermission COMMAND_SIT = new UniPermission(PREFIX_COMMAND + "sit"); 18 | public static final UniPermission COMMAND_SIT_OTHERS = new UniPermission(PREFIX_COMMAND + "sit.others"); 19 | public static final UniPermission COMMAND_CHEST_SORT = new UniPermission(PREFIX_COMMAND + "chestsort"); 20 | public static final UniPermission COMMAND_CHEST_SORT_OTHERS = new UniPermission(PREFIX_COMMAND + "chestsort.others"); 21 | 22 | public static final UniPermission SIGNS_COLOR = new UniPermission(PREFIX + "signs.color"); 23 | public static final UniPermission ANVILS_COLOR = new UniPermission(PREFIX + "anvils.color"); 24 | 25 | static { 26 | Perms.PLUGIN.addChildren(MODULE); 27 | 28 | MODULE.addChildren(COMMAND, SIGNS_COLOR, ANVILS_COLOR); 29 | 30 | COMMAND.addChildren( 31 | COMMAND_CHAIRS, COMMAND_CHAIRS_OTHERS, 32 | COMMAND_CHEST_SORT, COMMAND_CHEST_SORT_OTHERS, 33 | COMMAND_SIT, COMMAND_SIT_OTHERS 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/godmode/config/GodConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.godmode.config; 2 | 3 | import su.nightexpress.nightcore.config.ConfigValue; 4 | import su.nightexpress.nightcore.util.Lists; 5 | 6 | import java.util.Set; 7 | 8 | public class GodConfig { 9 | 10 | public static final ConfigValue> DISABLED_WORLDS = ConfigValue.create("Settings.Disabled_Worlds", 11 | Lists.newSet("world_name", "other_world"), 12 | "Worlds, where GodMode is not available.", 13 | "This setting can be bypasses with the '" + GodPerms.BYPASS_WORLDS.getName() + "' permission." 14 | ); 15 | 16 | public static final ConfigValue OUT_DAMAGE_PLAYERS = ConfigValue.create("Settings.OutgoingDamage.Players", 17 | false, 18 | "Sets whether or not players in GodMode can damage other players." 19 | ); 20 | 21 | public static final ConfigValue OUT_DAMAGE_MOBS = ConfigValue.create("Settings.OutgoingDamage.Mobs", 22 | true, 23 | "Sets whether or not players in GodMode can damage mobs." 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/godmode/config/GodLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.godmode.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | import su.nightexpress.nightcore.language.message.OutputType; 6 | 7 | import static su.nightexpress.nightcore.language.tag.MessageTags.OUTPUT; 8 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 9 | import static su.nightexpress.sunlight.Placeholders.*; 10 | 11 | public class GodLang { 12 | 13 | public static final LangString COMMAND_GOD_DESC = LangString.of("GodMode.Command.God.Desc", "Toggle God Mode."); 14 | public static final LangString COMMAND_FOOD_GOD_DESC = LangString.of("Command.FoodGod.Desc", "Toggle Food God."); 15 | 16 | public static final LangText COMMAND_FOOD_GOD_TARGET = LangText.of("GodMode.Command.FoodGod.Target", 17 | LIGHT_GRAY.wrap("Set Food God on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + " for " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + ".") 18 | ); 19 | 20 | public static final LangText COMMAND_FOOD_GOD_NOTIFY = LangText.of("GodMode.Command.FoodGod.Notify", 21 | LIGHT_GRAY.wrap("Food God has been set on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 22 | ); 23 | 24 | 25 | public static final LangText COMMAND_GOD_TOGGLE_NOTIFY = LangText.of("GodMode.Command.God.Notify", 26 | LIGHT_GRAY.wrap("God Mode has been set on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 27 | ); 28 | 29 | public static final LangText COMMAND_GOD_TOGGLE_TARGET = LangText.of("GodMode.Command.God.Target", 30 | LIGHT_GRAY.wrap("Set God Mode on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + " for " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + ".") 31 | ); 32 | 33 | 34 | public static final LangText NOTIFY_DISABLED_DAMAGE = LangText.of("GodMode.Notify.DamageDisabled", 35 | OUTPUT.wrap(OutputType.ACTION_BAR), 36 | LIGHT_RED.wrap("You can't inflict damage in God Mode!") 37 | ); 38 | 39 | public static final LangText NOTIFY_BAD_WORLD = LangText.of("GodMode.Notify.BadWorld", 40 | LIGHT_RED.wrap(BOLD.wrap("God Mode Info:")), 41 | LIGHT_GRAY.wrap("God Mode has no effect in this world!") 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/godmode/config/GodPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.godmode.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class GodPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "godmode."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 15 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 16 | 17 | public static final UniPermission COMMAND_GOD = new UniPermission(PREFIX_COMMAND + "god"); 18 | public static final UniPermission COMMAND_GOD_OTHERS = new UniPermission(PREFIX_COMMAND + "god.others"); 19 | public static final UniPermission COMMAND_FOOD_GOD = new UniPermission(PREFIX_COMMAND + "foodgod"); 20 | public static final UniPermission COMMAND_FOOD_GOD_OTHERS = new UniPermission(PREFIX_COMMAND + "foodgod.others"); 21 | 22 | public static final UniPermission BYPASS_WORLDS = new UniPermission(PREFIX_BYPASS + "worlds"); 23 | 24 | static { 25 | Perms.PLUGIN.addChildren(MODULE); 26 | 27 | MODULE.addChildren(COMMAND, BYPASS); 28 | 29 | COMMAND.addChildren( 30 | COMMAND_GOD, COMMAND_GOD_OTHERS, 31 | COMMAND_FOOD_GOD, COMMAND_FOOD_GOD_OTHERS 32 | ); 33 | 34 | BYPASS.addChildren( 35 | BYPASS_WORLDS 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/homes/event/PlayerHomeCreateEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.homes.event; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | public class PlayerHomeCreateEvent extends Event implements Cancellable { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final Player player; 15 | private final String homeId; 16 | private final boolean isNewHome; 17 | private Location location; 18 | 19 | private boolean cancelled; 20 | 21 | public PlayerHomeCreateEvent(@NotNull Player player, @NotNull String homeId, @NotNull Location location, boolean isNewHome) { 22 | this.player = player; 23 | this.homeId = homeId; 24 | this.isNewHome = isNewHome; 25 | this.setLocation(location); 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return HANDLER_LIST; 30 | } 31 | 32 | @NotNull 33 | @Override 34 | public HandlerList getHandlers() { 35 | return HANDLER_LIST; 36 | } 37 | 38 | @NotNull 39 | public Player getPlayer() { 40 | return player; 41 | } 42 | 43 | @NotNull 44 | public String getHomeId() { 45 | return homeId; 46 | } 47 | 48 | @NotNull 49 | public Location getLocation() { 50 | return location; 51 | } 52 | 53 | public void setLocation(@NotNull Location location) { 54 | this.location = location; 55 | } 56 | 57 | public boolean isNewHome() { 58 | return isNewHome; 59 | } 60 | 61 | @Override 62 | public boolean isCancelled() { 63 | return cancelled; 64 | } 65 | 66 | @Override 67 | public void setCancelled(boolean cancelled) { 68 | this.cancelled = cancelled; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/homes/event/PlayerHomeRemoveEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.homes.event; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | import su.nightexpress.sunlight.module.homes.impl.Home; 8 | 9 | public class PlayerHomeRemoveEvent extends Event { 10 | 11 | public static final HandlerList HANDLER_LIST = new HandlerList(); 12 | 13 | private final Player player; 14 | private final Home home; 15 | 16 | public PlayerHomeRemoveEvent(@NotNull Player player, @NotNull Home home) { 17 | this.player = player; 18 | this.home = home; 19 | } 20 | 21 | public static HandlerList getHandlerList() { 22 | return HANDLER_LIST; 23 | } 24 | 25 | @NotNull 26 | @Override 27 | public HandlerList getHandlers() { 28 | return HANDLER_LIST; 29 | } 30 | 31 | @NotNull 32 | public Player getPlayer() { 33 | return player; 34 | } 35 | 36 | @NotNull 37 | public Home getHome() { 38 | return home; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/homes/event/PlayerHomeTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.homes.event; 2 | 3 | import org.bukkit.entity.Player; 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 | import su.nightexpress.sunlight.module.homes.impl.Home; 9 | 10 | public class PlayerHomeTeleportEvent extends Event implements Cancellable { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final Player player; 15 | private final Home home; 16 | 17 | private boolean cancelled; 18 | 19 | public PlayerHomeTeleportEvent(@NotNull Player player, @NotNull Home home) { 20 | this.player = player; 21 | this.home = home; 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return HANDLER_LIST; 26 | } 27 | 28 | @NotNull 29 | @Override 30 | public HandlerList getHandlers() { 31 | return HANDLER_LIST; 32 | } 33 | 34 | @NotNull 35 | public Player getPlayer() { 36 | return player; 37 | } 38 | 39 | @NotNull 40 | public Home getHome() { 41 | return home; 42 | } 43 | 44 | @Override 45 | public boolean isCancelled() { 46 | return cancelled; 47 | } 48 | 49 | @Override 50 | public void setCancelled(boolean cancelled) { 51 | this.cancelled = cancelled; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/homes/impl/HomeType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.homes.impl; 2 | 3 | public enum HomeType { 4 | PUBLIC, 5 | PRIVATE, 6 | // TODO FRIEND_ONLY 7 | } 8 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/kits/config/KitsConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.kits.config; 2 | 3 | import su.nightexpress.nightcore.config.ConfigValue; 4 | 5 | public class KitsConfig { 6 | 7 | public static final ConfigValue BIND_ITEMS_TO_PLAYERS = ConfigValue.create("Bind_Items_To_Players", 8 | false, 9 | "When enabled, all items a player receives from a kit will be bound to that player.", 10 | "Players can not use/pick up items that are bound to other players." 11 | ); 12 | 13 | public static final ConfigValue GUI_HIDE_NO_PERMISSION = ConfigValue.create("GUI.Hide_No_Permission", 14 | false, 15 | "Sets whether or not kits with permission requirement enabled should be hidden from", 16 | "players that don't have permission to those kits." 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/kits/listener/KitBindListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.kits.listener; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.EventPriority; 7 | import org.bukkit.event.block.BlockDispenseArmorEvent; 8 | import org.bukkit.event.entity.EntityPickupItemEvent; 9 | import org.bukkit.event.inventory.InventoryClickEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.jetbrains.annotations.NotNull; 12 | import su.nightexpress.nightcore.manager.AbstractListener; 13 | import su.nightexpress.sunlight.SunLightPlugin; 14 | import su.nightexpress.sunlight.module.kits.KitsModule; 15 | import su.nightexpress.sunlight.module.kits.util.KitsUtils; 16 | 17 | public class KitBindListener extends AbstractListener { 18 | 19 | public KitBindListener(@NotNull SunLightPlugin plugin, @NotNull KitsModule module) { 20 | super(plugin); 21 | } 22 | 23 | @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) 24 | public void onBindItemPickup(EntityPickupItemEvent event) { 25 | ItemStack item = event.getItem().getItemStack(); 26 | LivingEntity entity = event.getEntity(); 27 | if (!KitsUtils.isItemOwner(item, entity)) { 28 | event.setCancelled(true); 29 | } 30 | } 31 | 32 | @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) 33 | public void onBindItemClick(InventoryClickEvent event) { 34 | ItemStack item = event.getCurrentItem(); 35 | if (item == null || item.getType().isAir()) return; 36 | 37 | Player player = (Player) event.getWhoClicked(); 38 | if (!KitsUtils.isItemOwner(item, player)) { 39 | event.setCancelled(true); 40 | } 41 | } 42 | 43 | @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) 44 | public void onBindItemDispense(BlockDispenseArmorEvent event) { 45 | ItemStack item = event.getItem(); 46 | LivingEntity entity = event.getTargetEntity(); 47 | if (!KitsUtils.isItemOwner(item, entity)) { 48 | event.setCancelled(true); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/kits/util/Placeholders.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.kits.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.util.NumberUtil; 5 | import su.nightexpress.nightcore.util.TimeUtil; 6 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 7 | import su.nightexpress.sunlight.config.Lang; 8 | import su.nightexpress.sunlight.module.kits.Kit; 9 | import su.nightexpress.sunlight.module.kits.config.KitsLang; 10 | 11 | public class Placeholders extends su.nightexpress.sunlight.Placeholders { 12 | 13 | public static final String KIT_ID = "%kit_id%"; 14 | public static final String KIT_NAME = "%kit_name%"; 15 | public static final String KIT_DESCRIPTION = "%kit_description%"; 16 | public static final String KIT_PERMISSION_REQUIRED = "%kit_permission_required%"; 17 | public static final String KIT_PERMISSION_NODE = "%kit_permission_node%"; 18 | public static final String KIT_COOLDOWN = "%kit_cooldown%"; 19 | public static final String KIT_COST = "%kit_cost_money%"; 20 | public static final String KIT_PRIORITY = "%kit_priority%"; 21 | public static final String KIT_COMMANDS = "%kit_commands%"; 22 | 23 | @NotNull 24 | public static PlaceholderMap forKit(@NotNull Kit kit) { 25 | return new PlaceholderMap() 26 | .add(KIT_ID, kit::getId) 27 | .add(KIT_NAME, kit::getName) 28 | .add(KIT_DESCRIPTION, () -> String.join("\n", kit.getDescription())) 29 | .add(KIT_PERMISSION_REQUIRED, () -> Lang.getYesOrNo(kit.isPermissionRequired())) 30 | .add(KIT_PERMISSION_NODE, kit::getPermission) 31 | .add(KIT_COOLDOWN, () -> kit.hasCooldown() ? (kit.isOneTimed() ? KitsLang.OTHER_ONE_TIMED.getString() : TimeUtil.formatTime(kit.getCooldown() * 1000L)) : KitsLang.OTHER_DISABLED.getString()) 32 | .add(KIT_COST, () -> kit.hasCost() ? NumberUtil.format(kit.getCost()) : KitsLang.OTHER_DISABLED.getString()) 33 | .add(KIT_PRIORITY, () -> String.valueOf(kit.getPriority())) 34 | .add(KIT_COMMANDS, () -> String.join("\n", kit.getCommands().stream().map(Placeholders::listEntry).toList())); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/nerfphantoms/config/PhantomsConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.nerfphantoms.config; 2 | 3 | import org.bukkit.event.entity.CreatureSpawnEvent; 4 | import su.nightexpress.nightcore.config.ConfigValue; 5 | import su.nightexpress.nightcore.util.Lists; 6 | import su.nightexpress.nightcore.util.StringUtil; 7 | 8 | import java.util.Set; 9 | 10 | public class PhantomsConfig { 11 | 12 | public static final ConfigValue DISABLE_SPAWN_ENABLED = ConfigValue.create("DisableSpawn.Enabled", 13 | false, 14 | "Sets whether or not NerfPhantoms feature is enabled."); 15 | 16 | public static final ConfigValue> DISABLE_SPAWN_REASONS = ConfigValue.forSet("DisableSpawn.Sources", 17 | raw -> StringUtil.getEnum(raw, CreatureSpawnEvent.SpawnReason.class).orElse(null), 18 | (cfg, path, set) -> cfg.set(path, set.stream().map(Enum::name).toList()), 19 | Lists.newSet( 20 | CreatureSpawnEvent.SpawnReason.NATURAL, 21 | CreatureSpawnEvent.SpawnReason.DEFAULT 22 | ), 23 | "List of disabled phantom spawn sources.", 24 | "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html" 25 | ); 26 | 27 | public static final ConfigValue DAMAGE_MODIFIER_ENABLED = ConfigValue.create("DamageModifier.Enabled", 28 | false, 29 | "Sets whether or not NerfPhantoms feature is enabled."); 30 | 31 | public static final ConfigValue DAMAGE_MODIFIER_VALUE = ConfigValue.create("DamageModifier.Value", 32 | 1D, 33 | "Sets phantom's damage modifier to players. PhantomDamage * DamageModifier = Final Damage."); 34 | 35 | public static final ConfigValue HEALTH_MODIFIER_ENABLED = ConfigValue.create("HealthModifier.Enabled", 36 | false, 37 | "Sets whether or not NerfPhantoms feature is enabled."); 38 | 39 | public static final ConfigValue HEALTH_MODIFIER_VALUE = ConfigValue.create("HealthModifier.Value", 40 | 20D, 41 | "Replaces phantom's health with specified value."); 42 | } 43 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/nerfphantoms/config/PhantomsLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.nerfphantoms.config; 2 | 3 | import su.nightexpress.nightcore.core.CoreLang; 4 | import su.nightexpress.nightcore.language.entry.LangString; 5 | import su.nightexpress.nightcore.language.entry.LangText; 6 | 7 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 8 | import static su.nightexpress.sunlight.Placeholders.*; 9 | 10 | public class PhantomsLang extends CoreLang { 11 | 12 | public static final LangString COMMAND_NO_PHANTOM_DESC = LangString.of("NerfPhantoms.Command.NoPhantom.Desc", 13 | "Toggle anti-phantom mode."); 14 | 15 | public static final LangText COMMAND_NO_PHANTOM_TOGGLE_NOTIFY = LangText.of("NerfPhantoms.Command.NoPhantom.Toggle.Notify", 16 | LIGHT_GRAY.wrap("Anti-Phantom mode: " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 17 | ); 18 | 19 | public static final LangText COMMAND_NO_PHANTOM_TOGGLE_OTHERS = LangText.of("NerfPhantoms.Command.NoPhantom.Toggle.Others", 20 | LIGHT_GRAY.wrap("Set Anti-Phantom mode " + LIGHT_YELLOW.wrap(GENERIC_STATE) + " for " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + ".") 21 | ); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/nerfphantoms/config/PhantomsPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.nerfphantoms.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class PhantomsPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "nerfphantoms."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 14 | 15 | public static final UniPermission COMMAND_NO_PHANTOM = new UniPermission(PREFIX_COMMAND + "nophantom"); 16 | public static final UniPermission COMMAND_NO_PHANTOM_OTHERS = new UniPermission(PREFIX_COMMAND + "nophantom.others"); 17 | 18 | static { 19 | Perms.PLUGIN.addChildren(MODULE); 20 | 21 | MODULE.addChildren(COMMAND); 22 | 23 | COMMAND.addChildren( 24 | COMMAND_NO_PHANTOM, 25 | COMMAND_NO_PHANTOM_OTHERS 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/nerfphantoms/listener/PhantomsListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.nerfphantoms.listener; 2 | 3 | import org.bukkit.attribute.Attribute; 4 | import org.bukkit.attribute.AttributeInstance; 5 | import org.bukkit.entity.Phantom; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.EventPriority; 8 | import org.bukkit.event.entity.CreatureSpawnEvent; 9 | import org.jetbrains.annotations.NotNull; 10 | import su.nightexpress.nightcore.manager.AbstractListener; 11 | import su.nightexpress.nightcore.util.EntityUtil; 12 | import su.nightexpress.sunlight.SunLightPlugin; 13 | import su.nightexpress.sunlight.module.nerfphantoms.PhantomsModule; 14 | import su.nightexpress.sunlight.module.nerfphantoms.config.PhantomsConfig; 15 | 16 | public class PhantomsListener extends AbstractListener { 17 | 18 | //private final PhantomsModule module; 19 | 20 | public PhantomsListener(@NotNull SunLightPlugin plugin, @NotNull PhantomsModule module) { 21 | super(plugin); 22 | //this.module = module; 23 | } 24 | 25 | @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) 26 | public void onPhantomSpawn(CreatureSpawnEvent event) { 27 | if (!(event.getEntity() instanceof Phantom phantom)) return; 28 | 29 | if (PhantomsConfig.DISABLE_SPAWN_ENABLED.get()) { 30 | if (PhantomsConfig.DISABLE_SPAWN_REASONS.get().contains(event.getSpawnReason())) { 31 | event.setCancelled(true); 32 | return; 33 | } 34 | } 35 | 36 | if (PhantomsConfig.DAMAGE_MODIFIER_ENABLED.get()) { 37 | this.modifyAttribute(phantom, Attribute.ATTACK_DAMAGE, PhantomsConfig.DAMAGE_MODIFIER_VALUE.get()); 38 | } 39 | if (PhantomsConfig.HEALTH_MODIFIER_ENABLED.get()) { 40 | this.modifyAttribute(phantom, Attribute.MAX_HEALTH, PhantomsConfig.HEALTH_MODIFIER_VALUE.get()); 41 | } 42 | } 43 | 44 | private void modifyAttribute(@NotNull Phantom phantom, @NotNull Attribute attribute, double value) { 45 | AttributeInstance instance = phantom.getAttribute(attribute); 46 | if (instance == null) return; 47 | 48 | if (attribute == Attribute.ATTACK_DAMAGE) { 49 | value = EntityUtil.getAttribute(phantom, attribute) * value; 50 | } 51 | 52 | instance.setBaseValue(value); 53 | 54 | if (attribute == Attribute.MAX_HEALTH) { 55 | phantom.setHealth(value); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/Mode.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp; 2 | 3 | public enum Mode { 4 | REQUEST, INVITE 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/TeleportRequest.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | import su.nightexpress.nightcore.util.Players; 8 | 9 | import java.util.UUID; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | public class TeleportRequest { 13 | 14 | private final UUID targetId; 15 | private final UUID senderId; 16 | private final Mode mode; 17 | 18 | private long expireDate; 19 | 20 | public TeleportRequest(@NotNull Player sender, @NotNull Player target, @NotNull Mode mode, int timeOut) { 21 | this(sender.getUniqueId(), target.getUniqueId(), mode, timeOut); 22 | } 23 | 24 | public TeleportRequest(@NotNull UUID senderId, @NotNull UUID targetId, @NotNull Mode mode, int timeOut) { 25 | this.senderId = senderId; 26 | this.targetId = targetId; 27 | this.mode = mode; 28 | this.expireDate = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(timeOut, TimeUnit.SECONDS); 29 | } 30 | 31 | public boolean isExpired() { 32 | return System.currentTimeMillis() >= this.expireDate; 33 | } 34 | 35 | public void setExpired() { 36 | this.expireDate = System.currentTimeMillis(); 37 | } 38 | 39 | public boolean isSender(@NotNull String name) { 40 | return Players.getPlayer(name) == this.getSender(); 41 | //return this.senderInfo.getName().equalsIgnoreCase(name); 42 | } 43 | 44 | public boolean isTarget(@NotNull String name) { 45 | return Players.getPlayer(name) == this.getTarget(); 46 | //return this.targetInfo.getName().equalsIgnoreCase(name); 47 | } 48 | 49 | @Nullable 50 | public Player getSender() { 51 | return Bukkit.getPlayer(this.senderId); 52 | } 53 | 54 | @Nullable 55 | public Player getTarget() { 56 | return Bukkit.getPlayer(this.targetId); 57 | } 58 | 59 | @NotNull 60 | public UUID getSenderId() { 61 | return this.senderId; 62 | } 63 | 64 | @NotNull 65 | public UUID getTargetId() { 66 | return this.targetId; 67 | } 68 | 69 | @NotNull 70 | public Mode getMode() { 71 | return this.mode; 72 | } 73 | 74 | public long getExpireDate() { 75 | return this.expireDate; 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/command/PTPCommand.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp.command; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.sunlight.SunLightPlugin; 5 | import su.nightexpress.sunlight.command.CommandRegistry; 6 | import su.nightexpress.sunlight.command.template.CommandTemplate; 7 | import su.nightexpress.sunlight.module.ptp.PTPModule; 8 | import su.nightexpress.sunlight.module.ptp.config.PTPPerms; 9 | 10 | public class PTPCommand { 11 | 12 | public static void load(@NotNull SunLightPlugin plugin, @NotNull PTPModule module) { 13 | CommandRegistry.addTemplate("ptp", CommandTemplate.group(new String[]{"ptp"}, 14 | "PTP Commands.", 15 | PTPPerms.PREFIX_COMMAND + "ptp", 16 | CommandTemplate.direct(new String[]{"request"}, RequestCommands.NODE_REQUEST), 17 | CommandTemplate.direct(new String[]{"invite"}, RequestCommands.NODE_INVITE), 18 | CommandTemplate.direct(new String[]{"accept"}, AcceptCommands.NODE_ACCEPT), 19 | CommandTemplate.direct(new String[]{"decline"}, AcceptCommands.NODE_DECLINE), 20 | CommandTemplate.direct(new String[]{"toggle"}, ToggleCommand.NODE) 21 | )); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/config/PTPConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp.config; 2 | 3 | import su.nightexpress.nightcore.config.ConfigValue; 4 | 5 | public class PTPConfig { 6 | 7 | public static final ConfigValue REQUEST_TIMEOUT = ConfigValue.create("Request_Timeout", 8 | 60, 9 | "Sets how long (in seconds) teleport request will be valid to accept/decline it." 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/config/PTPPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class PTPPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "ptp."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 14 | 15 | public static final UniPermission COMMAND_ACCEPT = new UniPermission(PREFIX_COMMAND + "accept"); 16 | public static final UniPermission COMMAND_DECLINE = new UniPermission(PREFIX_COMMAND + "decline"); 17 | public static final UniPermission COMMAND_INVITE = new UniPermission(PREFIX_COMMAND + "invite"); 18 | public static final UniPermission COMMAND_REQUEST = new UniPermission(PREFIX_COMMAND + "request"); 19 | public static final UniPermission COMMAND_TOGGLE = new UniPermission(PREFIX_COMMAND + "toggle"); 20 | public static final UniPermission COMMAND_TOGGLE_OTHERS = new UniPermission(PREFIX_COMMAND + "toggle.others"); 21 | 22 | static { 23 | Perms.PLUGIN.addChildren(MODULE); 24 | 25 | MODULE.addChildren(COMMAND); 26 | 27 | COMMAND.addChildren( 28 | COMMAND_ACCEPT, COMMAND_DECLINE, 29 | COMMAND_INVITE, COMMAND_REQUEST, 30 | COMMAND_TOGGLE, COMMAND_TOGGLE_OTHERS 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/ptp/listener/PTPListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.ptp.listener; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.player.PlayerQuitEvent; 6 | import org.jetbrains.annotations.NotNull; 7 | import su.nightexpress.nightcore.manager.AbstractListener; 8 | import su.nightexpress.sunlight.SunLightPlugin; 9 | import su.nightexpress.sunlight.module.ptp.PTPModule; 10 | 11 | public class PTPListener extends AbstractListener { 12 | 13 | private final PTPModule module; 14 | 15 | public PTPListener(@NotNull SunLightPlugin plugin, @NotNull PTPModule module) { 16 | super(plugin); 17 | this.module = module; 18 | } 19 | 20 | @EventHandler(priority = EventPriority.MONITOR) 21 | public void onQuit(@NotNull PlayerQuitEvent event) { 22 | this.module.clearRequests(event.getPlayer()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/rtp/command/RTPCommands.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.rtp.command; 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.SunLightPlugin; 11 | import su.nightexpress.sunlight.command.CommandRegistry; 12 | import su.nightexpress.sunlight.command.template.CommandTemplate; 13 | import su.nightexpress.sunlight.module.rtp.RTPModule; 14 | import su.nightexpress.sunlight.module.rtp.config.RTPLang; 15 | import su.nightexpress.sunlight.module.rtp.config.RTPPerms; 16 | 17 | public class RTPCommands { 18 | 19 | public static final String NODE = "rtp"; 20 | 21 | public static void load(@NotNull SunLightPlugin plugin, @NotNull RTPModule module) { 22 | CommandRegistry.registerDirectExecutor(NODE, (template, config) -> builder(plugin, module, template, config)); 23 | 24 | CommandRegistry.addTemplate(NODE, CommandTemplate.direct(new String[]{NODE, "wild"}, NODE)); 25 | } 26 | 27 | @NotNull 28 | public static DirectNodeBuilder builder(@NotNull SunLightPlugin plugin, @NotNull RTPModule module, @NotNull CommandTemplate template, @NotNull FileConfig config) { 29 | return DirectNode.builder(plugin, template.getAliases()) 30 | .playerOnly() 31 | .description(RTPLang.COMMAND_RTP_DESC) 32 | .permission(RTPPerms.COMMAND_RTP) 33 | .executes((context, arguments) -> execute(plugin, module, context, arguments)) 34 | ; 35 | } 36 | 37 | public static boolean execute(@NotNull SunLightPlugin plugin, @NotNull RTPModule module, @NotNull CommandContext context, @NotNull ParsedArguments arguments) { 38 | Player player = context.getPlayerOrThrow(); 39 | module.startSearch(player); 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/rtp/config/RTPLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.rtp.config; 2 | 3 | import org.bukkit.Sound; 4 | import su.nightexpress.nightcore.language.entry.LangString; 5 | import su.nightexpress.nightcore.language.entry.LangText; 6 | 7 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 8 | import static su.nightexpress.sunlight.Placeholders.*; 9 | import static su.nightexpress.nightcore.language.tag.MessageTags.*; 10 | 11 | public class RTPLang { 12 | 13 | public static final LangString COMMAND_RTP_DESC = LangString.of("RTP.Command.RTP.Desc", "Teleport to a random place."); 14 | 15 | public static final LangText ERROR_ALREADY_IN = LangText.of("RTP.Teleport.Error.AlreadyIn", 16 | LIGHT_RED.wrap("You're already in RTP!") 17 | ); 18 | 19 | public static final LangText TELEPORT_ERROR_INVALID_RANGE = LangText.of("RTP.Teleport.Error.InvalidRange", 20 | LIGHT_RED.wrap("Random teleport is not supported for this world or have invalid range settings.") 21 | ); 22 | 23 | public static final LangText TELEPORT_NOTIFY_DONE = LangText.of("RTP.Teleport.Notify.Done", 24 | OUTPUT.wrap(20, 80) + SOUND.wrap(Sound.ENTITY_ENDERMAN_TELEPORT), 25 | LIGHT_GREEN.wrap(BOLD.wrap("Successful Teleport!")), 26 | LIGHT_GRAY.wrap("Location: " + LIGHT_GREEN.wrap(LOCATION_X) + ", " + LIGHT_GREEN.wrap(LOCATION_Y) + ", " + LIGHT_GREEN.wrap(LOCATION_Z)) 27 | ); 28 | 29 | public static final LangText TELEPORT_NOTIFY_SEARCH = LangText.of("RTP.Teleport.Notify.Search", 30 | OUTPUT.wrap(20, 80) + SOUND.wrap(Sound.BLOCK_LAVA_POP), 31 | LIGHT_YELLOW.wrap(BOLD.wrap("Search for location...")), 32 | LIGHT_GRAY.wrap("Step: " + LIGHT_YELLOW.wrap(GENERIC_CURRENT) + "/" + LIGHT_YELLOW.wrap(GENERIC_MAX)) 33 | ); 34 | 35 | public static final LangText TELEPORT_NOTIFY_FAILURE = LangText.of("RTP.Teleport.Notify.Failure", 36 | OUTPUT.wrap(20, 80) + SOUND.wrap(Sound.ENTITY_VILLAGER_NO), 37 | LIGHT_RED.wrap(BOLD.wrap("Teleport Failed")), 38 | LIGHT_GRAY.wrap("Could not find a valid location.") 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/rtp/config/RTPPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.rtp.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.config.Perms; 5 | import su.nightexpress.sunlight.Placeholders; 6 | 7 | public class RTPPerms { 8 | 9 | private static final String PREFIX = Perms.PREFIX + "rtp."; 10 | private static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 14 | 15 | public static final UniPermission COMMAND_RTP = new UniPermission(PREFIX_COMMAND + "rtp"); 16 | 17 | static { 18 | Perms.PLUGIN.addChildren(MODULE); 19 | 20 | MODULE.addChildren(COMMAND); 21 | 22 | COMMAND.addChildren(COMMAND_RTP); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/rtp/listener/RTPListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.rtp.listener; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.entity.PlayerDeathEvent; 6 | import org.bukkit.event.player.PlayerQuitEvent; 7 | import org.jetbrains.annotations.NotNull; 8 | import su.nightexpress.nightcore.manager.AbstractListener; 9 | import su.nightexpress.sunlight.SunLightPlugin; 10 | import su.nightexpress.sunlight.module.rtp.RTPModule; 11 | 12 | public class RTPListener extends AbstractListener { 13 | 14 | private final RTPModule module; 15 | 16 | public RTPListener(@NotNull SunLightPlugin plugin, @NotNull RTPModule module) { 17 | super(plugin); 18 | this.module = module; 19 | } 20 | 21 | @EventHandler(priority = EventPriority.NORMAL) 22 | public void onPlayerQuit(@NotNull PlayerQuitEvent event) { 23 | this.module.stopSearch(event.getPlayer()); 24 | } 25 | 26 | @EventHandler(priority = EventPriority.NORMAL) 27 | public void onPlayerDeath(@NotNull PlayerDeathEvent event) { 28 | this.module.stopSearch(event.getEntity()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/scoreboard/board/Board.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.scoreboard.board; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface Board { 6 | 7 | @NotNull BoardConfig getBoardConfig(); 8 | 9 | void create(); 10 | 11 | void update(); 12 | 13 | void updateIfReady(); 14 | 15 | void remove(); 16 | } 17 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/scoreboard/board/BoardProvider.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.scoreboard.board; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.module.scoreboard.ScoreboardModule; 6 | 7 | public interface BoardProvider { 8 | 9 | @NotNull 10 | Board create(@NotNull Player player, @NotNull ScoreboardModule module, @NotNull BoardConfig config); 11 | } 12 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/scoreboard/config/SBLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.scoreboard.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | 6 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 7 | import static su.nightexpress.sunlight.Placeholders.*; 8 | 9 | public class SBLang { 10 | 11 | public static final LangString COMMAND_SCOREBOARD_DESC = LangString.of("Scoreboard.Command.Scoreboard.Desc", 12 | "Toggle scoreboard."); 13 | 14 | public static final LangText COMMAND_SCOREBOARD_NOTIFY = LangText.of("Scoreboard.Command.Scoreboard.Notify", 15 | LIGHT_GRAY.wrap("Scoreboard: " + LIGHT_YELLOW.wrap(GENERIC_STATE)) 16 | ); 17 | 18 | public static final LangText COMMAND_SCOREBOARD_TARGET = LangText.of("Scoreboard.Command.Scoreboard.Target", 19 | LIGHT_GRAY.wrap("Set Scoreboard " + LIGHT_YELLOW.wrap(GENERIC_STATE) + " for " + LIGHT_YELLOW.wrap(PLAYER_NAME) + ".") 20 | ); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/scoreboard/config/SBPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.scoreboard.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.config.Perms; 5 | import su.nightexpress.sunlight.Placeholders; 6 | 7 | public class SBPerms { 8 | 9 | private static final String PREFIX = Perms.PREFIX + "scoreboard."; 10 | private static final String PREFIX_COMMAND = PREFIX + "command."; 11 | 12 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 13 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 14 | 15 | public static final UniPermission COMMAND_SCOREBOARD = new UniPermission(PREFIX_COMMAND + "scoreboard"); 16 | public static final UniPermission COMMAND_SCOREBOARD_OTHERS = new UniPermission(PREFIX_COMMAND + "scoreboard.others"); 17 | 18 | static { 19 | Perms.PLUGIN.addChildren(MODULE); 20 | 21 | MODULE.addChildren(COMMAND); 22 | 23 | COMMAND.addChildren( 24 | COMMAND_SCOREBOARD, 25 | COMMAND_SCOREBOARD_OTHERS 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/scoreboard/listener/ScoreboardListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.scoreboard.listener; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerChangedWorldEvent; 7 | import org.bukkit.event.player.PlayerJoinEvent; 8 | import org.bukkit.event.player.PlayerQuitEvent; 9 | import org.jetbrains.annotations.NotNull; 10 | import su.nightexpress.nightcore.manager.AbstractListener; 11 | import su.nightexpress.sunlight.SunLightPlugin; 12 | import su.nightexpress.sunlight.module.scoreboard.ScoreboardModule; 13 | import su.nightexpress.sunlight.module.scoreboard.board.Board; 14 | import su.nightexpress.sunlight.module.scoreboard.board.BoardConfig; 15 | 16 | public class ScoreboardListener extends AbstractListener { 17 | 18 | private final ScoreboardModule module; 19 | 20 | public ScoreboardListener(@NotNull SunLightPlugin plugin, @NotNull ScoreboardModule module) { 21 | super(plugin); 22 | this.module = module; 23 | } 24 | 25 | @EventHandler(priority = EventPriority.MONITOR) 26 | public void onBoardWorldChange(PlayerChangedWorldEvent event) { 27 | Player player = event.getPlayer(); 28 | if (!this.module.isScoreboardEnabled(player)) return; 29 | 30 | Board board = this.module.getBoard(player); 31 | BoardConfig currentBoard = board != null ? board.getBoardConfig() : null; 32 | BoardConfig worldBoard = this.module.getBoardConfig(player); 33 | 34 | if (currentBoard != null) { 35 | this.module.removeBoard(player); 36 | } 37 | if (worldBoard != null) { 38 | this.module.addBoard(player, worldBoard); 39 | } 40 | } 41 | 42 | @EventHandler(priority = EventPriority.MONITOR) 43 | public void onBoardJoin(PlayerJoinEvent event) { 44 | Player player = event.getPlayer(); 45 | if (!this.module.isScoreboardEnabled(player)) return; 46 | 47 | this.module.addBoard(player); 48 | } 49 | 50 | @EventHandler(priority = EventPriority.MONITOR) 51 | public void onBoardQuit(PlayerQuitEvent event) { 52 | Player player = event.getPlayer(); 53 | this.module.removeBoard(player); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/spawns/config/SpawnsConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.spawns.config; 2 | 3 | import su.nightexpress.nightcore.config.ConfigValue; 4 | import su.nightexpress.sunlight.module.spawns.util.Placeholders; 5 | 6 | public class SpawnsConfig { 7 | 8 | public static final ConfigValue RESPECT_PLAYER_RESPAWN_LOCATION = ConfigValue.create("Global.Respect_Player_Beds", 9 | true, 10 | "When enabled, players with respawn location (a bed or an respawn anchor) won't teleported to a spawn on death." 11 | ); 12 | 13 | public static final ConfigValue DEFAULT_SPAWN = ConfigValue.create("Settings.Default_Spawn", 14 | Placeholders.DEFAULT, 15 | "Sets spawn used by default.", 16 | "If no other spawn is set, specified or available, the default one will be used.", 17 | "Examples:", 18 | "- When player types /spawn command without spawn name.", 19 | "", 20 | "[*] Players always has access to the default spawn." 21 | ); 22 | 23 | public static final ConfigValue NEWBIE_TELEPORT_ENABLED = ConfigValue.create("Teleport_New_Players.Enabled", 24 | true, 25 | "Sets whether or not players joined the first time should be teleported to a certain spawn." 26 | ); 27 | 28 | public static final ConfigValue NEWBIE_TELEPORT_TARGET = ConfigValue.create("Teleport_New_Players.SpawnId", 29 | Placeholders.DEFAULT, 30 | "Sets spawn ID for new players teleportation.", 31 | "Spawn permission check will be ignored for new players." 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/spawns/config/SpawnsPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.spawns.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.config.Perms; 5 | import su.nightexpress.sunlight.module.ModuleId; 6 | import su.nightexpress.sunlight.module.spawns.util.Placeholders; 7 | 8 | public class SpawnsPerms { 9 | 10 | public static final String PREFIX = Perms.PREFIX + ModuleId.SPAWNS + "."; 11 | public static final String PREFIX_SPAWN = PREFIX + "spawn."; 12 | public static final String PREFIX_COMMAND = PREFIX + "command."; 13 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 14 | 15 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 16 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 17 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 18 | public static final UniPermission SPAWN = new UniPermission(PREFIX_SPAWN + Placeholders.WILDCARD); 19 | 20 | public static final UniPermission COMMAND_SPAWNS_CREATE = new UniPermission(PREFIX_COMMAND + "spawns.create"); 21 | public static final UniPermission COMMAND_SPAWNS_DELETE = new UniPermission(PREFIX_COMMAND + "spawns.delete"); 22 | public static final UniPermission COMMAND_SPAWNS_TELEPORT = new UniPermission(PREFIX_COMMAND + "spawns.teleport"); 23 | public static final UniPermission COMMAND_SPAWNS_TELEPORT_OTHERS = new UniPermission(PREFIX_COMMAND + "spawns.teleport.others"); 24 | public static final UniPermission COMMAND_SPAWNS_EDITOR = new UniPermission(PREFIX_COMMAND + "spawns.editor"); 25 | 26 | static { 27 | Perms.PLUGIN.addChildren(MODULE); 28 | 29 | MODULE.addChildren( 30 | COMMAND, 31 | BYPASS 32 | ); 33 | 34 | COMMAND.addChildren( 35 | COMMAND_SPAWNS_CREATE, 36 | COMMAND_SPAWNS_DELETE, 37 | COMMAND_SPAWNS_EDITOR, 38 | COMMAND_SPAWNS_TELEPORT, COMMAND_SPAWNS_TELEPORT_OTHERS 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/spawns/event/PlayerSpawnTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.spawns.event; 2 | 3 | import org.bukkit.entity.Player; 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 | import su.nightexpress.sunlight.module.spawns.impl.Spawn; 9 | 10 | public class PlayerSpawnTeleportEvent extends Event implements Cancellable { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final Player player; 15 | private final Spawn spawn; 16 | 17 | private boolean cancelled; 18 | 19 | public PlayerSpawnTeleportEvent(@NotNull Player player, @NotNull Spawn spawn) { 20 | this.player = player; 21 | this.spawn = spawn; 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return HANDLER_LIST; 26 | } 27 | 28 | @NotNull 29 | @Override 30 | public HandlerList getHandlers() { 31 | return HANDLER_LIST; 32 | } 33 | 34 | @NotNull 35 | public Player getPlayer() { 36 | return player; 37 | } 38 | 39 | @NotNull 40 | public Spawn getSpawn() { 41 | return spawn; 42 | } 43 | 44 | @Override 45 | public boolean isCancelled() { 46 | return cancelled; 47 | } 48 | 49 | @Override 50 | public void setCancelled(boolean cancelled) { 51 | this.cancelled = cancelled; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/spawns/listener/SpawnListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.spawns.listener; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.bukkit.event.player.PlayerRespawnEvent; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.manager.AbstractListener; 10 | import su.nightexpress.sunlight.SunLightPlugin; 11 | import su.nightexpress.sunlight.data.user.SunUser; 12 | import su.nightexpress.sunlight.module.spawns.SpawnsModule; 13 | import su.nightexpress.sunlight.module.spawns.config.SpawnsConfig; 14 | import su.nightexpress.sunlight.module.spawns.impl.Spawn; 15 | 16 | public class SpawnListener extends AbstractListener { 17 | 18 | private final SpawnsModule module; 19 | 20 | public SpawnListener(@NotNull SunLightPlugin plugin, @NotNull SpawnsModule module) { 21 | super(plugin); 22 | this.module = module; 23 | } 24 | 25 | @EventHandler(priority = EventPriority.LOWEST) 26 | public void onSpawnJoin(PlayerJoinEvent event) { 27 | Player player = event.getPlayer(); 28 | SunUser user = this.plugin.getUserManager().getUserData(player); 29 | Spawn spawn; 30 | if (!user.hasPlayedBefore()) { 31 | if (!SpawnsConfig.NEWBIE_TELEPORT_ENABLED.get()) return; 32 | 33 | spawn = this.module.getNewbieSpawn(player); 34 | } 35 | else spawn = this.module.getLoginSpawn(player); 36 | 37 | if (spawn == null || !spawn.isValid()) return; 38 | 39 | spawn.teleport(player, true, true); 40 | } 41 | 42 | @EventHandler(priority = EventPriority.LOWEST) 43 | public void onSpawnRespawn(PlayerRespawnEvent event) { 44 | Player player = event.getPlayer(); 45 | if (player.getBedSpawnLocation() != null && SpawnsConfig.RESPECT_PLAYER_RESPAWN_LOCATION.get()) return; 46 | 47 | Spawn spawn = this.module.getDeathSpawn(player); 48 | if (spawn == null || !spawn.isValid()) return; 49 | 50 | event.setRespawnLocation(spawn.getLocation()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/tab/handler/NametagHandler.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.tab.handler; 2 | 3 | import me.clip.placeholderapi.PlaceholderAPI; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.NotNull; 7 | import su.nightexpress.nightcore.manager.SimpleManager; 8 | import su.nightexpress.nightcore.util.Plugins; 9 | import su.nightexpress.sunlight.SunLightPlugin; 10 | import su.nightexpress.sunlight.module.tab.impl.NameTagFormat; 11 | import su.nightexpress.sunlight.utils.SunUtils; 12 | 13 | import java.util.Collection; 14 | 15 | public abstract class NametagHandler extends SimpleManager { 16 | 17 | public NametagHandler(@NotNull SunLightPlugin plugin) { 18 | super(plugin); 19 | } 20 | 21 | public void sendTeamPacket(@NotNull Player playerOfTeam, @NotNull NameTagFormat tag) { 22 | String uuid = SunUtils.createIdentifier(playerOfTeam); 23 | String teamId = tag.getIndex() + tag.getId() + uuid; 24 | if (teamId.length() > 16) teamId = teamId.substring(0, 16); 25 | 26 | String teamPrefix = tag.getPrefix(); 27 | String teamSuffix = tag.getSuffix(); 28 | String teamColorRaw = tag.getColor(); 29 | 30 | if (Plugins.hasPlaceholderAPI()) { 31 | teamPrefix = PlaceholderAPI.setPlaceholders(playerOfTeam, teamPrefix); 32 | teamSuffix = PlaceholderAPI.setPlaceholders(playerOfTeam, teamSuffix); 33 | teamColorRaw = PlaceholderAPI.setPlaceholders(playerOfTeam, teamColorRaw); 34 | } 35 | 36 | Collection receivers = Bukkit.getServer().getOnlinePlayers(); 37 | 38 | for (TeamMode mode : TeamMode.values()) { 39 | this.sendPacket(mode, teamId, teamPrefix, teamSuffix, teamColorRaw, playerOfTeam, receivers); 40 | } 41 | } 42 | 43 | protected abstract void sendPacket(@NotNull TeamMode mode, 44 | @NotNull String teamId, 45 | @NotNull String teamPrefix, 46 | @NotNull String teamSuffix, 47 | @NotNull String teamColorRaw, 48 | @NotNull Player playerOfTeam, 49 | @NotNull Collection receivers); 50 | 51 | public enum TeamMode { 52 | REMOVE(1), 53 | CREATE(0); 54 | 55 | public final int index; 56 | 57 | TeamMode(int index) { 58 | this.index = index; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/tab/impl/TabNameFormat.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.tab.impl; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.config.FileConfig; 5 | import su.nightexpress.sunlight.Placeholders; 6 | 7 | public class TabNameFormat { 8 | 9 | private final int priority; 10 | private final String format; 11 | 12 | public TabNameFormat(int priority, @NotNull String format) { 13 | this.priority = priority; 14 | this.format = format; 15 | } 16 | 17 | @NotNull 18 | public static TabNameFormat read(@NotNull FileConfig config, @NotNull String path) { 19 | int priority = config.getInt(path + ".Priority"); 20 | String format = config.getString(path + ".Format", Placeholders.PLAYER_DISPLAY_NAME); 21 | 22 | return new TabNameFormat(priority, format); 23 | } 24 | 25 | public void write (@NotNull FileConfig config, @NotNull String path) { 26 | config.set(path + ".Priority", this.getPriority()); 27 | config.set(path + ".Format", this.getFormat()); 28 | } 29 | 30 | public int getPriority() { 31 | return priority; 32 | } 33 | 34 | @NotNull 35 | public String getFormat() { 36 | return format; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/tab/listener/TabListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.tab.listener; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.bukkit.event.player.PlayerRespawnEvent; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.manager.AbstractListener; 10 | import su.nightexpress.sunlight.SunLightPlugin; 11 | import su.nightexpress.sunlight.module.tab.TabModule; 12 | 13 | public class TabListener extends AbstractListener { 14 | 15 | private final TabModule module; 16 | 17 | public TabListener(@NotNull SunLightPlugin plugin, @NotNull TabModule module) { 18 | super(plugin); 19 | this.module = module; 20 | } 21 | 22 | @EventHandler(priority = EventPriority.MONITOR) 23 | public void onUpdateJoin(PlayerJoinEvent event) { 24 | Player player = event.getPlayer(); 25 | this.module.updateAll(player); 26 | } 27 | 28 | @EventHandler(priority = EventPriority.MONITOR) 29 | public void onUpdateRespawn(PlayerRespawnEvent event) { 30 | Player player = event.getPlayer(); 31 | this.module.updateAll(player); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/vanish/VanishListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.vanish; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.jetbrains.annotations.NotNull; 8 | import su.nightexpress.nightcore.manager.AbstractListener; 9 | import su.nightexpress.sunlight.SunLightPlugin; 10 | import su.nightexpress.sunlight.module.vanish.config.VanishPerms; 11 | 12 | public class VanishListener extends AbstractListener { 13 | 14 | private final VanishModule module; 15 | 16 | public VanishListener(@NotNull SunLightPlugin plugin, @NotNull VanishModule module) { 17 | super(plugin); 18 | this.module = module; 19 | } 20 | 21 | @EventHandler(priority = EventPriority.MONITOR) 22 | public void onJoin(PlayerJoinEvent event) { 23 | Player player = event.getPlayer(); 24 | if (player.hasPermission(VanishPerms.BYPASS_SEE)) return; 25 | 26 | for (Player vanished : plugin.getServer().getOnlinePlayers()) { 27 | if (vanished == player || !this.module.isVanished(vanished)) continue; 28 | 29 | player.hidePlayer(plugin, vanished); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/vanish/VanishModule.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.vanish; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.SunLightPlugin; 6 | import su.nightexpress.sunlight.core.user.settings.Setting; 7 | import su.nightexpress.sunlight.core.user.settings.SettingRegistry; 8 | import su.nightexpress.sunlight.data.user.SunUser; 9 | import su.nightexpress.sunlight.module.Module; 10 | import su.nightexpress.sunlight.module.ModuleInfo; 11 | import su.nightexpress.sunlight.module.vanish.command.VanishCommand; 12 | import su.nightexpress.sunlight.module.vanish.config.VanishConfig; 13 | import su.nightexpress.sunlight.module.vanish.config.VanishLang; 14 | import su.nightexpress.sunlight.module.vanish.config.VanishPerms; 15 | 16 | public class VanishModule extends Module { 17 | 18 | public static final Setting VANISH = SettingRegistry.register(Setting.create("vanish", false, false)); 19 | 20 | public VanishModule(@NotNull SunLightPlugin plugin, @NotNull String id) { 21 | super(plugin, id); 22 | } 23 | 24 | @Override 25 | protected void gatherInfo(@NotNull ModuleInfo moduleInfo) { 26 | moduleInfo.setConfigClass(VanishConfig.class); 27 | moduleInfo.setLangClass(VanishLang.class); 28 | moduleInfo.setPermissionsClass(VanishPerms.class); 29 | } 30 | 31 | @Override 32 | protected void onModuleLoad() { 33 | VanishCommand.load(this.plugin, this); 34 | 35 | this.addListener(new VanishListener(this.plugin, this)); 36 | } 37 | 38 | @Override 39 | protected void onModuleUnload() { 40 | 41 | } 42 | 43 | public boolean isVanished(@NotNull Player player) { 44 | SunUser user = this.plugin.getUserManager().getUserData(player); 45 | return user.getSettings().get(VANISH); 46 | } 47 | 48 | public void vanish(@NotNull Player player, boolean isVanished) { 49 | for (Player other : this.plugin.getServer().getOnlinePlayers()) { 50 | if (isVanished) { 51 | if (!other.hasPermission(VanishPerms.BYPASS_SEE)) { 52 | other.hidePlayer(this.plugin, player); 53 | } 54 | } 55 | else { 56 | other.showPlayer(this.plugin, player); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/vanish/config/VanishConfig.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.vanish.config; 2 | 3 | public class VanishConfig { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/vanish/config/VanishLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.vanish.config; 2 | 3 | import su.nightexpress.nightcore.language.entry.LangString; 4 | import su.nightexpress.nightcore.language.entry.LangText; 5 | 6 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 7 | import static su.nightexpress.sunlight.Placeholders.*; 8 | 9 | public class VanishLang { 10 | 11 | public static final LangString COMMAND_VANISH_DESC = LangString.of("Command.Vanish.Desc", "Toggle Vanish."); 12 | 13 | public static final LangText COMMAND_VANISH_NOTIFY = LangText.of("Command.Vanish.Notify", 14 | LIGHT_GRAY.wrap("Vanish has been set on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + ".") 15 | ); 16 | 17 | public static final LangText COMMAND_VANISH_TARGET = LangText.of("Command.Vanish.Target", 18 | LIGHT_GRAY.wrap("Set Vanish on " + LIGHT_YELLOW.wrap(GENERIC_STATE) + " for " + LIGHT_YELLOW.wrap(PLAYER_DISPLAY_NAME) + ".") 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/vanish/config/VanishPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.vanish.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class VanishPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "vanish."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 15 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 16 | 17 | public static final UniPermission COMMAND_VANISH = new UniPermission(PREFIX_COMMAND + "vanish"); 18 | public static final UniPermission COMMAND_VANISH_OTHERS = new UniPermission(PREFIX_COMMAND + "vanish.others"); 19 | 20 | public static final UniPermission BYPASS_SEE = new UniPermission(PREFIX_BYPASS + "see"); 21 | 22 | static { 23 | Perms.PLUGIN.addChildren(MODULE); 24 | 25 | MODULE.addChildren(COMMAND, BYPASS); 26 | 27 | COMMAND.addChildren( 28 | COMMAND_VANISH, COMMAND_VANISH_OTHERS 29 | ); 30 | 31 | BYPASS.addChildren( 32 | BYPASS_SEE 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warmups/config/WarmupsLang.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warmups.config; 2 | 3 | import org.bukkit.Sound; 4 | import su.nightexpress.nightcore.core.CoreLang; 5 | import su.nightexpress.nightcore.language.entry.LangText; 6 | 7 | import static su.nightexpress.nightcore.util.text.tag.Tags.*; 8 | import static su.nightexpress.nightcore.util.Placeholders.*; 9 | import static su.nightexpress.nightcore.language.tag.MessageTags.*; 10 | 11 | public class WarmupsLang extends CoreLang { 12 | 13 | public static final LangText WARMUP_TELEPORT_NOTIFY = LangText.of("Warmup.Teleport.Notify", 14 | OUTPUT.wrap(20, 60) + SOUND.wrap(Sound.BLOCK_LAVA_POP), 15 | LIGHT_GREEN.wrap(BOLD.wrap("Teleport Warmup")), 16 | LIGHT_GRAY.wrap("Don't move, you'll be teleported soon...") 17 | ); 18 | 19 | public static final LangText WARMUP_TELEPORT_CANCEL = LangText.of("Warmup.Teleport.Cancel", 20 | OUTPUT.wrap(20, 60) + SOUND.wrap(Sound.ENTITY_VILLAGER_NO), 21 | LIGHT_RED.wrap(BOLD.wrap("Teleport Cancelled")), 22 | LIGHT_GRAY.wrap("Teleport cancelled due to movement.") 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warmups/config/WarmupsPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warmups.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class WarmupsPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "warmups."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 15 | 16 | public static final UniPermission BYPASS_TELEPORT = new UniPermission(PREFIX_BYPASS + "teleport"); 17 | public static final UniPermission BYPASS_COMMAND = new UniPermission(PREFIX_BYPASS + "command"); 18 | 19 | static { 20 | Perms.PLUGIN.addChildren(MODULE); 21 | 22 | MODULE.addChildren(BYPASS); 23 | 24 | BYPASS.addChildren( 25 | BYPASS_TELEPORT, 26 | BYPASS_COMMAND 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warmups/impl/TeleportWarmup.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warmups.impl; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.boss.BarColor; 5 | import org.bukkit.boss.BarStyle; 6 | import org.bukkit.entity.Player; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | import su.nightexpress.sunlight.module.warmups.config.WarmupsConfig; 10 | import su.nightexpress.sunlight.module.warmups.config.WarmupsLang; 11 | import su.nightexpress.sunlight.utils.SunUtils; 12 | 13 | public class TeleportWarmup extends Warmup { 14 | 15 | private final Location destination; 16 | private final Runnable action; 17 | 18 | public TeleportWarmup(@NotNull Player player, int countdown, @NotNull Location destination, @Nullable Runnable action) { 19 | super(player, countdown); 20 | this.destination = destination.clone(); 21 | this.action = action; 22 | } 23 | 24 | @Override 25 | protected void onInit() { 26 | WarmupsLang.WARMUP_TELEPORT_NOTIFY.getMessage().send(this.player); 27 | } 28 | 29 | @Override 30 | protected void onComplete() { 31 | SunUtils.teleport(this.player, this.destination, this.action); 32 | } 33 | 34 | @Override 35 | protected void onCancel(boolean silent) { 36 | if (!silent) WarmupsLang.WARMUP_TELEPORT_CANCEL.getMessage().send(this.player); 37 | } 38 | 39 | @Override 40 | @NotNull 41 | public WarmupType getType() { 42 | return WarmupType.TELEPORT; 43 | } 44 | 45 | @Override 46 | @NotNull 47 | protected String getIndicatorTitle() { 48 | return WarmupsConfig.BAR_INDICATOR_TELEPORT_TITLE.get(); 49 | } 50 | 51 | @Override 52 | @NotNull 53 | protected BarColor getIndicatorColor() { 54 | return WarmupsConfig.BAR_INDICATOR_TELEPORT_COLOR.get(); 55 | } 56 | 57 | @Override 58 | @NotNull 59 | protected BarStyle getIndicatorStyle() { 60 | return WarmupsConfig.BAR_INDICATOR_TELEPORT_STYLE.get(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warmups/impl/WarmupType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warmups.impl; 2 | 3 | public enum WarmupType { 4 | TELEPORT, 5 | COMMAND 6 | } 7 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/command/WarpShortcutCommand.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.command; 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.RootCommand; 7 | import su.nightexpress.nightcore.command.experimental.ServerCommand; 8 | import su.nightexpress.nightcore.command.experimental.argument.ParsedArguments; 9 | import su.nightexpress.sunlight.SunLightPlugin; 10 | import su.nightexpress.sunlight.module.warps.WarpsModule; 11 | import su.nightexpress.sunlight.module.warps.config.WarpsLang; 12 | import su.nightexpress.sunlight.module.warps.impl.Warp; 13 | 14 | public class WarpShortcutCommand { 15 | 16 | public static void register(@NotNull SunLightPlugin plugin, @NotNull Warp warp) { 17 | //module.getWarps().forEach(warp -> { 18 | String shortcut = warp.getCommandShortcut(); 19 | if (shortcut == null) return; 20 | 21 | ServerCommand command = RootCommand.direct(plugin, warp.getCommandShortcut(), builder -> builder 22 | .playerOnly() 23 | .description(warp.replacePlaceholders().apply(WarpsLang.COMMAND_DIRECT_WARP_DESC.getString())) 24 | .permission(warp.getPermission()) 25 | .executes((context, arguments) -> execute(plugin, warp.getModule(), context, arguments, warp.getId())) 26 | ); 27 | plugin.getCommandManager().registerCommand(command); 28 | //}); 29 | } 30 | 31 | public static void unregister(@NotNull SunLightPlugin plugin, @NotNull Warp warp) { 32 | String shortcut = warp.getCommandShortcut(); 33 | if (shortcut == null) return; 34 | 35 | plugin.getCommandManager().unregisterServerCommand(shortcut); 36 | } 37 | 38 | public static boolean execute(@NotNull SunLightPlugin plugin, @NotNull WarpsModule module, @NotNull CommandContext context, @NotNull ParsedArguments arguments, 39 | @NotNull String id) { 40 | Player player = context.getExecutor(); 41 | if (player == null) return false; 42 | 43 | Warp warp = module.getWarp(id); 44 | if (warp == null) return false; 45 | 46 | warp.teleport(player, false); 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/event/PlayerWarpTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.event; 2 | 3 | import org.bukkit.entity.Player; 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 | import su.nightexpress.sunlight.module.warps.impl.Warp; 9 | 10 | public class PlayerWarpTeleportEvent extends Event implements Cancellable { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final Player player; 15 | private final Warp warp; 16 | 17 | private boolean cancelled; 18 | 19 | public PlayerWarpTeleportEvent(@NotNull Player player, @NotNull Warp warp) { 20 | this.player = player; 21 | this.warp = warp; 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return HANDLER_LIST; 26 | } 27 | 28 | @NotNull 29 | @Override 30 | public HandlerList getHandlers() { 31 | return HANDLER_LIST; 32 | } 33 | 34 | @NotNull 35 | public Player getPlayer() { 36 | return player; 37 | } 38 | 39 | @NotNull 40 | public Warp getWarp() { 41 | return warp; 42 | } 43 | 44 | @Override 45 | public boolean isCancelled() { 46 | return cancelled; 47 | } 48 | 49 | @Override 50 | public void setCancelled(boolean cancelled) { 51 | this.cancelled = cancelled; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/menu/DisplayInfo.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.menu; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.sunlight.module.warps.type.SortType; 5 | import su.nightexpress.sunlight.module.warps.type.WarpType; 6 | 7 | public class DisplayInfo { 8 | 9 | public WarpType type; 10 | public SortType sortType; 11 | public boolean ownedOnly; 12 | 13 | public DisplayInfo(@NotNull WarpType type) { 14 | this.type = type; 15 | this.sortType = SortType.WARP_NAME; 16 | this.ownedOnly = false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/type/SortType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.type; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.manager.AbstractFileData; 5 | import su.nightexpress.nightcore.util.Colorizer; 6 | import su.nightexpress.sunlight.module.warps.impl.Warp; 7 | 8 | import java.util.Comparator; 9 | 10 | public enum SortType { 11 | 12 | WARP_NAME(Comparator.comparing(warp -> Colorizer.strip(warp.getName()))), 13 | WARP_ID(Comparator.comparing(AbstractFileData::getId)), 14 | WARP_TYPE(Comparator.comparingInt(warp -> warp.getType().ordinal())), 15 | VISIT_COST(Comparator.comparingDouble(Warp::getVisitCostMoney)) 16 | ; 17 | 18 | private final Comparator comparator; 19 | 20 | SortType(@NotNull Comparator comparator) { 21 | this.comparator = comparator; 22 | } 23 | 24 | @NotNull 25 | public Comparator getComparator() { 26 | return comparator; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/type/WarpType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.type; 2 | 3 | public enum WarpType { 4 | SERVER, PLAYER 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/warps/util/WarpUtils.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.warps.util; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.inventory.ItemStack; 6 | import org.bukkit.inventory.meta.SkullMeta; 7 | import org.jetbrains.annotations.NotNull; 8 | import su.nightexpress.nightcore.util.ItemUtil; 9 | import su.nightexpress.sunlight.module.warps.type.WarpType; 10 | 11 | public class WarpUtils { 12 | 13 | @NotNull 14 | public static ItemStack getDefaultIcon(@NotNull Player player, @NotNull WarpType type) { 15 | if (type == WarpType.SERVER) return new ItemStack(Material.COMPASS); 16 | 17 | ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD); 18 | ItemUtil.editMeta(itemStack, meta -> { 19 | SkullMeta skullMeta = (SkullMeta) meta; 20 | skullMeta.setOwnerProfile(player.getPlayerProfile()); 21 | }); 22 | return itemStack; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/config/WorldsPerms.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.config; 2 | 3 | import su.nightexpress.nightcore.util.wrapper.UniPermission; 4 | import su.nightexpress.sunlight.Placeholders; 5 | import su.nightexpress.sunlight.config.Perms; 6 | 7 | public class WorldsPerms { 8 | 9 | public static final String PREFIX = Perms.PREFIX + "worlds."; 10 | public static final String PREFIX_COMMAND = PREFIX + "command."; 11 | public static final String PREFIX_BYPASS = PREFIX + "bypass."; 12 | 13 | public static final UniPermission MODULE = new UniPermission(PREFIX + Placeholders.WILDCARD); 14 | public static final UniPermission COMMAND = new UniPermission(PREFIX_COMMAND + Placeholders.WILDCARD); 15 | public static final UniPermission BYPASS = new UniPermission(PREFIX_BYPASS + Placeholders.WILDCARD); 16 | 17 | public static final UniPermission COMMAND_WORLDS_CREATE = new UniPermission(PREFIX_COMMAND + "createworld"); 18 | public static final UniPermission COMMAND_WORLDS_DELETE = new UniPermission(PREFIX_COMMAND + "deleteworld"); 19 | public static final UniPermission COMMAND_WORLDS_LOAD = new UniPermission(PREFIX_COMMAND + "loadworld"); 20 | public static final UniPermission COMMAND_WORLDS_UNLOAD = new UniPermission(PREFIX_COMMAND + "unloadworld"); 21 | public static final UniPermission COMMAND_WORLDS_EDITOR = new UniPermission(PREFIX_COMMAND + "editor"); 22 | 23 | public static final UniPermission BYPASS_COMMANDS = new UniPermission(PREFIX_BYPASS + "commands"); 24 | public static final UniPermission BYPASS_FLY = new UniPermission(PREFIX_BYPASS + "fly"); 25 | 26 | static { 27 | Perms.PLUGIN.addChildren(MODULE); 28 | 29 | MODULE.addChildren( 30 | COMMAND, 31 | BYPASS 32 | ); 33 | 34 | COMMAND.addChildren( 35 | COMMAND_WORLDS_CREATE, 36 | COMMAND_WORLDS_DELETE, 37 | COMMAND_WORLDS_EDITOR, 38 | COMMAND_WORLDS_LOAD, 39 | COMMAND_WORLDS_UNLOAD 40 | ); 41 | 42 | BYPASS.addChildren( 43 | BYPASS_COMMANDS, 44 | BYPASS_FLY 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/impl/WrappedWorld.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.impl; 2 | 3 | import org.bukkit.World; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | import su.nightexpress.nightcore.util.placeholder.Placeholder; 7 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 8 | import su.nightexpress.sunlight.module.worlds.util.Placeholders; 9 | 10 | public class WrappedWorld implements Placeholder { 11 | 12 | private final World world; 13 | private final WorldData worldData; 14 | private final PlaceholderMap placeholders; 15 | 16 | public WrappedWorld(@Nullable World world, @Nullable WorldData worldData) { 17 | this.world = world; 18 | this.worldData = worldData; 19 | this.placeholders = Placeholders.forWrapped(this); 20 | } 21 | 22 | @NotNull 23 | @Override 24 | public PlaceholderMap getPlaceholders() { 25 | return placeholders; 26 | } 27 | 28 | public boolean isCustom() { 29 | return this.worldData != null; 30 | } 31 | 32 | public boolean isPresent() { 33 | return this.world != null; 34 | } 35 | 36 | public World getWorld() { 37 | return world; 38 | } 39 | 40 | public WorldData getData() { 41 | return worldData; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/impl/generation/FlatChunkGenerator.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.impl.generation; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.generator.ChunkGenerator; 5 | import org.bukkit.generator.WorldInfo; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Random; 9 | 10 | public class FlatChunkGenerator extends ChunkGenerator { 11 | 12 | public static final String NAME = "flat"; 13 | 14 | @Override 15 | public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int chunkX, int chunkZ, @NotNull ChunkGenerator.ChunkData chunkData) { 16 | for (int y = chunkData.getMinHeight(); y < 6 && y < chunkData.getMaxHeight(); y++) { 17 | if (y < 0) continue; 18 | 19 | for(int x = 0; x < 16; x++) { 20 | for (int z = 0; z < 16; z++) { 21 | Material material = Material.BEDROCK; 22 | 23 | if (y > 0) { 24 | if (y == 5) material = Material.GRASS_BLOCK; 25 | else material = Material.DIRT; 26 | } 27 | 28 | chunkData.setBlock(x, y, z, material); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/impl/generation/VoidChunkGenerator.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.impl.generation; 2 | 3 | import org.bukkit.generator.ChunkGenerator; 4 | import org.bukkit.generator.WorldInfo; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Random; 8 | 9 | public class VoidChunkGenerator extends ChunkGenerator { 10 | 11 | public static final String NAME = "void"; 12 | 13 | @Override 14 | public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData chunkData) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/listener/InventoryListener.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.listener; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.EventPriority; 6 | import org.bukkit.event.player.PlayerChangedWorldEvent; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.manager.AbstractListener; 10 | import su.nightexpress.sunlight.SunLightPlugin; 11 | import su.nightexpress.sunlight.module.worlds.impl.WorldInventories; 12 | import su.nightexpress.sunlight.module.worlds.WorldsModule; 13 | 14 | public class InventoryListener extends AbstractListener { 15 | 16 | private final WorldsModule module; 17 | 18 | public InventoryListener(@NotNull SunLightPlugin plugin, @NotNull WorldsModule module) { 19 | super(plugin); 20 | this.module = module; 21 | } 22 | 23 | @EventHandler(priority = EventPriority.NORMAL) 24 | public void onInventorySplitChange(PlayerChangedWorldEvent event) { 25 | Player player = event.getPlayer(); 26 | String groupTo = this.module.getWorldGroup(player.getWorld()); 27 | String groupFrom = this.module.getWorldGroup(event.getFrom()); 28 | 29 | // Do not affect snapshots for the same group 30 | if (groupFrom != null && groupTo != null) { 31 | if (groupTo.equalsIgnoreCase(groupFrom)) { 32 | return; 33 | } 34 | } 35 | 36 | WorldInventories worldInventories = this.module.getWorldInventory(player); 37 | // And here do snapshot for current player inv for world he comes from 38 | if (groupFrom != null) { 39 | worldInventories.saveInventory(player, groupFrom); 40 | } 41 | 42 | // And now replace it by the inventory of new world 43 | if (groupTo != null) { 44 | worldInventories.loadInventory(player); 45 | } 46 | } 47 | 48 | @EventHandler(priority = EventPriority.NORMAL) 49 | public void onInventorySplitQuit(PlayerQuitEvent event) { 50 | Player player = event.getPlayer(); 51 | String playerId = player.getUniqueId().toString(); 52 | 53 | WorldInventories worldInventories = this.module.getInventoryMap().remove(playerId); 54 | if (worldInventories != null) { 55 | worldInventories.save(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/util/DeletionType.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.util; 2 | 3 | public enum DeletionType { 4 | DIRECTORY, REGION, DATA, FULL 5 | } 6 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/module/worlds/util/WorldUtils.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.module.worlds.util; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.plugin.Plugin; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Collection; 8 | import java.util.stream.Collectors; 9 | import java.util.stream.Stream; 10 | 11 | public class WorldUtils { 12 | 13 | @NotNull 14 | public static Collection getGeneratorPlugins(@NotNull String worldName) { 15 | return Stream.of(Bukkit.getServer().getPluginManager().getPlugins()) 16 | .filter(plugin -> plugin.getDefaultWorldGenerator(worldName, null) != null) 17 | .collect(Collectors.toSet()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/utils/DynamicText.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.utils; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import su.nightexpress.nightcore.config.FileConfig; 5 | import su.nightexpress.nightcore.util.placeholder.Placeholder; 6 | import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.function.Function; 11 | 12 | public class DynamicText implements Placeholder { 13 | 14 | public static final Function PLACEHOLDER = id -> "%animation:" + id + "%"; 15 | 16 | private final String id; 17 | private final String[] lines; 18 | private final int interval; 19 | private final PlaceholderMap placeholders; 20 | 21 | public DynamicText(@NotNull String id, @NotNull List messages, int interval) { 22 | this.id = id.toLowerCase(); 23 | this.lines = messages.toArray(new String[0]); 24 | this.interval = Math.max(1, interval); 25 | 26 | this.placeholders = new PlaceholderMap().add(PLACEHOLDER.apply(this.id), this::getMessage); 27 | } 28 | 29 | @NotNull 30 | public static DynamicText read(@NotNull FileConfig config, @NotNull String path, @NotNull String id) { 31 | int interval = config.getInt(path + ".Update_Interval_MS"); 32 | List messages = config.getStringList(path + ".Texts"); 33 | 34 | return new DynamicText(id, messages, interval); 35 | } 36 | 37 | public void write(@NotNull FileConfig config, @NotNull String path) { 38 | config.set(path + ".Update_Interval_MS", this.interval); 39 | config.set(path + ".Texts", Arrays.asList(this.lines)); 40 | } 41 | 42 | @NotNull 43 | @Override 44 | public PlaceholderMap getPlaceholders() { 45 | return placeholders; 46 | } 47 | 48 | @NotNull 49 | public String getId() { 50 | return this.id; 51 | } 52 | 53 | @NotNull 54 | public String getMessage() { 55 | return this.lines[(int) (System.currentTimeMillis() % (this.lines.length * this.interval) / this.interval)]; 56 | } 57 | 58 | @NotNull 59 | @Deprecated 60 | public final String replace(@NotNull String text) { 61 | return text.replace(PLACEHOLDER.apply(this.id), this.getMessage()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/utils/UserInfo.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.utils; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | import su.nightexpress.sunlight.data.user.SunUser; 6 | 7 | import java.util.Objects; 8 | import java.util.UUID; 9 | 10 | public class UserInfo { 11 | 12 | private final UUID id; 13 | private final String name; 14 | 15 | public UserInfo(@NotNull Player player) { 16 | this(player.getUniqueId(), player.getName()); 17 | } 18 | 19 | public UserInfo(@NotNull SunUser user) { 20 | this(user.getId(), user.getName()); 21 | } 22 | 23 | public UserInfo(@NotNull UUID uuid, @NotNull String name) { 24 | this.id = uuid; 25 | this.name = name; 26 | } 27 | 28 | @NotNull 29 | public UUID getId() { 30 | return id; 31 | } 32 | 33 | @NotNull 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public boolean isUser(@NotNull Player player) { 39 | return player.getUniqueId().equals(this.id); 40 | } 41 | 42 | public boolean isUser(@NotNull String name) { 43 | return this.name.equalsIgnoreCase(name); 44 | } 45 | 46 | @Override 47 | public boolean equals(Object obj) { 48 | return obj instanceof UserInfo info && info.getId().equals(this.id); 49 | } 50 | 51 | @Override 52 | public int hashCode() { 53 | return Objects.hash(getId(), getName()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Core/src/main/java/su/nightexpress/sunlight/utils/pos/WorldPos.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.utils.pos; 2 | 3 | import org.bukkit.Chunk; 4 | import org.bukkit.Location; 5 | import org.bukkit.World; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | @Deprecated 9 | public interface WorldPos { 10 | 11 | @NotNull String serialize(); 12 | 13 | @NotNull 14 | default Chunk toChunk(@NotNull World world) { 15 | int chunkX = this.getX() >> 4; 16 | int chunkZ = this.getZ() >> 4; 17 | 18 | return world.getChunkAt(chunkX, chunkZ); 19 | } 20 | 21 | default boolean isChunkLoaded(@NotNull World world) { 22 | int chunkX = this.getX() >> 4; 23 | int chunkZ = this.getZ() >> 4; 24 | 25 | return world.isChunkLoaded(chunkX, chunkZ); 26 | } 27 | 28 | @NotNull 29 | default Location toLocation(@NotNull World world) { 30 | return new Location(world, this.getX(), this.getY(), this.getZ()); 31 | } 32 | 33 | @NotNull 34 | WorldPos copy(); 35 | 36 | default boolean isEmpty() { 37 | return this.getX() == 0 && this.getY() == 0 && this.getZ() == 0; 38 | } 39 | 40 | int getX(); 41 | 42 | int getY(); 43 | 44 | int getZ(); 45 | } 46 | -------------------------------------------------------------------------------- /Core/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: SunLight 2 | main: su.nightexpress.sunlight.SunLightPlugin 3 | version: '${project.version}' 4 | description: Advanced, light & modern all-in-one server management plugin. 5 | author: NightExpress 6 | depend: [ nightcore ] 7 | softdepend: 8 | - PlaceholderAPI 9 | - ProtocolLib 10 | - packetevents 11 | - DiscordSRV 12 | api-version: 1.21 -------------------------------------------------------------------------------- /MC_1_21_4/src/main/java/su/nightexpress/sunlight/nms/mc_1_21_4/container/PlayerEnderChest.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.nms.mc_1_21_4.container; 2 | 3 | import net.minecraft.world.entity.player.Player; 4 | import net.minecraft.world.inventory.PlayerEnderChestContainer; 5 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftHumanEntity; 6 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftPlayer; 7 | import org.bukkit.craftbukkit.v1_21_R3.inventory.CraftInventory; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.util.Reflex; 10 | 11 | public class PlayerEnderChest extends PlayerEnderChestContainer { 12 | 13 | private static final String ITEMS_FIELD = "c"; // 'items' 14 | 15 | private final CraftInventory inventory = new CraftInventory(this); 16 | private final CraftPlayer owner; 17 | 18 | public PlayerEnderChest(CraftPlayer owner) { 19 | super(owner.getHandle()); 20 | this.owner = owner; 21 | Reflex.setFieldValue(this, ITEMS_FIELD, owner.getHandle().getEnderChestInventory().items); 22 | } 23 | 24 | @NotNull 25 | public org.bukkit.inventory.Inventory getInventory() { 26 | return this.inventory; 27 | } 28 | 29 | private void saveOnExit() { 30 | if (!this.transaction.isEmpty()) return; 31 | this.owner.saveData(); 32 | } 33 | 34 | @Override 35 | public void onClose(CraftHumanEntity who) { 36 | super.onClose(who); 37 | this.saveOnExit(); 38 | } 39 | 40 | @Override 41 | public boolean stillValid(Player entityhuman) { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MC_1_21_4/src/main/java/su/nightexpress/sunlight/nms/mc_1_21_4/container/PlayerInventory.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.nms.mc_1_21_4.container; 2 | 3 | import net.minecraft.world.entity.player.Inventory; 4 | import net.minecraft.world.entity.player.Player; 5 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftHumanEntity; 6 | import org.bukkit.craftbukkit.v1_21_R3.entity.CraftPlayer; 7 | import org.bukkit.craftbukkit.v1_21_R3.inventory.CraftInventory; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.util.Reflex; 10 | 11 | import java.util.Arrays; 12 | 13 | public class PlayerInventory extends Inventory { 14 | 15 | private static final String ITEMS_FIELD = "g"; // 'items' 16 | private static final String ARMOR_FIELD = "h"; // 'armor' 17 | private static final String OFFHAND_FIELD = "i"; // 'offhand' 18 | private static final String COMPARTMENTS_FIELD = "l"; // 'compartments' 19 | 20 | private final CraftInventory inventory; 21 | private final CraftPlayer owner; 22 | 23 | public PlayerInventory(@NotNull CraftPlayer player) { 24 | super(player.getHandle()); 25 | this.owner = player; 26 | this.inventory = new CraftInventory(this); 27 | this.reflectContents(); 28 | } 29 | 30 | private void reflectContents() { 31 | Inventory origin = this.player.getInventory(); 32 | 33 | Reflex.setFieldValue(this, ITEMS_FIELD, origin.items); 34 | Reflex.setFieldValue(this, ARMOR_FIELD, origin.armor); 35 | Reflex.setFieldValue(this, OFFHAND_FIELD, origin.offhand); 36 | Reflex.setFieldValue(this, COMPARTMENTS_FIELD, Arrays.asList(origin.items, origin.armor, origin.offhand)); 37 | } 38 | 39 | @NotNull 40 | public org.bukkit.inventory.Inventory getInventory() { 41 | return this.inventory; 42 | } 43 | 44 | private void saveOnExit() { 45 | if (!this.transaction.isEmpty()) return; 46 | this.owner.saveData(); 47 | } 48 | 49 | @Override 50 | public void onClose(CraftHumanEntity who) { 51 | super.onClose(who); 52 | this.saveOnExit(); 53 | } 54 | 55 | @Override 56 | public int getContainerSize() { 57 | return super.getContainerSize() + 4; 58 | } 59 | 60 | @Override 61 | public boolean hasCustomName() { 62 | return true; 63 | } 64 | 65 | @Override 66 | public boolean stillValid(Player entityhuman) { 67 | return true; 68 | } 69 | 70 | public void update() { 71 | super.tick(); 72 | this.player.getInventory().tick(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /MC_1_21_5/src/main/java/su/nightexpress/sunlight/nms/mc_1_21_5/container/PlayerEnderChest.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.nms.mc_1_21_5.container; 2 | 3 | import net.minecraft.world.entity.player.Player; 4 | import net.minecraft.world.inventory.PlayerEnderChestContainer; 5 | import org.bukkit.craftbukkit.entity.CraftHumanEntity; 6 | import org.bukkit.craftbukkit.entity.CraftPlayer; 7 | import org.bukkit.craftbukkit.inventory.CraftInventory; 8 | import org.jetbrains.annotations.NotNull; 9 | import su.nightexpress.nightcore.util.Reflex; 10 | 11 | public class PlayerEnderChest extends PlayerEnderChestContainer { 12 | 13 | private static final String ITEMS_FIELD = "c"; // 'items' 14 | 15 | private final CraftInventory inventory = new CraftInventory(this); 16 | private final CraftPlayer owner; 17 | 18 | public PlayerEnderChest(CraftPlayer owner) { 19 | super(owner.getHandle()); 20 | this.owner = owner; 21 | Reflex.setFieldValue(this, ITEMS_FIELD, owner.getHandle().getEnderChestInventory().items); 22 | } 23 | 24 | @NotNull 25 | public org.bukkit.inventory.Inventory getInventory() { 26 | return this.inventory; 27 | } 28 | 29 | private void saveOnExit() { 30 | if (!this.transaction.isEmpty()) return; 31 | this.owner.saveData(); 32 | } 33 | 34 | @Override 35 | public void onClose(@NotNull CraftHumanEntity who) { 36 | super.onClose(who); 37 | this.saveOnExit(); 38 | } 39 | 40 | @Override 41 | public boolean stillValid(@NotNull Player player) { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MC_1_21_5/src/main/java/su/nightexpress/sunlight/nms/mc_1_21_5/container/PlayerInventory.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.nms.mc_1_21_5.container; 2 | 3 | import net.minecraft.world.entity.EntityEquipment; 4 | import net.minecraft.world.entity.player.Inventory; 5 | import net.minecraft.world.entity.player.Player; 6 | import org.bukkit.craftbukkit.entity.CraftHumanEntity; 7 | import org.bukkit.craftbukkit.entity.CraftPlayer; 8 | import org.bukkit.craftbukkit.inventory.CraftInventory; 9 | import org.jetbrains.annotations.NotNull; 10 | import su.nightexpress.nightcore.util.Reflex; 11 | import su.nightexpress.nightcore.util.Version; 12 | 13 | public class PlayerInventory extends Inventory { 14 | 15 | private static final String ITEMS_FIELD = "i"; // 'items' 16 | 17 | private final CraftInventory inventory; 18 | private final CraftPlayer owner; 19 | 20 | public PlayerInventory(@NotNull CraftPlayer player) { 21 | super(player.getHandle(), getEquipment(player)); 22 | this.owner = player; 23 | this.inventory = new CraftInventory(this); 24 | this.reflectContents(); 25 | } 26 | 27 | private static EntityEquipment getEquipment(@NotNull CraftPlayer craftPlayer) { 28 | if (Version.isSpigot()) { 29 | return (EntityEquipment) Reflex.getFieldValue(craftPlayer.getHandle(), "equipment"); 30 | } 31 | return craftPlayer.getHandle().getInventory().equipment; 32 | } 33 | 34 | private void reflectContents() { 35 | Inventory origin = this.player.getInventory(); 36 | 37 | Reflex.setFieldValue(this, ITEMS_FIELD, origin.getNonEquipmentItems()); 38 | } 39 | 40 | @NotNull 41 | public org.bukkit.inventory.Inventory getInventory() { 42 | return this.inventory; 43 | } 44 | 45 | private void saveOnExit() { 46 | if (!this.transaction.isEmpty()) return; 47 | this.owner.saveData(); 48 | } 49 | 50 | @Override 51 | public void onClose(@NotNull CraftHumanEntity who) { 52 | super.onClose(who); 53 | this.saveOnExit(); 54 | } 55 | 56 | @Override 57 | public int getContainerSize() { 58 | return super.getContainerSize() + 4; 59 | } 60 | 61 | @Override 62 | public boolean hasCustomName() { 63 | return true; 64 | } 65 | 66 | @Override 67 | public boolean stillValid(@NotNull Player player) { 68 | return true; 69 | } 70 | 71 | public void update() { 72 | super.tick(); 73 | this.player.getInventory().tick(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /NMS/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | SunLight 7 | su.nightexpress.sunlight 8 | 3.13.2 9 | 10 | 4.0.0 11 | 12 | NMS 13 | 14 | 15 | 21 16 | 21 17 | UTF-8 18 | 19 | 20 | 21 | 22 | su.nightexpress.sunlight 23 | API 24 | 3.13.2 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NMS/src/main/java/su/nightexpress/sunlight/nms/SunNMS.java: -------------------------------------------------------------------------------- 1 | package su.nightexpress.sunlight.nms; 2 | 3 | import org.bukkit.GameMode; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.FallingBlock; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.block.BlockExplodeEvent; 8 | import org.bukkit.event.entity.EntityExplodeEvent; 9 | import org.bukkit.inventory.Inventory; 10 | import org.jetbrains.annotations.NotNull; 11 | import su.nightexpress.sunlight.api.MenuType; 12 | 13 | import java.util.UUID; 14 | 15 | public interface SunNMS { 16 | 17 | default boolean canDestroyBlocks(@NotNull EntityExplodeEvent event) { 18 | return true; 19 | } 20 | 21 | default boolean canDestroyBlocks(@NotNull BlockExplodeEvent event) { 22 | return true; 23 | } 24 | 25 | @NotNull Object fineChatPacket(@NotNull Object packet); 26 | 27 | @NotNull Player loadPlayerData(@NotNull UUID id, @NotNull String name); 28 | 29 | @NotNull Inventory getPlayerInventory(@NotNull Player player); 30 | 31 | @NotNull Inventory getPlayerEnderChest(@NotNull Player player); 32 | 33 | void setGameMode(@NotNull Player player, @NotNull GameMode mode); 34 | 35 | void teleport(@NotNull Player player, @NotNull Location location); 36 | 37 | default void openContainer(@NotNull Player player, @NotNull MenuType menuType) { 38 | 39 | } 40 | 41 | @Deprecated 42 | default void openAnvil(@NotNull Player player) { 43 | 44 | } 45 | 46 | @Deprecated 47 | default void openEnchanting(@NotNull Player player) { 48 | 49 | } 50 | 51 | @Deprecated 52 | default void openGrindstone(@NotNull Player player) { 53 | 54 | } 55 | 56 | @Deprecated 57 | default void openLoom(@NotNull Player player) { 58 | 59 | } 60 | 61 | @Deprecated 62 | default void openSmithing(@NotNull Player player) { 63 | 64 | } 65 | 66 | @Deprecated 67 | default void openCartography(@NotNull Player player){ 68 | 69 | } 70 | 71 | @Deprecated 72 | default void openStonecutter(@NotNull Player player) { 73 | 74 | } 75 | 76 | void dropFallingContent(@NotNull FallingBlock fallingBlock); 77 | } 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SunLight 2 | SunLight is a all-in-one plugin solution for your Spigot server! It tries to provide you all the most essential features every modern server must have. And not only that, but also a lot of customizations and configurations. The plugin is modularized, so you can easily completely disable any part you don't like. 3 | --------------------------------------------------------------------------------