├── .gitignore ├── .travis.yml ├── Bukkit ├── db-create-all.sql ├── db-drop-all.sql ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── riguron │ │ │ └── bukkit │ │ │ ├── BukkitModule.java │ │ │ ├── command │ │ │ ├── CommandListModule.java │ │ │ ├── alert │ │ │ │ ├── AlertCommand.java │ │ │ │ └── AlertCommandOptions.java │ │ │ ├── find │ │ │ │ ├── FindCommand.java │ │ │ │ └── FindCommandOptions.java │ │ │ ├── package-info.java │ │ │ └── party │ │ │ │ ├── AsyncPartySubCommand.java │ │ │ │ ├── PartyCommandModule.java │ │ │ │ ├── PartyCommandOptions.java │ │ │ │ ├── PartySubCommand.java │ │ │ │ ├── PartySubCommandFactory.java │ │ │ │ ├── accept │ │ │ │ ├── AcceptCommandOptions.java │ │ │ │ └── PartyAcceptCommand.java │ │ │ │ ├── chat │ │ │ │ ├── ChatCommandOptions.java │ │ │ │ └── PartyChatCommand.java │ │ │ │ ├── create │ │ │ │ ├── CreateCommandOptions.java │ │ │ │ └── PartyCreateCommand.java │ │ │ │ ├── disband │ │ │ │ ├── DisbandCommandOptions.java │ │ │ │ └── PartyDisbandCommand.java │ │ │ │ ├── invite │ │ │ │ ├── InviteCommandOptions.java │ │ │ │ └── PartyInviteCommand.java │ │ │ │ └── remove │ │ │ │ ├── PartyRemoveCommand.java │ │ │ │ └── RemoveCommandOptions.java │ │ │ ├── config │ │ │ ├── WorldDeserializer.java │ │ │ └── WorldSerializer.java │ │ │ ├── gui │ │ │ ├── Executable.java │ │ │ ├── GUI.java │ │ │ ├── GUIFactory.java │ │ │ ├── item │ │ │ │ ├── InventoryItem.java │ │ │ │ └── NoOpExecutable.java │ │ │ ├── multipage │ │ │ │ ├── InventoryPages.java │ │ │ │ ├── MultiPageButtons.java │ │ │ │ ├── MultiPageGui.java │ │ │ │ ├── MultiPageListener.java │ │ │ │ ├── PageBuilder.java │ │ │ │ ├── PageSwitcher.java │ │ │ │ ├── PagesList.java │ │ │ │ ├── SlotActions.java │ │ │ │ └── player │ │ │ │ │ ├── PlayerPageRearranger.java │ │ │ │ │ └── PlayerPages.java │ │ │ ├── package-info.java │ │ │ ├── single │ │ │ │ ├── SinglePageInterface.java │ │ │ │ └── SinglePageListener.java │ │ │ └── validate │ │ │ │ ├── SinglePageValidatingGui.java │ │ │ │ ├── UniversalPageValidatingGui.java │ │ │ │ └── UniversalValidatingGui.java │ │ │ ├── item │ │ │ ├── ItemModule.java │ │ │ ├── ItemStackBuilder.java │ │ │ ├── entity │ │ │ │ ├── InventoryItemEntity.java │ │ │ │ ├── ItemStackEntity.java │ │ │ │ ├── MaterialDataEntity.java │ │ │ │ └── WoolMaterialData.java │ │ │ ├── executable │ │ │ │ ├── ExecutableItem.java │ │ │ │ ├── ExecutableItemListener.java │ │ │ │ ├── ExecutableItemRegistration.java │ │ │ │ ├── ExecutableItems.java │ │ │ │ └── NoOpItem.java │ │ │ └── join │ │ │ │ ├── JoinItem.java │ │ │ │ └── JoinItems.java │ │ │ ├── listener │ │ │ ├── BukkitCommandListener.java │ │ │ ├── BukkitListenerRegistration.java │ │ │ ├── ListenerModule.java │ │ │ ├── PlayerChatListener.java │ │ │ ├── RegisterListener.java │ │ │ ├── ServerDisableListener.java │ │ │ └── stream │ │ │ │ ├── DisconnectListener.java │ │ │ │ ├── JoinBroadcastingListener.java │ │ │ │ └── LoginListener.java │ │ │ ├── message │ │ │ ├── BukkitBroadcast.java │ │ │ ├── ConsoleSendMessage.java │ │ │ └── PlayerSendMessage.java │ │ │ ├── package-info.java │ │ │ ├── plugin │ │ │ ├── PluginBootstrapper.java │ │ │ ├── PluginModule.java │ │ │ └── ServerPlugin.java │ │ │ ├── punish │ │ │ └── PunishChatListener.java │ │ │ ├── selector │ │ │ ├── DynamicSelectorUpdater.java │ │ │ ├── SelectorModule.java │ │ │ ├── SelectorRepository.java │ │ │ ├── ServerConnectionActions.java │ │ │ ├── ServerItemProvider.java │ │ │ ├── ServerKind.java │ │ │ ├── ServerSelector.java │ │ │ ├── factory │ │ │ │ ├── SelectorFactory.java │ │ │ │ ├── SelectorInventoryFactory.java │ │ │ │ └── StoringSelectorFactory.java │ │ │ ├── global │ │ │ │ ├── GlobalSelectorInterface.java │ │ │ │ ├── GlobalSelectorInventory.java │ │ │ │ ├── GlobalSelectorItemFactory.java │ │ │ │ ├── GlobalSelectorUpdater.java │ │ │ │ └── config │ │ │ │ │ ├── GlobalSelectorConfig.java │ │ │ │ │ └── GlobalSelectorSlotConfig.java │ │ │ ├── gui │ │ │ │ ├── DynamicSelectorInventory.java │ │ │ │ └── FastServerItem.java │ │ │ ├── item │ │ │ │ └── GameServerItemProvider.java │ │ │ ├── iterator │ │ │ │ ├── GameSlotIterator.java │ │ │ │ └── LobbySlotIterator.java │ │ │ └── package-info.java │ │ │ ├── server │ │ │ ├── DefaultServerRegistration.java │ │ │ ├── OnlineIndexer.java │ │ │ ├── PlayerServerConnector.java │ │ │ ├── ServerDataModule.java │ │ │ ├── ServerIndexingRegistration.java │ │ │ ├── ServerProxyRegistration.java │ │ │ ├── ServerRegistration.java │ │ │ └── ServerUnregister.java │ │ │ ├── shop │ │ │ ├── Shop.java │ │ │ ├── ShopInventoryButtons.java │ │ │ ├── ShopModule.java │ │ │ ├── ShopViews.java │ │ │ ├── click │ │ │ │ ├── ClickHandler.java │ │ │ │ └── NoOpClickHandler.java │ │ │ └── ui │ │ │ │ ├── ShopInventoryConfiguration.java │ │ │ │ └── ShopListener.java │ │ │ ├── stream │ │ │ ├── DefaultStreamMessageProvider.java │ │ │ ├── StreamBroadcast.java │ │ │ ├── StreamMessageProvider.java │ │ │ └── StreamType.java │ │ │ └── task │ │ │ ├── AsyncFunction.java │ │ │ ├── AsyncProcedure.java │ │ │ ├── BukkitSchedulerTask.java │ │ │ ├── BukkitTaskFactory.java │ │ │ ├── BukkitTaskModule.java │ │ │ ├── BukkitTimerFactory.java │ │ │ ├── DelegatingTask.java │ │ │ └── execution │ │ │ ├── DelayedBukkitExecution.java │ │ │ ├── ImmediateBukkitExecution.java │ │ │ ├── RepeatingBukkitExecution.java │ │ │ └── delayed │ │ │ ├── AsyncDelayedExecution.java │ │ │ ├── DelayedExecution.java │ │ │ └── SyncDelayedExecution.java │ └── resources │ │ └── ebean.mf │ └── test │ └── java │ └── io │ └── riguron │ └── bukkit │ ├── config │ ├── WorldDeserializerTest.java │ └── WorldSerializerTest.java │ ├── gui │ └── multipage │ │ ├── InventoryPagesTest.java │ │ ├── MockItemFactory.java │ │ ├── MultiPageGuiTest.java │ │ ├── MultiPageListenerTest.java │ │ ├── PageBuilderTest.java │ │ ├── PageSwitcherTest.java │ │ ├── PlayerPageRearrangerTest.java │ │ ├── PlayerPagesTest.java │ │ └── SlotActionsTest.java │ ├── item │ └── ItemStackEntityTest.java │ ├── shop │ └── ShopViewsTest.java │ └── task │ └── timer │ └── BukkitTimerFactoryTest.java ├── Bungee ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── riguron │ │ │ └── bungee │ │ │ ├── BungeePlugin.java │ │ │ ├── BungeeSendMessage.java │ │ │ ├── ProxyChannelDeclaration.java │ │ │ ├── data │ │ │ ├── GlobalOnline.java │ │ │ └── GlobalOnlineUpdater.java │ │ │ ├── event │ │ │ └── PluginDisableEvent.java │ │ │ ├── listener │ │ │ ├── BungeeListenerRegistration.java │ │ │ ├── ListenerModule.java │ │ │ ├── LobbyBalancer.java │ │ │ ├── PartyListener.java │ │ │ ├── PingListener.java │ │ │ ├── PluginDisableListener.java │ │ │ └── stream │ │ │ │ ├── PlayerServerListener.java │ │ │ │ └── ServerStreamListener.java │ │ │ ├── message │ │ │ ├── AlertHandler.java │ │ │ ├── BungeeMessagingModule.java │ │ │ ├── KickHandler.java │ │ │ ├── MessageHandlerModule.java │ │ │ ├── PrivateMessageHandler.java │ │ │ ├── RegisterServerHandler.java │ │ │ └── party │ │ │ │ ├── PartyChatHandler.java │ │ │ │ ├── PartyDisbandHandler.java │ │ │ │ ├── PartyHandlerModule.java │ │ │ │ ├── PartyInviteHandler.java │ │ │ │ └── PartyTeleportHandler.java │ │ │ ├── module │ │ │ ├── BungeeModule.java │ │ │ └── PluginModule.java │ │ │ ├── package-info.java │ │ │ └── task │ │ │ ├── BungeeRepeatingExecution.java │ │ │ ├── BungeeSchedulerTask.java │ │ │ └── BungeeTaskFactory.java │ └── resources │ │ └── plugin.yml │ └── test │ └── java │ └── io │ └── riguron │ └── bungee │ ├── PartyListenerTest.java │ ├── data │ └── GlobalOnlineTest.java │ └── listener │ ├── LobbyBalancerTest.java │ └── PartyListenerTest.java ├── Command ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── riguron │ │ └── command │ │ ├── arguments │ │ ├── ArgumentSet.java │ │ ├── ListArgumentSet.java │ │ └── ValidatingArgumentSet.java │ │ ├── base │ │ ├── Command.java │ │ ├── CommandExecution.java │ │ ├── CommandOptions.java │ │ ├── PlayerOnlyException.java │ │ ├── SenderKind.java │ │ └── StaticCommandExecution.java │ │ ├── engine │ │ ├── CommandExecutor.java │ │ ├── CommandFrontController.java │ │ └── CommandOptionsValidator.java │ │ ├── function │ │ ├── CommandFunction.java │ │ └── RespondingCommand.java │ │ ├── module │ │ ├── CommandModule.java │ │ └── CommandPostProcessor.java │ │ ├── nested │ │ ├── NestedCommand.java │ │ └── NestedCommandFactory.java │ │ ├── package-info.java │ │ ├── repository │ │ ├── CommandRegistration.java │ │ ├── CommandRepository.java │ │ └── VirtualCommandRepository.java │ │ ├── sender │ │ ├── ConsoleSender.java │ │ ├── DefaultSenderFactory.java │ │ ├── PlayerSender.java │ │ ├── Sender.java │ │ └── SenderFactory.java │ │ └── state │ │ ├── CommandStep.java │ │ └── StatefulCommand.java │ └── test │ └── java │ └── io │ └── riguron │ └── command │ ├── arguments │ ├── ListArgumentSetTest.java │ └── ValidatingArgumentSetTest.java │ ├── engine │ ├── CommandExecutorTest.java │ └── CommandOptionsValidatorTest.java │ ├── function │ └── RespondingCommandTest.java │ ├── listener │ └── CommandFrontControllerTest.java │ ├── nested │ └── NestedCommandTest.java │ ├── repository │ └── VirtualCommandRepositoryTest.java │ └── state │ └── StatefulCommandTest.java ├── Common ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── riguron │ │ └── common │ │ ├── CommonModule.java │ │ ├── package-info.java │ │ ├── shutdown │ │ ├── ShutdownHook.java │ │ └── ShutdownHooks.java │ │ └── time │ │ ├── PeriodParser.java │ │ └── TimeExtractor.java │ └── test │ └── java │ └── io │ └── riguron │ └── common │ ├── PeriodParserTest.java │ └── TimeExtractorTest.java ├── Configuration ├── pom.xml └── src │ └── main │ └── java │ └── io │ └── riguron │ └── config │ ├── Configuration.java │ ├── client │ ├── ConfigurationLoader.java │ └── ConfigurationSaver.java │ ├── factory │ ├── ConfigurationProviderFactory.java │ ├── JsonConfigurationFactory.java │ └── stream │ │ ├── JsonStreamReaderFactory.java │ │ ├── JsonStreamWriterFactory.java │ │ ├── StreamReaderFactory.java │ │ └── StreamWriterFactory.java │ ├── json │ ├── JsonConfigurationProvider.java │ ├── JsonStreamReader.java │ └── JsonStreamWriter.java │ ├── module │ ├── ConfigurationModule.java │ └── JsonConfigurationModule.java │ ├── package-info.java │ ├── properties │ ├── PropertiesFactory.java │ └── PropertiesLoader.java │ └── provider │ ├── ConfigurationProvider.java │ └── StreamConfigurationProvider.java ├── Game ├── build.sh ├── db-create-all.sql ├── db-drop-all.sql ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── riguron │ │ │ └── game │ │ │ ├── GameBootstrapper.java │ │ │ ├── bootstrap │ │ │ └── GameProvider.java │ │ │ ├── config │ │ │ ├── GameOptions.java │ │ │ ├── advanced │ │ │ │ ├── AdvancedGameOptions.java │ │ │ │ ├── BlockOptions.java │ │ │ │ ├── ChangingOptions.java │ │ │ │ ├── DamageOptions.java │ │ │ │ ├── ItemOptions.java │ │ │ │ └── PlayerOptions.java │ │ │ ├── map │ │ │ │ ├── MapConfig.java │ │ │ │ ├── solo │ │ │ │ │ └── SoloMapConfig.java │ │ │ │ └── team │ │ │ │ │ ├── TeamLocationConfig.java │ │ │ │ │ └── TeamMapConfig.java │ │ │ └── team │ │ │ │ ├── TeamConfig.java │ │ │ │ └── TeamGameConfig.java │ │ │ ├── core │ │ │ ├── Game.java │ │ │ ├── GameDeathType.java │ │ │ ├── GameKind.java │ │ │ ├── GameState.java │ │ │ ├── decorator │ │ │ │ ├── DelayedStartingGame.java │ │ │ │ ├── ImmediateStartingGame.java │ │ │ │ └── StartStateChangingGame.java │ │ │ └── type │ │ │ │ ├── AbstractGame.java │ │ │ │ └── DelegatingGame.java │ │ │ ├── death │ │ │ ├── DeathListener.java │ │ │ ├── Respawn.java │ │ │ └── handler │ │ │ │ ├── DropOutDeathHandler.java │ │ │ │ ├── LivesDeathHandler.java │ │ │ │ ├── PlayerDeathHandler.java │ │ │ │ └── RespawnDeathHandler.java │ │ │ ├── event │ │ │ ├── GameEvent.java │ │ │ ├── GameStartEvent.java │ │ │ ├── GameStateChangeEvent.java │ │ │ ├── PlayerDropOutEvent.java │ │ │ └── PlayerSpectatorEvent.java │ │ │ ├── kit │ │ │ ├── Kit.java │ │ │ ├── KitInformation.java │ │ │ ├── KitLoader.java │ │ │ ├── KitModule.java │ │ │ ├── KitPlayerSupplier.java │ │ │ ├── KitRepository.java │ │ │ ├── KitSelectItem.java │ │ │ ├── Kits.java │ │ │ ├── permissions │ │ │ │ ├── AnyoneKitPermissions.java │ │ │ │ ├── BalanceKitPermissions.java │ │ │ │ ├── KitAvailabilityException.java │ │ │ │ ├── KitChallenger.java │ │ │ │ ├── KitChallengerAdapter.java │ │ │ │ ├── KitPermissions.java │ │ │ │ └── RankBasedPermissions.java │ │ │ └── selector │ │ │ │ ├── KitSelector.java │ │ │ │ └── inventory │ │ │ │ └── KitSelectorInterface.java │ │ │ ├── listener │ │ │ ├── ListenerRegistration.java │ │ │ ├── ListenerRegistrationService.java │ │ │ ├── ListenerUnregister.java │ │ │ ├── change │ │ │ │ ├── GameCountdownListener.java │ │ │ │ ├── GameEndListener.java │ │ │ │ └── SingleStateChangeListener.java │ │ │ ├── dropout │ │ │ │ ├── SoloDropOutListener.java │ │ │ │ └── TeamDropOutListener.java │ │ │ ├── restrictions │ │ │ │ ├── BlockListener.java │ │ │ │ ├── ChangeListener.java │ │ │ │ ├── ClickListener.java │ │ │ │ ├── DamageListener.java │ │ │ │ ├── ItemListener.java │ │ │ │ ├── RestrictionsModule.java │ │ │ │ ├── SpawnListener.java │ │ │ │ └── TimeChangeRunner.java │ │ │ ├── start │ │ │ │ ├── GameStartListener.java │ │ │ │ └── TeamGameStartListener.java │ │ │ ├── state │ │ │ │ ├── StateDependentListener.java │ │ │ │ ├── TriggeringStateChangeListener.java │ │ │ │ ├── active │ │ │ │ │ ├── ActiveJoinListener.java │ │ │ │ │ ├── ActiveStateListener.java │ │ │ │ │ ├── DropoutQuitListener.java │ │ │ │ │ ├── PlayerSpectatorListener.java │ │ │ │ │ └── SpectatorActionListener.java │ │ │ │ ├── starting │ │ │ │ │ ├── StartingBlockingListener.java │ │ │ │ │ └── StartingStateListener.java │ │ │ │ └── waiting │ │ │ │ │ ├── WaitingItemsListener.java │ │ │ │ │ ├── WaitingJoinListener.java │ │ │ │ │ ├── WaitingLobbyListener.java │ │ │ │ │ ├── WaitingMoveListener.java │ │ │ │ │ ├── WaitingOnlineIndexer.java │ │ │ │ │ ├── WaitingQuitListener.java │ │ │ │ │ ├── WaitingStateListener.java │ │ │ │ │ └── register │ │ │ │ │ ├── WaitingJoinRegistrationListener.java │ │ │ │ │ └── WaitingQuitUnregisterListener.java │ │ │ └── team │ │ │ │ └── TeamQuitListener.java │ │ │ ├── map │ │ │ ├── GameMap.java │ │ │ ├── GameMaps.java │ │ │ ├── type │ │ │ │ ├── AbstractGameMap.java │ │ │ │ ├── SoloGameMap.java │ │ │ │ └── TeamGameMap.java │ │ │ └── vote │ │ │ │ ├── GameMapVoting.java │ │ │ │ └── result │ │ │ │ ├── MapVotingResult.java │ │ │ │ ├── SuccessfulVoteResult.java │ │ │ │ └── UnknownMapResult.java │ │ │ ├── message │ │ │ └── GameMessageProvider.java │ │ │ ├── module │ │ │ ├── GameBootstrapModule.java │ │ │ ├── GameModule.java │ │ │ ├── GamePluginModule.java │ │ │ ├── GeneralModule.java │ │ │ ├── ListenerModule.java │ │ │ ├── SoloModule.java │ │ │ ├── game │ │ │ │ ├── ActiveModule.java │ │ │ │ ├── StartingModule.java │ │ │ │ └── WaitingModule.java │ │ │ └── team │ │ │ │ ├── TeamMapsLoader.java │ │ │ │ └── TeamModule.java │ │ │ ├── package-info.java │ │ │ ├── player │ │ │ ├── BasicGamePlayer.java │ │ │ ├── BasicPlayerStatus.java │ │ │ ├── GamePlayer.java │ │ │ ├── GamePlayerKit.java │ │ │ ├── GamePlayerStatus.java │ │ │ ├── GameScore.java │ │ │ ├── NullPlayer.java │ │ │ ├── factory │ │ │ │ ├── GamePlayerFactory.java │ │ │ │ ├── StandardPlayerFactory.java │ │ │ │ └── TeamPlayerFactory.java │ │ │ ├── repository │ │ │ │ ├── GamePlayerStorage.java │ │ │ │ ├── ValidatingGamePlayerStorage.java │ │ │ │ └── VirtualGamePlayerStorage.java │ │ │ ├── spectator │ │ │ │ └── Spectator.java │ │ │ ├── status │ │ │ │ └── PlayerLives.java │ │ │ └── team │ │ │ │ ├── NullTeamPlayer.java │ │ │ │ ├── TeamPlayer.java │ │ │ │ └── TeamPlayerBasic.java │ │ │ ├── plugin │ │ │ ├── GamePlugin.java │ │ │ ├── GamePluginConfiguration.java │ │ │ └── module │ │ │ │ ├── GameModuleConfiguration.java │ │ │ │ ├── ModuleConfiguration.java │ │ │ │ └── SetupModuleConfiguration.java │ │ │ ├── server │ │ │ ├── GameServerDataModule.java │ │ │ ├── GameServerRegistration.java │ │ │ ├── GameServerUnregister.java │ │ │ └── GameStartUpdater.java │ │ │ ├── setup │ │ │ ├── MapSetup.java │ │ │ ├── SoloMapSetup.java │ │ │ ├── TeamMapSetup.java │ │ │ ├── command │ │ │ │ ├── SaveCommand.java │ │ │ │ ├── SoloAddSpawnCommand.java │ │ │ │ └── TeleportCommand.java │ │ │ └── module │ │ │ │ ├── SetupModule.java │ │ │ │ ├── SoloSetupModule.java │ │ │ │ └── TeamSetupModule.java │ │ │ ├── shop │ │ │ └── KitPurchasableAdapter.java │ │ │ ├── team │ │ │ ├── DefaultTeamPlayers.java │ │ │ ├── NullTeam.java │ │ │ ├── StandardTeam.java │ │ │ ├── Team.java │ │ │ ├── TeamPlayers.java │ │ │ ├── add │ │ │ │ ├── AbstractAddResult.java │ │ │ │ ├── AlreadyInCurrentTeam.java │ │ │ │ ├── SuccessfulAdd.java │ │ │ │ ├── TeamAddResult.java │ │ │ │ └── TeamIsFull.java │ │ │ ├── client │ │ │ │ ├── TeamAssigner.java │ │ │ │ └── TeamLoader.java │ │ │ ├── repository │ │ │ │ ├── InMemoryTeams.java │ │ │ │ ├── Teams.java │ │ │ │ └── ValidatingTeams.java │ │ │ └── selector │ │ │ │ ├── TeamGuiListener.java │ │ │ │ └── TeamSelectorInventory.java │ │ │ ├── timer │ │ │ ├── GameEndingCountdown.java │ │ │ ├── GameStartingCountdown.java │ │ │ ├── SoundPlayingCountdown.java │ │ │ └── StartManagingTimer.java │ │ │ └── winner │ │ │ ├── WinningHandler.java │ │ │ ├── solo │ │ │ ├── OrderedResultCalculation.java │ │ │ ├── SoloResultCalculation.java │ │ │ ├── SoloWinningHandler.java │ │ │ └── order │ │ │ │ ├── Place.java │ │ │ │ ├── PlaceOrderBy.java │ │ │ │ ├── PlaceOrderByDropout.java │ │ │ │ └── PlaceOrderByScore.java │ │ │ └── team │ │ │ ├── AlivePlayersResultCalculation.java │ │ │ ├── ScoreTeamResultCalculation.java │ │ │ ├── TeamResultCalculation.java │ │ │ └── TeamWinningHandler.java │ └── resources │ │ └── plugin.yml │ └── test │ ├── java │ └── io │ │ └── riguron │ │ └── game │ │ ├── core │ │ ├── decorator │ │ │ ├── DelayedStartingGameTest.java │ │ │ ├── ImmediateStartingGameTest.java │ │ │ └── StartStateChangingGameTest.java │ │ └── type │ │ │ └── AbstractGameTest.java │ │ ├── death │ │ ├── RespawnTest.java │ │ └── handler │ │ │ ├── DropOutDeathHandlerTest.java │ │ │ ├── LivesDeathHandlerTest.java │ │ │ └── RespawnDeathHandlerTest.java │ │ ├── kit │ │ ├── KitRepositoryTest.java │ │ └── permissions │ │ │ ├── AnyoneKitPermissionsTest.java │ │ │ ├── BalanceKitPermissionsTest.java │ │ │ └── RankBasedPermissionsTest.java │ │ ├── listener │ │ ├── ListenerRegistrationServiceTest.java │ │ ├── change │ │ │ └── GameCountdownListenerTest.java │ │ ├── dropout │ │ │ ├── SoloDropOutListenerTest.java │ │ │ └── TeamDropOutListenerTest.java │ │ └── state │ │ │ ├── active │ │ │ └── ActiveOnlineIndexerTest.java │ │ │ └── waiting │ │ │ ├── WaitingMoveListenerTest.java │ │ │ ├── WaitingOnlineIndexerTest.java │ │ │ └── WaitingQuitListenerTest.java │ │ ├── map │ │ ├── type │ │ │ ├── SoloGameMapTest.java │ │ │ └── TeamGameMapTest.java │ │ └── vote │ │ │ └── GameMapVotingTest.java │ │ ├── player │ │ └── repository │ │ │ └── VirtualGamePlayerStorageTest.java │ │ ├── team │ │ ├── client │ │ │ ├── TeamAssignerTest.java │ │ │ └── TeamLoaderTest.java │ │ └── repository │ │ │ └── InMemoryTeamsTest.java │ │ └── winner │ │ └── solo │ │ └── OrderedResultCalculationTest.java │ └── resources │ ├── advanced.json │ ├── database.properties │ ├── game.json │ └── maps │ └── map.json ├── IO ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── riguron │ │ └── io │ │ ├── factory │ │ ├── DataFormat.java │ │ └── stream │ │ │ ├── FileStreamProviderFactory.java │ │ │ ├── StreamProviderFactory.java │ │ │ └── URLStreamProviderFactory.java │ │ ├── file │ │ └── ResourceInputStreamProvider.java │ │ ├── list │ │ ├── DirectoryList.java │ │ ├── FileDirectoryList.java │ │ ├── GenericDirectoryList.java │ │ └── ResourceDirectoryList.java │ │ ├── package-info.java │ │ ├── provider │ │ ├── InputStreamProvider.java │ │ ├── OutputStreamProvider.java │ │ ├── file │ │ │ ├── FileInputStreamProvider.java │ │ │ └── FileOutputStreamProvider.java │ │ └── url │ │ │ ├── URLInputStreamProvider.java │ │ │ └── URLOutputStreamProvider.java │ │ ├── stream │ │ ├── StreamReader.java │ │ └── StreamWriter.java │ │ └── util │ │ └── RemoveExtension.java │ └── test │ ├── java │ └── io │ │ └── riguron │ │ └── io │ │ ├── factory │ │ └── stream │ │ │ └── FileStreamProviderFactoryTest.java │ │ └── util │ │ └── RemoveExtensionTest.java │ └── resources │ └── in.txt ├── LICENSE ├── Messaging ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── riguron │ │ └── messaging │ │ ├── Message.java │ │ ├── MessageListener.java │ │ ├── MessagingChannels.java │ │ ├── MessagingException.java │ │ ├── MessagingModule.java │ │ ├── MessagingService.java │ │ ├── amqp │ │ ├── AMQPException.java │ │ ├── AMQPMessagingService.java │ │ └── ChannelFactory.java │ │ ├── handler │ │ ├── MessageDispatcher.java │ │ └── MessageHandler.java │ │ ├── message │ │ ├── Alert.java │ │ ├── KickProxyCommand.java │ │ ├── PrivateMessageCommand.java │ │ ├── RegisterServer.java │ │ └── party │ │ │ ├── PartyChat.java │ │ │ ├── PartyDisband.java │ │ │ ├── PartyInvite.java │ │ │ └── PartyTeleport.java │ │ ├── module │ │ └── RabbitModule.java │ │ ├── package-info.java │ │ └── serialize │ │ ├── MessageData.java │ │ ├── MessageDataExtractor.java │ │ ├── MessageDeserializer.java │ │ └── MessageSerializer.java │ └── test │ └── java │ └── io │ └── riguron │ └── messaging │ ├── handler │ └── MessageDispatcherTest.java │ └── serialize │ ├── MessageDataExtractorTest.java │ └── MessageSerializerTest.java ├── Persistence ├── db-create-all.sql ├── db-drop-all.sql ├── pom.xml └── src │ └── main │ ├── java │ └── io │ │ └── riguron │ │ └── persistence │ │ ├── CachingRepository.java │ │ ├── ebean │ │ └── EbeanPatch.java │ │ ├── entity │ │ └── EntityGroup.java │ │ ├── module │ │ └── PersistenceModule.java │ │ ├── package-info.java │ │ └── specification │ │ └── Specification.java │ └── resources │ └── datasource.properties ├── README.md ├── ServerData ├── dump.rdb ├── pom.xml └── src │ ├── main │ └── java │ │ └── io │ │ └── riguron │ │ └── server │ │ ├── ConvertingServerGroup.java │ │ ├── NoFreeServersException.java │ │ ├── ServerDataModule.java │ │ ├── ServerGroup.java │ │ ├── ServerName.java │ │ ├── ServerProfile.java │ │ ├── ServerType.java │ │ ├── StaticServerGroup.java │ │ ├── mapper │ │ ├── GameServerMapper.java │ │ ├── ServerMapper.java │ │ └── StandardServerMapper.java │ │ ├── package-info.java │ │ ├── redis │ │ ├── RedisGlobalOnlineRepository.java │ │ ├── RedisModule.java │ │ ├── RedisOnlineIndexingRepository.java │ │ ├── RedisPlayerRepository.java │ │ ├── RedisServerRepository.java │ │ └── RedisTransactions.java │ │ ├── repository │ │ ├── FreeServersQueryOptions.java │ │ ├── GlobalOnlineRepository.java │ │ ├── OnlineIndexingRepository.java │ │ ├── PlayerRepository.java │ │ ├── RepositoryModule.java │ │ ├── ServerFieldType.java │ │ └── ServerRepository.java │ │ └── type │ │ ├── GameServer.java │ │ └── Server.java │ └── test │ └── java │ └── io │ └── riguron │ └── server │ ├── ConvertingServerGroupTest.java │ ├── mapper │ ├── GameServerMapperTest.java │ └── StandardServerMapperTest.java │ └── redis │ ├── RedisGlobalOnlineRepositoryTest.java │ ├── RedisOnlineIndexingRepositoryTest.java │ ├── RedisPlayerRepositoryTest.java │ └── RedisServerRepositoryTest.java ├── System ├── db-create-all.sql ├── db-drop-all.sql ├── dump.rdb ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── riguron │ │ │ └── system │ │ │ ├── CoreModule.java │ │ │ ├── ServerSideModule.java │ │ │ ├── chat │ │ │ ├── ChatCooldowns.java │ │ │ ├── ChatFormatter.java │ │ │ └── ChatModule.java │ │ │ ├── dialog │ │ │ ├── MessageSendResponse.java │ │ │ ├── PrivateMessage.java │ │ │ ├── PrivateMessageModule.java │ │ │ ├── PrivateMessageProjection.java │ │ │ ├── PrivateMessageRecord.java │ │ │ ├── PrivateMessageRepository.java │ │ │ ├── ignore │ │ │ │ ├── IgnoreData.java │ │ │ │ ├── IgnoreHistoryElement.java │ │ │ │ ├── IgnoreRemoveResult.java │ │ │ │ ├── IgnoreRepository.java │ │ │ │ ├── IgnoreResult.java │ │ │ │ └── IgnoreService.java │ │ │ └── send │ │ │ │ ├── CheckTarget.java │ │ │ │ ├── FinalStage.java │ │ │ │ ├── FindOnlinePlayer.java │ │ │ │ ├── FindPlayerProfile.java │ │ │ │ ├── SendModule.java │ │ │ │ └── SendPrivateMessage.java │ │ │ ├── exception │ │ │ └── PlayerNotFoundException.java │ │ │ ├── internalization │ │ │ ├── InternalizationService.java │ │ │ ├── InvalidMessageFormatException.java │ │ │ ├── Localizable.java │ │ │ ├── Message.java │ │ │ └── SendMessage.java │ │ │ ├── listener │ │ │ ├── ConditionalListener.java │ │ │ ├── ListenerPostProcessor.java │ │ │ └── ListenerRegistration.java │ │ │ ├── login │ │ │ ├── LoginDetails.java │ │ │ ├── LoginProcessingModule.java │ │ │ └── chain │ │ │ │ ├── DefaultChainExecutor.java │ │ │ │ ├── LoggingChainExecutor.java │ │ │ │ ├── LoginChainExecutor.java │ │ │ │ ├── LoginChainLink.java │ │ │ │ └── LoginProcessingException.java │ │ │ ├── message │ │ │ └── PlayerMessaging.java │ │ │ ├── package-info.java │ │ │ ├── party │ │ │ ├── PartyModule.java │ │ │ ├── PartyRepository.java │ │ │ ├── PartyService.java │ │ │ ├── RedisPartyRepository.java │ │ │ ├── SelfCheckingPartyRepository.java │ │ │ └── result │ │ │ │ ├── AcceptResult.java │ │ │ │ ├── CreateResult.java │ │ │ │ ├── DisbandResult.java │ │ │ │ ├── InviteResult.java │ │ │ │ ├── RemoveResult.java │ │ │ │ └── Result.java │ │ │ ├── player │ │ │ ├── CachingPlayerRepository.java │ │ │ ├── PlayerAssociation.java │ │ │ ├── PlayerLeaveHandler.java │ │ │ ├── PlayerProfile.java │ │ │ ├── PlayerProfileLoader.java │ │ │ ├── PlayerProfileModule.java │ │ │ ├── PlayerProfileRepository.java │ │ │ ├── exception │ │ │ │ ├── InsufficientFundsException.java │ │ │ │ └── PlayerProcessingException.java │ │ │ └── specification │ │ │ │ ├── PlayerNameSpecification.java │ │ │ │ └── UUIDSpecification.java │ │ │ ├── plugin │ │ │ └── PluginConfiguration.java │ │ │ ├── preferences │ │ │ ├── PlayerPreferences.java │ │ │ ├── PreferencesRepository.java │ │ │ └── specification │ │ │ │ └── PlayerNameSpecification.java │ │ │ ├── punishment │ │ │ ├── PunishmentChecker.java │ │ │ ├── PunishmentLink.java │ │ │ ├── PunishmentModule.java │ │ │ ├── model │ │ │ │ ├── ActivePunishmentRecord.java │ │ │ │ ├── ActivePunishmentType.java │ │ │ │ ├── PunishmentData.java │ │ │ │ ├── PunishmentRecord.java │ │ │ │ └── type │ │ │ │ │ └── PunishmentType.java │ │ │ ├── package-info.java │ │ │ ├── param │ │ │ │ └── PunishmentParameters.java │ │ │ ├── repository │ │ │ │ ├── PunishmentDataProvider.java │ │ │ │ ├── PunishmentDataRepository.java │ │ │ │ └── PunishmentRepository.java │ │ │ ├── service │ │ │ │ ├── ActivePunishmentService.java │ │ │ │ └── PunishmentService.java │ │ │ └── type │ │ │ │ ├── Kick.java │ │ │ │ ├── ProxyKick.java │ │ │ │ ├── PunishResult.java │ │ │ │ ├── PunishResultType.java │ │ │ │ ├── Punishment.java │ │ │ │ ├── Warn.java │ │ │ │ └── active │ │ │ │ ├── ActivePunishment.java │ │ │ │ ├── Ban.java │ │ │ │ ├── Excuse.java │ │ │ │ └── Mute.java │ │ │ ├── rank │ │ │ ├── Rank.java │ │ │ ├── RankLoader.java │ │ │ ├── RankModule.java │ │ │ ├── RankRepository.java │ │ │ └── Ranks.java │ │ │ ├── server │ │ │ ├── ServerChannel.java │ │ │ └── ServerChannelFactory.java │ │ │ ├── shop │ │ │ ├── ActivePurchases.java │ │ │ ├── AlreadyPurchasedException.java │ │ │ ├── PlayerPurchaseService.java │ │ │ ├── PlayerPurchases.java │ │ │ ├── Purchasable.java │ │ │ ├── Purchase.java │ │ │ └── PurchaseRepository.java │ │ │ ├── stream │ │ │ └── Broadcast.java │ │ │ ├── task │ │ │ ├── AbstractRepeatingTask.java │ │ │ ├── ExecutionStrategy.java │ │ │ ├── FixedRepeatingAction.java │ │ │ ├── FixedRepeatingTaskRunner.java │ │ │ ├── SchedulerTask.java │ │ │ ├── Task.java │ │ │ ├── TaskFactory.java │ │ │ ├── TimerFactory.java │ │ │ ├── async │ │ │ │ └── Callback.java │ │ │ ├── repeating │ │ │ │ ├── RepeatingAction.java │ │ │ │ ├── RepeatingRunnable.java │ │ │ │ ├── RepeatingTask.java │ │ │ │ └── ReusableRepeatingTask.java │ │ │ ├── startup │ │ │ │ ├── PostLoadTask.java │ │ │ │ └── PostLoadTaskRunner.java │ │ │ ├── timer │ │ │ │ ├── Countdown.java │ │ │ │ ├── CountdownTask.java │ │ │ │ ├── TaskOptions.java │ │ │ │ ├── Timer.java │ │ │ │ └── TimerAdapter.java │ │ │ ├── type │ │ │ │ └── CompletableTask.java │ │ │ └── util │ │ │ │ └── SecondsToTicks.java │ │ │ └── test │ │ │ ├── EbeanTesting.java │ │ │ └── RepositoryTest.java │ └── resources │ │ ├── ebean.mf │ │ ├── log4j.xml │ │ └── selector.json │ └── test │ └── java │ └── io │ └── riguron │ └── system │ ├── chat │ ├── ChatCooldownsTest.java │ └── ChatFormatterTest.java │ ├── dialog │ ├── PrivateMessageRepositoryTest.java │ ├── ignore │ │ ├── IgnoreRepositoryTest.java │ │ └── IgnoreServiceTest.java │ └── send │ │ ├── CheckTargetTest.java │ │ ├── FinalStageTest.java │ │ ├── FindOnlinePlayerTest.java │ │ ├── FindPlayerProfileTest.java │ │ └── SendPrivateMessageTest.java │ ├── internalization │ └── InternalizationServiceTest.java │ ├── party │ ├── PartyRepositoryTest.java │ ├── PartyServiceTest.java │ └── SelfCheckingPartyRepositoryTest.java │ ├── player │ ├── PlayerProfileLoaderTest.java │ └── repository │ │ └── PlayerProfileRepositoryTest.java │ ├── preferences │ └── PreferencesRepositoryTest.java │ ├── punishment │ ├── PunishmentCheckerTest.java │ ├── PunishmentLinkTest.java │ ├── model │ │ └── ActivePunishmentRecordTest.java │ ├── repository │ │ ├── PunishmentDataProviderTest.java │ │ ├── PunishmentDataRepositoryTest.java │ │ └── PunishmentRepositoryTest.java │ ├── service │ │ ├── ActivePunishmentServiceTest.java │ │ └── PunishmentServiceTest.java │ └── type │ │ ├── ProxyKickTest.java │ │ ├── WarnTest.java │ │ └── active │ │ └── BanTest.java │ ├── rank │ ├── RankRepositoryTest.java │ ├── RankTest.java │ └── RanksTest.java │ ├── shop │ ├── ActivePurchasesTest.java │ ├── PlayerPurchaseServiceTest.java │ └── PurchaseRepositoryTest.java │ └── task │ ├── timer │ └── CountdownTest.java │ └── util │ └── SecondsToTicksTest.java ├── build-game.sh ├── db-create-all.sql ├── pom.xml ├── start-redis.sh └── stop-redis.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.ear 17 | *.zip 18 | *.tar.gz 19 | *.rar 20 | 21 | target 22 | 23 | .idea 24 | *.iml 25 | .DS_Store 26 | .rdb 27 | .sql 28 | 29 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package containing concrete server-side commands. 3 | */ 4 | package io.riguron.bukkit.command; -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/PartySubCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.command.base.CommandExecution; 5 | import io.riguron.command.base.CommandOptions; 6 | import io.riguron.system.party.PartyService; 7 | import io.riguron.system.party.result.Result; 8 | 9 | import java.util.function.BiFunction; 10 | 11 | @RequiredArgsConstructor 12 | public abstract class PartySubCommand { 13 | 14 | private final PartyService partyService; 15 | private final BiFunction function; 16 | 17 | public Result execute(CommandExecution execution) { 18 | return function.apply(this.partyService, execution); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/accept/PartyAcceptCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party.accept; 2 | 3 | import io.riguron.bukkit.command.party.PartySubCommand; 4 | import io.riguron.bukkit.command.party.PartySubCommand; 5 | import io.riguron.system.party.PartyService; 6 | 7 | public class PartyAcceptCommand extends PartySubCommand { 8 | 9 | public PartyAcceptCommand(PartyService partyService) { 10 | super(partyService, (ps, commandExecution) -> ps.accept(commandExecution.getArguments().get(0), commandExecution.getSender().getName())); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/create/PartyCreateCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party.create; 2 | 3 | import io.riguron.bukkit.command.party.PartySubCommand; 4 | import io.riguron.bukkit.command.party.PartySubCommand; 5 | import io.riguron.command.base.CommandOptions; 6 | import io.riguron.system.internalization.Message; 7 | import io.riguron.system.party.PartyService; 8 | 9 | import java.util.Collections; 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | public class PartyCreateCommand extends PartySubCommand { 14 | 15 | public PartyCreateCommand(PartyService partyService) { 16 | super(partyService, (ps, commandExecution) -> ps.create(commandExecution.getSender().getName())); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/disband/PartyDisbandCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party.disband; 2 | 3 | import io.riguron.bukkit.command.party.PartySubCommand; 4 | import io.riguron.bukkit.command.party.PartySubCommand; 5 | import io.riguron.system.party.PartyService; 6 | 7 | public class PartyDisbandCommand extends PartySubCommand { 8 | 9 | public PartyDisbandCommand(PartyService partyService) { 10 | super(partyService, (ps, commandExecution) -> ps.disband(commandExecution.getSender().getName())); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/invite/PartyInviteCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party.invite; 2 | 3 | import io.riguron.bukkit.command.party.PartySubCommand; 4 | import io.riguron.bukkit.command.party.PartySubCommand; 5 | import io.riguron.system.party.PartyService; 6 | 7 | public class PartyInviteCommand extends PartySubCommand { 8 | 9 | public PartyInviteCommand(PartyService partyService) { 10 | super(partyService, (ps, commandExecution) -> ps.invite(commandExecution.getSender().getName(), commandExecution.getArguments().get(0))); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/command/party/remove/PartyRemoveCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.command.party.remove; 2 | 3 | import io.riguron.bukkit.command.party.PartySubCommand; 4 | import io.riguron.bukkit.command.party.PartySubCommand; 5 | import io.riguron.command.base.CommandOptions; 6 | import io.riguron.system.internalization.Message; 7 | import io.riguron.system.party.PartyService; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | public class PartyRemoveCommand extends PartySubCommand { 14 | 15 | public PartyRemoveCommand(PartyService partyService) { 16 | super(partyService, (ps, commandExecution) -> ps.remove(commandExecution.getSender().getName(), commandExecution.getArguments().get(0))); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/config/WorldDeserializer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.config; 2 | 3 | import com.google.gson.*; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.Server; 6 | import org.bukkit.World; 7 | 8 | import java.lang.reflect.Type; 9 | 10 | /** 11 | * Gson adapter for de-serializing World 12 | */ 13 | @RequiredArgsConstructor 14 | public class WorldDeserializer implements JsonDeserializer { 15 | 16 | private final Server server; 17 | 18 | @Override 19 | public World deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { 20 | return server.getWorld(jsonElement.getAsJsonObject().get("name").getAsString()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/config/WorldSerializer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.config; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonObject; 5 | import com.google.gson.JsonSerializationContext; 6 | import com.google.gson.JsonSerializer; 7 | import org.bukkit.World; 8 | 9 | import java.lang.reflect.Type; 10 | 11 | /** 12 | * Gson adapter for serializing World 13 | */ 14 | public class WorldSerializer implements JsonSerializer { 15 | 16 | @Override 17 | public JsonElement serialize(World world, Type type, JsonSerializationContext jsonSerializationContext) { 18 | JsonObject jsonObject = new JsonObject(); 19 | jsonObject.addProperty("name", world.getName()); 20 | return jsonObject; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/gui/Executable.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.gui; 2 | 3 | import java.util.UUID; 4 | 5 | public interface Executable { 6 | 7 | void execute(UUID playerId); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/gui/item/InventoryItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.gui.item; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.Setter; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | /** 9 | * Represents an item that can be added to an 10 | * inventory at the certain slot and page. 11 | * Plain wrapper for ItemStack. 12 | */ 13 | @Data 14 | @Setter(AccessLevel.NONE) 15 | public class InventoryItem { 16 | 17 | private final ItemStack itemStack; 18 | private final int slot; 19 | private final int page; 20 | 21 | public InventoryItem(ItemStack item, int slot) { 22 | this(item, slot, 1); 23 | } 24 | 25 | public InventoryItem(ItemStack item, int slot, int page) { 26 | this.itemStack = item; 27 | this.slot = slot; 28 | this.page = page; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/gui/item/NoOpExecutable.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.gui.item; 2 | 3 | import io.riguron.bukkit.gui.Executable; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * No-Op implementation for the NullObject (Special Case) 9 | * pattern. 10 | */ 11 | public enum NoOpExecutable implements Executable { 12 | 13 | INSTANCE { 14 | @Override 15 | public void execute(UUID playerId) { 16 | } 17 | }; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/gui/multipage/PagesList.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.gui.multipage; 2 | 3 | import lombok.experimental.Delegate; 4 | import org.bukkit.inventory.Inventory; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class PagesList implements List { 10 | 11 | @Delegate 12 | private List delegate = new ArrayList<>(); 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/gui/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Mini GUI framework. 3 | */ 4 | package io.riguron.bukkit.gui; -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/entity/InventoryItemEntity.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.entity; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.NonNull; 6 | import lombok.Setter; 7 | 8 | import javax.persistence.*; 9 | 10 | /** 11 | * JPA entity wrapping persistent ItemStack with the position 12 | */ 13 | @Data 14 | @Setter(AccessLevel.NONE) 15 | @Entity 16 | public class InventoryItemEntity { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private int id; 21 | 22 | @OneToOne(cascade = CascadeType.ALL, optional = false) 23 | private final ItemStackEntity item; 24 | 25 | @Column 26 | @NonNull 27 | private final int position; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/entity/MaterialDataEntity.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.entity; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.Setter; 6 | import org.bukkit.material.MaterialData; 7 | 8 | import javax.persistence.*; 9 | 10 | /** 11 | * JPA wrapper for MaterialData. 12 | */ 13 | @Entity 14 | @Inheritance 15 | @Data 16 | @Setter(AccessLevel.NONE) 17 | public abstract class MaterialDataEntity { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.AUTO) 21 | private int id; 22 | 23 | abstract MaterialData toMaterialData(); 24 | } 25 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/entity/WoolMaterialData.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.entity; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | import org.bukkit.DyeColor; 6 | import org.bukkit.material.MaterialData; 7 | import org.bukkit.material.Wool; 8 | 9 | import javax.persistence.Entity; 10 | import javax.persistence.EnumType; 11 | import javax.persistence.Enumerated; 12 | 13 | @Entity 14 | @Data 15 | @EqualsAndHashCode(callSuper = true) 16 | public class WoolMaterialData extends MaterialDataEntity { 17 | 18 | @Enumerated(value = EnumType.STRING) 19 | private DyeColor dyeColor; 20 | 21 | @Override 22 | MaterialData toMaterialData() { 23 | return new Wool(dyeColor); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/executable/ExecutableItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.executable; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | /** 6 | * Represents an item causing some action to happen when it's clicked 7 | * (interacted) by the player. 8 | */ 9 | public interface ExecutableItem { 10 | 11 | /** 12 | * Action that happens when item is clicked. 13 | * 14 | * @param player player that clicked the item 15 | */ 16 | void execute(Player player); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/executable/ExecutableItemListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.executable; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerInteractEvent; 7 | 8 | @RequiredArgsConstructor 9 | public class ExecutableItemListener implements Listener { 10 | 11 | private final ExecutableItems items; 12 | 13 | @EventHandler 14 | public void onInteract(PlayerInteractEvent event) { 15 | items.dispatchClick(event.getPlayer(), event.getItem()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/executable/ExecutableItemRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.executable; 2 | 3 | import lombok.Value; 4 | import io.riguron.bukkit.gui.item.InventoryItem; 5 | 6 | @Value 7 | public class ExecutableItemRegistration { 8 | 9 | private final InventoryItem item; 10 | private final ExecutableItem executableItem; 11 | } 12 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/executable/ExecutableItems.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.executable; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * Container class storing mapping of Bukkit item stacks to executable items. 11 | */ 12 | public class ExecutableItems { 13 | 14 | private Map items = new HashMap<>(); 15 | 16 | public void add(ExecutableItemRegistration registration) { 17 | items.put(registration.getItem().getItemStack(), registration.getExecutableItem()); 18 | } 19 | 20 | public void dispatchClick(Player player, ItemStack itemStack) { 21 | items.getOrDefault(itemStack, NoOpItem.INSTANCE).execute(player); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/executable/NoOpItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.executable; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | /** 6 | * No-op ExecutableItem implementation for null object (special case) 7 | * pattern. 8 | */ 9 | public enum NoOpItem implements ExecutableItem { 10 | 11 | INSTANCE { 12 | @Override 13 | public void execute(Player player) { 14 | 15 | } 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/item/join/JoinItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item.join; 2 | 3 | import lombok.Value; 4 | import io.riguron.bukkit.gui.item.InventoryItem; 5 | import io.riguron.bukkit.item.executable.ExecutableItem; 6 | 7 | @Value 8 | public class JoinItem { 9 | 10 | private final InventoryItem inventoryItem; 11 | private final ExecutableItem executableItem; 12 | } 13 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/listener/BukkitListenerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.listener; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.event.Listener; 5 | import io.riguron.system.listener.ListenerRegistration; 6 | 7 | @RequiredArgsConstructor 8 | public class BukkitListenerRegistration implements ListenerRegistration { 9 | 10 | private final RegisterListener registerListener; 11 | 12 | @Override 13 | public void registerListener(Listener listener) { 14 | registerListener.register(listener); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/listener/RegisterListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.listener; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.event.Listener; 5 | import org.bukkit.plugin.Plugin; 6 | 7 | @RequiredArgsConstructor 8 | public class RegisterListener { 9 | 10 | private final Plugin plugin; 11 | 12 | public void register(Listener listener) { 13 | plugin.getServer().getPluginManager().registerEvents(listener, plugin); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/listener/stream/DisconnectListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.listener.stream; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.player.PlayerLeaveHandler; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | import io.riguron.system.player.PlayerProfileRepository; 9 | 10 | @RequiredArgsConstructor 11 | public class DisconnectListener implements Listener { 12 | 13 | private final PlayerLeaveHandler leaveHandler; 14 | 15 | @EventHandler 16 | public void onLeave(PlayerQuitEvent playerQuitEvent) { 17 | leaveHandler.onLeave(playerQuitEvent.getPlayer().getUniqueId()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/listener/stream/JoinBroadcastingListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.listener.stream; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import io.riguron.bukkit.stream.StreamBroadcast; 8 | import io.riguron.bukkit.stream.StreamType; 9 | 10 | @RequiredArgsConstructor 11 | public class JoinBroadcastingListener implements Listener { 12 | 13 | private final StreamBroadcast streamBroadcast; 14 | 15 | @EventHandler 16 | public void onJoin(PlayerJoinEvent event) { 17 | streamBroadcast.onStream(StreamType.JOIN, event.getPlayer().getUniqueId()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/message/BukkitBroadcast.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.message; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.Server; 5 | import io.riguron.system.internalization.Message; 6 | import io.riguron.system.internalization.SendMessage; 7 | import io.riguron.system.stream.Broadcast; 8 | 9 | @RequiredArgsConstructor 10 | public class BukkitBroadcast implements Broadcast { 11 | 12 | private final Server server; 13 | private final SendMessage sendMessage; 14 | 15 | @Override 16 | public void broadcast(String message) { 17 | server.getOnlinePlayers().forEach((player -> player.sendMessage(message))); 18 | } 19 | 20 | @Override 21 | public void broadcast(Message message) { 22 | server.getOnlinePlayers().forEach(player -> sendMessage.to(player.getUniqueId(), message)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This module represents a Bukkit layer of the system. It contains classes 3 | * coupled with Bukkit API and therefore can not be used in any other environments. 4 | */ 5 | package io.riguron.bukkit; -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/plugin/ServerPlugin.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.plugin; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import io.riguron.system.plugin.PluginConfiguration; 5 | 6 | public abstract class ServerPlugin extends JavaPlugin { 7 | 8 | @Override 9 | public void onEnable() { 10 | getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { 11 | PluginBootstrapper pluginBootstrapper = new PluginBootstrapper(configuration(), this); 12 | pluginBootstrapper.bootstrap(); 13 | }); 14 | } 15 | 16 | /** 17 | * This method is overrode by the concrete plugins to provide the 18 | * configuration of the custom plugin. 19 | * 20 | * @return configuration of custom plugin 21 | */ 22 | protected abstract PluginConfiguration configuration(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/ServerItemProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector; 2 | 3 | import io.riguron.server.type.Server; 4 | 5 | /** 6 | * Maps server information to the appropriate visual display 7 | * element (sign, item stack or whatever it is). 8 | * 9 | * @param type of the visual element 10 | * @param type of the server 11 | */ 12 | public interface ServerItemProvider { 13 | 14 | /** 15 | * Function that maps server object to the visual element. 16 | * 17 | * @param gameServer server 18 | * @return constructed visual element 19 | */ 20 | I createServerItem(T gameServer); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/ServerKind.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector; 2 | 3 | /** 4 | * Type of the server. Used to distinguish the selector visual form. 5 | */ 6 | public enum ServerKind { 7 | 8 | GAME, LOBBY; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/ServerSelector.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Represents visual server selector (an interface that enables 9 | * players to pick different servers to join). 10 | * 11 | * @param type of the server 12 | */ 13 | public interface ServerSelector { 14 | 15 | /** 16 | * Updates selector state by providing actual state 17 | * of servers being monitored by the current selector. 18 | * 19 | * @param servers fresh server data 20 | */ 21 | void refresh(List servers); 22 | 23 | /** 24 | * Displays the visual part of the selector to the player. 25 | * 26 | * @param player player who sees the interface 27 | */ 28 | void displayTo(Player player); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/global/GlobalSelectorInterface.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.global; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Represents interface for selecting different game modes. 7 | * Global means that this selector enables player to pick the game type, 8 | * not the concrete server. 9 | */ 10 | public interface GlobalSelectorInterface { 11 | 12 | /** 13 | * Refreshes the visual interface. 14 | * 15 | * @param online mapping of the each game type to the total online players on that game mode. 16 | */ 17 | void update(Map online); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/global/GlobalSelectorItemFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.global; 2 | 3 | import io.riguron.bukkit.selector.SelectorRepository; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.Server; 6 | import io.riguron.bukkit.gui.Executable; 7 | import io.riguron.bukkit.selector.SelectorRepository; 8 | 9 | @RequiredArgsConstructor 10 | public class GlobalSelectorItemFactory { 11 | 12 | private final SelectorRepository selectorRepository; 13 | private final Server server; 14 | 15 | public Executable newGlobalSelectorButton(String serverChannel) { 16 | return playerId -> selectorRepository.getSelector(serverChannel).displayTo( 17 | server.getPlayer(playerId) 18 | ); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/global/config/GlobalSelectorConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.global.config; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.Setter; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Represents a config of the global selector. 11 | */ 12 | @Data 13 | @Setter(AccessLevel.NONE) 14 | public class GlobalSelectorConfig { 15 | 16 | /** 17 | * List of slot configurations. 18 | */ 19 | private List slots; 20 | } 21 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/global/config/GlobalSelectorSlotConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.global.config; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Data; 5 | import lombok.Setter; 6 | import org.bukkit.Material; 7 | 8 | /** 9 | * Represents configuration of the selector slot. 10 | */ 11 | @Data 12 | @Setter(AccessLevel.NONE) 13 | public class GlobalSelectorSlotConfig { 14 | 15 | /** 16 | * Material of the icon. 17 | */ 18 | private Material material; 19 | 20 | /** 21 | * Type of the server that is associated with the icon. 22 | */ 23 | private String serverChannel; 24 | 25 | /** 26 | * Name of the icon. 27 | */ 28 | private String displayName; 29 | 30 | /** 31 | * Position of the icon in the selector interface. 32 | */ 33 | private int position; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/gui/FastServerItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.gui; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | import org.bukkit.Material; 6 | import org.bukkit.inventory.ItemStack; 7 | import io.riguron.bukkit.item.ItemStackBuilder; 8 | 9 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 10 | public class FastServerItem { 11 | 12 | public static final ItemStack ICON = new ItemStackBuilder(Material.NETHER_STAR) 13 | .displayName("Instant join") 14 | .lore() 15 | .emptyLine() 16 | .addLine("> Click here to connect to the most available server") 17 | .emptyLine() 18 | .build(); 19 | } 20 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/iterator/LobbySlotIterator.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.selector.iterator; 2 | 3 | import java.util.Iterator; 4 | import java.util.NoSuchElementException; 5 | 6 | /** 7 | * Iterator that provides the slot indexes for lobby server icons. 8 | */ 9 | public class LobbySlotIterator implements Iterator { 10 | 11 | private static final int START_SLOT = 28; 12 | private static final int END_SLOT = 34; 13 | 14 | private int cursor = START_SLOT; 15 | 16 | @Override 17 | public boolean hasNext() { 18 | return cursor != END_SLOT; 19 | } 20 | 21 | @Override 22 | public Integer next() { 23 | if (!hasNext()) { 24 | throw new NoSuchElementException(); 25 | } 26 | 27 | return cursor++; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/selector/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Code base for the visual server selector. 3 | */ 4 | package io.riguron.bukkit.selector; -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/server/ServerIndexingRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.server; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.server.ServerProfile; 5 | import io.riguron.server.repository.OnlineIndexingRepository; 6 | import io.riguron.system.task.startup.PostLoadTask; 7 | 8 | /** 9 | * Task responsible for registering server at the online indexing repository. 10 | */ 11 | @RequiredArgsConstructor 12 | public class ServerIndexingRegistration implements PostLoadTask { 13 | 14 | private final OnlineIndexingRepository repository; 15 | private final ServerProfile serverProfile; 16 | 17 | @Override 18 | public void run() { 19 | repository.addServer( 20 | serverProfile.getServerGroup(), 21 | serverProfile.getServerName() 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/server/ServerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.server; 2 | 3 | import io.riguron.system.task.startup.PostLoadTask; 4 | 5 | /** 6 | * Task responsible for registering server at server repository. 7 | */ 8 | public interface ServerRegistration extends PostLoadTask { 9 | 10 | /** 11 | * Sends registration packet to the proxies. 12 | */ 13 | void run(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/server/ServerUnregister.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.server; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.server.ServerName; 5 | import io.riguron.server.repository.ServerFieldType; 6 | import io.riguron.server.repository.ServerRepository; 7 | 8 | /** 9 | * Task responsible for changing server status on "disabled" when server shuts 10 | * down. 11 | */ 12 | @RequiredArgsConstructor 13 | public class ServerUnregister { 14 | 15 | private final ServerRepository serverRepository; 16 | private final ServerName serverName; 17 | 18 | public void doUnregister() { 19 | serverRepository.set(serverName.get(), ServerFieldType.ENABLED, false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/shop/Shop.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.shop; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.Server; 5 | import io.riguron.system.shop.ActivePurchases; 6 | import io.riguron.system.shop.Purchasable; 7 | 8 | import java.util.UUID; 9 | 10 | @RequiredArgsConstructor 11 | public class Shop { 12 | 13 | private final ShopViews shopViews; 14 | private final ActivePurchases activePurchases; 15 | private final Server server; 16 | 17 | public void purchase(UUID player, Purchasable purchasable, Runnable onSuccess) { 18 | shopViews.openShopView(player, purchasable).displayTo(server.getPlayer(player)); 19 | activePurchases.addPurchase(player, purchasable, onSuccess); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/shop/click/ClickHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.shop.click; 2 | 3 | import java.util.UUID; 4 | 5 | public interface ClickHandler { 6 | 7 | void onClick(UUID uuid); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/shop/click/NoOpClickHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.shop.click; 2 | 3 | import java.util.UUID; 4 | 5 | public enum NoOpClickHandler implements ClickHandler { 6 | 7 | INSTANCE; 8 | 9 | @Override 10 | public void onClick(UUID uuid) { 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/stream/DefaultStreamMessageProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.stream; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.internalization.Message; 5 | import io.riguron.system.player.PlayerProfileRepository; 6 | 7 | import java.util.UUID; 8 | 9 | /** 10 | * Default implementation providing plain messages. 11 | */ 12 | @RequiredArgsConstructor 13 | public class DefaultStreamMessageProvider implements StreamMessageProvider { 14 | 15 | private final PlayerProfileRepository playerProfileRepository; 16 | 17 | @Override 18 | public Message getStreamMessage(StreamType streamType, UUID joinedPlayer) { 19 | return new Message(String.format("stream.message.%s", streamType.getDescription()), playerProfileRepository.get(joinedPlayer).getName()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/stream/StreamBroadcast.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.stream; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.internalization.SendMessage; 5 | 6 | import java.util.UUID; 7 | 8 | @RequiredArgsConstructor 9 | public class StreamBroadcast { 10 | 11 | private final StreamMessageProvider streamMessageProvider; 12 | private final SendMessage sendMessage; 13 | 14 | public void onStream(StreamType streamType, UUID player) { 15 | sendMessage.to(player, streamMessageProvider.getStreamMessage(streamType, player)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/stream/StreamMessageProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.stream; 2 | 3 | import io.riguron.system.internalization.Message; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Function responsible for producing stream (join/leave) messages. 9 | */ 10 | public interface StreamMessageProvider { 11 | 12 | Message getStreamMessage(StreamType streamType, UUID joinedPlayer); 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/stream/StreamType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.stream; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Type of the stream. 7 | */ 8 | @Getter 9 | public enum StreamType { 10 | 11 | /** 12 | * Player joins 13 | */ 14 | JOIN("join"), 15 | 16 | /** 17 | * Player quits 18 | */ 19 | QUIT("quit"); 20 | 21 | private String description; 22 | 23 | StreamType(String description) { 24 | this.description = description; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/AsyncProcedure.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.plugin.Plugin; 5 | import io.riguron.system.task.Task; 6 | 7 | @RequiredArgsConstructor 8 | public class AsyncProcedure implements Task { 9 | 10 | private final Runnable job; 11 | private final Plugin plugin; 12 | 13 | @Override 14 | public void execute() { 15 | plugin.getServer().getScheduler().runTaskAsynchronously(plugin, job); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/DelegatingTask.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task; 2 | 3 | import io.riguron.system.task.ExecutionStrategy; 4 | import io.riguron.system.task.Task; 5 | 6 | public class DelegatingTask implements Task { 7 | 8 | private Runnable job; 9 | private ExecutionStrategy executionStrategy; 10 | 11 | public DelegatingTask(Runnable job, ExecutionStrategy executionStrategy) { 12 | this.job = job; 13 | this.executionStrategy = executionStrategy; 14 | } 15 | 16 | @Override 17 | public void execute() { 18 | executionStrategy.execute(job); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/execution/ImmediateBukkitExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task.execution; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.plugin.Plugin; 5 | import org.bukkit.scheduler.BukkitScheduler; 6 | import io.riguron.system.task.ExecutionStrategy; 7 | 8 | @RequiredArgsConstructor 9 | public class ImmediateBukkitExecution implements ExecutionStrategy { 10 | 11 | private final Plugin plugin; 12 | private final BukkitScheduler bukkitScheduler; 13 | 14 | @Override 15 | public int execute(Runnable runnable) { 16 | return bukkitScheduler.runTask(plugin, runnable).getTaskId(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/execution/RepeatingBukkitExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task.execution; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.plugin.Plugin; 5 | import org.bukkit.scheduler.BukkitScheduler; 6 | import io.riguron.system.task.ExecutionStrategy; 7 | import io.riguron.system.task.util.SecondsToTicks; 8 | 9 | @RequiredArgsConstructor 10 | public class RepeatingBukkitExecution implements ExecutionStrategy { 11 | 12 | private final Plugin plugin; 13 | private final BukkitScheduler bukkitScheduler; 14 | private final int delay; 15 | 16 | @Override 17 | public int execute(Runnable runnable) { 18 | return bukkitScheduler.runTaskTimer(plugin, runnable, 0L, new SecondsToTicks(delay).convert()).getTaskId(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/execution/delayed/AsyncDelayedExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task.execution.delayed; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.bukkit.scheduler.BukkitScheduler; 5 | import org.bukkit.scheduler.BukkitTask; 6 | 7 | public class AsyncDelayedExecution implements DelayedExecution { 8 | 9 | @Override 10 | public BukkitTask execute(Plugin plugin, BukkitScheduler scheduler, Runnable runnable, long delay) { 11 | return scheduler.runTaskLaterAsynchronously(plugin, runnable, delay); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/execution/delayed/DelayedExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task.execution.delayed; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.bukkit.scheduler.BukkitScheduler; 5 | import org.bukkit.scheduler.BukkitTask; 6 | 7 | /** 8 | * Represents deferred action. 9 | */ 10 | public interface DelayedExecution { 11 | 12 | BukkitTask execute(Plugin plugin, BukkitScheduler scheduler, Runnable runnable, long delay); 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/java/io/riguron/bukkit/task/execution/delayed/SyncDelayedExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.task.execution.delayed; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.bukkit.scheduler.BukkitScheduler; 5 | import org.bukkit.scheduler.BukkitTask; 6 | 7 | public class SyncDelayedExecution implements DelayedExecution { 8 | 9 | @Override 10 | public BukkitTask execute(Plugin plugin, BukkitScheduler scheduler, Runnable runnable, long delay) { 11 | return scheduler.runTaskLater(plugin, runnable, delay); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Bukkit/src/main/resources/ebean.mf: -------------------------------------------------------------------------------- 1 | entity-packages: io.riguron 2 | transactional-packages: io.riguron 3 | -------------------------------------------------------------------------------- /Bukkit/src/test/java/io/riguron/bukkit/gui/multipage/MockItemFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.gui.multipage; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.inventory.ItemFactory; 5 | import org.bukkit.inventory.meta.ItemMeta; 6 | import org.mockito.Mockito; 7 | import org.powermock.api.mockito.PowerMockito; 8 | 9 | import static org.mockito.ArgumentMatchers.any; 10 | import static org.mockito.Mockito.mock; 11 | import static org.mockito.Mockito.when; 12 | 13 | public class MockItemFactory { 14 | 15 | public static ItemFactory mockItemFactory() { 16 | PowerMockito.mockStatic(Bukkit.class); 17 | when(Bukkit.getItemFactory()).thenReturn(Mockito.mock(ItemFactory.class)); 18 | when(Bukkit.getItemFactory().getItemMeta(any())).thenReturn(mock(ItemMeta.class)); 19 | return Bukkit.getItemFactory(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Bukkit/src/test/java/io/riguron/bukkit/item/ItemStackEntityTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bukkit.item; 2 | 3 | import io.ebean.EbeanServer; 4 | import io.riguron.bukkit.item.entity.ItemStackEntity; 5 | import io.riguron.bukkit.item.entity.ItemStackEntity; 6 | import io.riguron.system.test.EbeanTesting; 7 | import org.bukkit.Material; 8 | import org.junit.Test; 9 | 10 | import java.util.Arrays; 11 | 12 | public class ItemStackEntityTest { 13 | 14 | @Test 15 | public void tryPersist() { 16 | EbeanServer ebeanServer = new EbeanTesting().getEbeanServer(); 17 | ItemStackEntity entity = new ItemStackEntity( 18 | Material.ARROW, 19 | "DisplayName", 20 | Arrays.asList("a", "b", "c") 21 | ); 22 | ebeanServer.save(entity); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/BungeePlugin.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee; 2 | 3 | import com.google.inject.Guice; 4 | import io.riguron.bungee.event.PluginDisableEvent; 5 | import io.riguron.bungee.module.PluginModule; 6 | import net.md_5.bungee.api.plugin.Plugin; 7 | 8 | public class BungeePlugin extends Plugin { 9 | 10 | @Override 11 | public void onEnable() { 12 | Guice.createInjector(new PluginModule(this)); 13 | } 14 | 15 | @Override 16 | public void onDisable() { 17 | getProxy().getPluginManager().callEvent(new PluginDisableEvent()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/BungeeSendMessage.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import net.md_5.bungee.api.ProxyServer; 5 | import net.md_5.bungee.api.chat.TextComponent; 6 | import net.md_5.bungee.api.connection.ProxiedPlayer; 7 | 8 | @RequiredArgsConstructor 9 | public class BungeeSendMessage { 10 | 11 | private final ProxyServer proxyServer; 12 | 13 | public void sendMessage(String name, String message) { 14 | final ProxiedPlayer player = proxyServer.getPlayer(name); 15 | if (player != null) { 16 | player.sendMessage(new TextComponent(message)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/data/GlobalOnlineUpdater.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.data; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.task.FixedRepeatingAction; 5 | 6 | @RequiredArgsConstructor 7 | public class GlobalOnlineUpdater implements FixedRepeatingAction { 8 | 9 | private final GlobalOnline globalOnline; 10 | 11 | @Override 12 | public void run() { 13 | globalOnline.update(); 14 | } 15 | 16 | @Override 17 | public int getInterval() { 18 | return 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/event/PluginDisableEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.event; 2 | 3 | import net.md_5.bungee.api.plugin.Event; 4 | 5 | /** 6 | * BungeeCord version of Bukkit's PluginDisableEvent. 7 | */ 8 | public class PluginDisableEvent extends Event { 9 | } 10 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/listener/BungeeListenerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.listener; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import net.md_5.bungee.api.plugin.Listener; 5 | import net.md_5.bungee.api.plugin.Plugin; 6 | import io.riguron.system.listener.ListenerRegistration; 7 | 8 | @RequiredArgsConstructor 9 | public class BungeeListenerRegistration implements ListenerRegistration { 10 | 11 | private final Plugin plugin; 12 | 13 | @Override 14 | public void registerListener(Listener listener) { 15 | plugin.getProxy().getPluginManager().registerListener(plugin, listener); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/listener/PingListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.listener; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import net.md_5.bungee.api.event.ProxyPingEvent; 5 | import net.md_5.bungee.api.plugin.Listener; 6 | import net.md_5.bungee.event.EventHandler; 7 | import io.riguron.bungee.data.GlobalOnline; 8 | 9 | @RequiredArgsConstructor 10 | public class PingListener implements Listener { 11 | 12 | private final GlobalOnline globalOnline; 13 | 14 | @EventHandler 15 | public void onProxyPing(ProxyPingEvent event) { 16 | event.getResponse().getPlayers().setOnline(globalOnline.getGlobalOnline()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/listener/PluginDisableListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.listener; 2 | 3 | import io.riguron.bungee.event.PluginDisableEvent; 4 | import lombok.RequiredArgsConstructor; 5 | import net.md_5.bungee.api.plugin.Listener; 6 | import net.md_5.bungee.event.EventHandler; 7 | import io.riguron.common.shutdown.ShutdownHooks; 8 | 9 | @RequiredArgsConstructor 10 | public class PluginDisableListener implements Listener { 11 | 12 | private final ShutdownHooks shutdownHooks; 13 | 14 | @EventHandler 15 | public void onSystemDisable(PluginDisableEvent pluginDisableEvent) { 16 | shutdownHooks.runAll(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/message/party/PartyDisbandHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.message.party; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.bungee.BungeeSendMessage; 5 | import io.riguron.messaging.handler.MessageHandler; 6 | import io.riguron.messaging.message.party.PartyDisband; 7 | 8 | import java.lang.reflect.Type; 9 | 10 | @RequiredArgsConstructor 11 | public class PartyDisbandHandler implements MessageHandler { 12 | 13 | private final BungeeSendMessage bungeeSendMessage; 14 | 15 | @Override 16 | public void accept(PartyDisband message) { 17 | bungeeSendMessage.sendMessage(message.getMemberName(), "Your party has been disbanded!"); 18 | } 19 | 20 | @Override 21 | public Type getMessageType() { 22 | return PartyDisband.class; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/module/PluginModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.module; 2 | 3 | import com.google.inject.AbstractModule; 4 | import lombok.RequiredArgsConstructor; 5 | import net.md_5.bungee.api.plugin.Plugin; 6 | import io.riguron.system.CoreModule; 7 | 8 | @RequiredArgsConstructor 9 | public class PluginModule extends AbstractModule { 10 | 11 | private final Plugin plugin; 12 | 13 | @Override 14 | protected void configure() { 15 | bind(Plugin.class).toInstance(plugin); 16 | install(new BungeeModule()); 17 | install(new CoreModule()); 18 | 19 | } 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * BungeeCord side of the system containing message handlers, 3 | * global listeners and more 4 | */ 5 | package io.riguron.bungee; -------------------------------------------------------------------------------- /Bungee/src/main/java/io/riguron/bungee/task/BungeeRepeatingExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.task; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.task.ExecutionStrategy; 5 | import net.md_5.bungee.api.plugin.Plugin; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | @RequiredArgsConstructor 10 | public class BungeeRepeatingExecution implements ExecutionStrategy { 11 | 12 | private final Plugin plugin; 13 | private final int interval; 14 | 15 | @Override 16 | public int execute(Runnable runnable) { 17 | 18 | return plugin.getProxy().getScheduler().schedule( 19 | plugin, 20 | runnable, 21 | 0L, 22 | interval, 23 | TimeUnit.SECONDS 24 | ).getId(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Bungee/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: BungeeCore 2 | main: io.riguron.BungeePlugin 3 | version: 1.0 4 | author: riguron -------------------------------------------------------------------------------- /Bungee/src/test/java/io/riguron/bungee/data/GlobalOnlineTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.bungee.data; 2 | 3 | import io.riguron.server.repository.GlobalOnlineRepository; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | import static org.mockito.Mockito.mock; 8 | import static org.mockito.Mockito.when; 9 | 10 | public class GlobalOnlineTest { 11 | 12 | @Test 13 | public void getGlobalOnline() { 14 | GlobalOnlineRepository globalOnlineRepository = mock(GlobalOnlineRepository.class); 15 | when(globalOnlineRepository.getGlobalOnline()).thenReturn(10); 16 | GlobalOnline globalOnline = new GlobalOnline(globalOnlineRepository); 17 | globalOnline.update(); 18 | 19 | new Thread(() -> assertEquals(10, globalOnline.getGlobalOnline())).start(); 20 | } 21 | } -------------------------------------------------------------------------------- /Command/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | MinecraftNetwork 7 | io.riguron 8 | 1.0 9 | 10 | 4.0.0 11 | 12 | command 13 | 14 | 15 | 16 | io.riguron 17 | system 18 | 1.0 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/base/Command.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.base; 2 | 3 | /** 4 | * Commands are a primary way of user interaction with server 5 | * features. Command is a message starting with slash (/) that is 6 | * associated with a specific server feature. 7 | */ 8 | public interface Command { 9 | 10 | /** 11 | * Logic performed when user dispatches a certain 12 | * command. 13 | * 14 | * @param execution parameters of current command execution. 15 | */ 16 | void execute(CommandExecution execution); 17 | } 18 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/base/PlayerOnlyException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.base; 2 | 3 | /** 4 | * Exception thrown by command execution engine when a console 5 | * attempts to execute player-only command. 6 | */ 7 | public class PlayerOnlyException extends RuntimeException { 8 | 9 | public PlayerOnlyException() { 10 | super("This command is for players only"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/base/SenderKind.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.base; 2 | 3 | public enum SenderKind { 4 | 5 | PLAYER, CONSOLE; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/base/StaticCommandExecution.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.base; 2 | 3 | import io.riguron.command.arguments.ArgumentSet; 4 | import io.riguron.command.sender.Sender; 5 | import lombok.Value; 6 | import io.riguron.command.arguments.ArgumentSet; 7 | import io.riguron.command.sender.Sender; 8 | 9 | @Value 10 | public class StaticCommandExecution implements CommandExecution { 11 | 12 | private final Sender sender; 13 | private final ArgumentSet arguments; 14 | private final String body; 15 | } 16 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/function/CommandFunction.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.function; 2 | 3 | import io.riguron.command.base.CommandExecution; 4 | import io.riguron.command.base.CommandExecution; 5 | import io.riguron.system.internalization.Message; 6 | 7 | /** 8 | * Represents an "echo" command, i.e the command 9 | * that always returns some text response to the initiator. 10 | */ 11 | public interface CommandFunction { 12 | 13 | /** 14 | * A message returned to the command initiator after an execution. 15 | * 16 | * @param execution command execution context 17 | * @return result of command invocation 18 | */ 19 | Message execute(CommandExecution execution); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/function/RespondingCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.function; 2 | 3 | import io.riguron.command.base.Command; 4 | import io.riguron.command.base.CommandExecution; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.command.base.Command; 7 | import io.riguron.command.base.CommandExecution; 8 | import io.riguron.system.internalization.SendMessage; 9 | 10 | @RequiredArgsConstructor 11 | public class RespondingCommand implements Command { 12 | 13 | private final SendMessage sendMessage; 14 | private final CommandFunction commandFunction; 15 | 16 | @Override 17 | public void execute(CommandExecution execution) { 18 | sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/module/CommandPostProcessor.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.module; 2 | 3 | import com.google.inject.Inject; 4 | import io.riguron.command.repository.CommandRegistration; 5 | import io.riguron.command.repository.CommandRegistration; 6 | import io.riguron.command.repository.CommandRepository; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * Class responsible of registering commands defined in the guice modules. 12 | */ 13 | public class CommandPostProcessor { 14 | 15 | @Inject(optional = true) 16 | public void postConfigure(CommandRepository commandRepository, Set registrations) { 17 | registrations.forEach(commandRepository::addCommand); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This module is actually a small command framework that can be used either in Bukkit or 3 | * BungeeCord environment. 4 | */ 5 | package io.riguron.command; -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/repository/CommandRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.repository; 2 | 3 | import io.riguron.command.base.CommandOptions; 4 | import lombok.AccessLevel; 5 | import lombok.Data; 6 | import lombok.Setter; 7 | import io.riguron.command.base.Command; 8 | import io.riguron.command.base.CommandOptions; 9 | 10 | /** 11 | * Simple value class that couples a command with its options. Used 12 | * in command execution engine internals. 13 | */ 14 | @Data 15 | @Setter(AccessLevel.NONE) 16 | public class CommandRegistration { 17 | 18 | private final Command command; 19 | private final CommandOptions commandOptions; 20 | } 21 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/repository/CommandRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.repository; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * Storage that holds associations of strings with the corresponding command 7 | * objects. 8 | */ 9 | public interface CommandRepository { 10 | 11 | /** 12 | * Retrieves a command by its name or alias. 13 | * 14 | * @param body string associated with a command 15 | * @return optional containing appropriate command. Empty optional is returned 16 | * if there is none. 17 | */ 18 | Optional getCommand(String body); 19 | 20 | /** 21 | * Puts command into the storage. 22 | * 23 | * @param commandRegistration command and its options 24 | */ 25 | void addCommand(CommandRegistration commandRegistration); 26 | } 27 | -------------------------------------------------------------------------------- /Command/src/main/java/io/riguron/command/sender/SenderFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.command.sender; 2 | 3 | import io.riguron.command.base.SenderKind; 4 | 5 | import java.util.UUID; 6 | 7 | public interface SenderFactory { 8 | 9 | Sender newSender(UUID uuid, SenderKind senderKind); 10 | } 11 | -------------------------------------------------------------------------------- /Common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | MinecraftNetwork 7 | io.riguron 8 | 1.0 9 | 10 | 4.0.0 11 | 12 | common 13 | 14 | 15 | -------------------------------------------------------------------------------- /Common/src/main/java/io/riguron/common/CommonModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.common; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Provides; 5 | import com.google.inject.Singleton; 6 | import io.riguron.common.shutdown.ShutdownHook; 7 | import io.riguron.common.shutdown.ShutdownHooks; 8 | 9 | import java.util.Set; 10 | 11 | public class CommonModule extends AbstractModule { 12 | 13 | @Provides 14 | @Singleton 15 | public ShutdownHooks shutdownHooks(Set hooks) { 16 | return new ShutdownHooks(hooks); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Common/src/main/java/io/riguron/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This module contains primarily utility classes and classes used throughout 3 | * the system. 4 | */ 5 | package io.riguron.common; -------------------------------------------------------------------------------- /Common/src/main/java/io/riguron/common/shutdown/ShutdownHook.java: -------------------------------------------------------------------------------- 1 | package io.riguron.common.shutdown; 2 | 3 | /** 4 | * Represents action that happens on server shutdown. It's typically 5 | * resource closing or any related stuff. 6 | */ 7 | public interface ShutdownHook extends Runnable { 8 | 9 | /** 10 | * Shutdown action logic. 11 | */ 12 | void run(); 13 | } 14 | -------------------------------------------------------------------------------- /Common/src/main/java/io/riguron/common/shutdown/ShutdownHooks.java: -------------------------------------------------------------------------------- 1 | package io.riguron.common.shutdown; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | /** 7 | * Class responsible for holding shutdown hooks. 8 | */ 9 | public class ShutdownHooks { 10 | 11 | private final Set hooks; 12 | 13 | public ShutdownHooks(Set hooks) { 14 | this.hooks = new HashSet<>(hooks); 15 | } 16 | 17 | /** 18 | * Registers shutdown hook. 19 | * 20 | * @param runnable hook 21 | */ 22 | public void addHook(Runnable runnable) { 23 | hooks.add(runnable::run); 24 | } 25 | 26 | /** 27 | * Executes all shutdown hooks. 28 | */ 29 | public void runAll() { 30 | hooks.forEach(Runnable::run); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Configuration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | MinecraftNetwork 7 | io.riguron 8 | 1.0 9 | 10 | 4.0.0 11 | 1.0 12 | 13 | configuration 14 | 15 | 16 | io.riguron 17 | io 18 | 1.0 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/Configuration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config; 2 | 3 | /** 4 | * Marker configuration for configuration POJOs (mappings) 5 | */ 6 | public interface Configuration { 7 | } 8 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/client/ConfigurationSaver.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.client; 2 | 3 | import io.riguron.config.factory.stream.StreamWriterFactory; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.config.Configuration; 6 | 7 | /** 8 | * Client class for writing configuration objects to external resources. 9 | */ 10 | @RequiredArgsConstructor 11 | public class ConfigurationSaver { 12 | 13 | private final StreamWriterFactory streamWriterFactory; 14 | 15 | public void save(Configuration configuration, String name) { 16 | streamWriterFactory.newStreamWriter(name).write(configuration); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/ConfigurationProviderFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory; 2 | 3 | import io.riguron.config.provider.ConfigurationProvider; 4 | import io.riguron.io.provider.InputStreamProvider; 5 | 6 | /** 7 | * Class responsible for creating ConfigurationProvider instances. 8 | * High-level component. 9 | */ 10 | public interface ConfigurationProviderFactory { 11 | 12 | /** 13 | * Creates new configuration provider. 14 | * 15 | * @param type type of the serialized object 16 | * @param streamProvider external resource input stream provider 17 | * @param type of the serialized object 18 | * @return configuration provider instance 19 | */ 20 | ConfigurationProvider newConfigurationProvider(Class type, InputStreamProvider streamProvider); 21 | } 22 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/JsonConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory; 2 | 3 | import com.google.gson.Gson; 4 | import io.riguron.config.json.JsonConfigurationProvider; 5 | import io.riguron.config.provider.ConfigurationProvider; 6 | import lombok.AllArgsConstructor; 7 | import io.riguron.io.provider.InputStreamProvider; 8 | 9 | @AllArgsConstructor 10 | public class JsonConfigurationFactory implements ConfigurationProviderFactory { 11 | 12 | private Gson gson; 13 | 14 | @Override 15 | public ConfigurationProvider newConfigurationProvider(Class type, InputStreamProvider streamProvider) { 16 | return new JsonConfigurationProvider<>(gson, type, streamProvider); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/stream/JsonStreamReaderFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory.stream; 2 | 3 | import com.google.gson.Gson; 4 | import io.riguron.config.json.JsonStreamReader; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.io.factory.stream.StreamProviderFactory; 7 | import io.riguron.io.stream.StreamReader; 8 | 9 | @RequiredArgsConstructor 10 | public class JsonStreamReaderFactory implements StreamReaderFactory { 11 | 12 | private final Gson gson; 13 | private final StreamProviderFactory streamProviderFactory; 14 | 15 | @Override 16 | public StreamReader newStreamReader(String target, Class type) { 17 | return new JsonStreamReader<>(gson, type, streamProviderFactory.newInputStreamProvider(target)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/stream/JsonStreamWriterFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory.stream; 2 | 3 | import com.google.gson.Gson; 4 | import io.riguron.config.json.JsonStreamWriter; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.io.factory.stream.StreamProviderFactory; 7 | import io.riguron.io.stream.StreamWriter; 8 | 9 | @RequiredArgsConstructor 10 | public class JsonStreamWriterFactory implements StreamWriterFactory { 11 | 12 | private final StreamProviderFactory streamProviderFactory; 13 | private final Gson gson; 14 | 15 | @Override 16 | public StreamWriter newStreamWriter(String dst) { 17 | return new JsonStreamWriter(gson, streamProviderFactory.newOutputStreamProvider(dst)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/stream/StreamReaderFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory.stream; 2 | 3 | import io.riguron.io.stream.StreamReader; 4 | 5 | public interface StreamReaderFactory { 6 | 7 | StreamReader newStreamReader(String target, Class type); 8 | } 9 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/factory/stream/StreamWriterFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.factory.stream; 2 | 3 | import io.riguron.io.stream.StreamWriter; 4 | 5 | public interface StreamWriterFactory { 6 | 7 | StreamWriter newStreamWriter(String dst); 8 | } 9 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/json/JsonConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.json; 2 | 3 | import com.google.gson.Gson; 4 | import io.riguron.config.provider.StreamConfigurationProvider; 5 | import io.riguron.io.provider.InputStreamProvider; 6 | 7 | public class JsonConfigurationProvider extends StreamConfigurationProvider { 8 | 9 | public JsonConfigurationProvider(Gson gson, Class type, InputStreamProvider streamProvider) { 10 | super(new JsonStreamReader<>(gson, type, streamProvider)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple configuration framework. 3 | */ 4 | package io.riguron.config; -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/properties/PropertiesFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.properties; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.io.factory.stream.StreamProviderFactory; 5 | 6 | @RequiredArgsConstructor 7 | public class PropertiesFactory { 8 | 9 | private final StreamProviderFactory streamProviderFactory; 10 | 11 | public PropertiesLoader newPropertiesLoader(String path) { 12 | return new PropertiesLoader(streamProviderFactory.newInputStreamProvider(path)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/provider/ConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.provider; 2 | 3 | /** 4 | * Interface responsible for loading configuration objects from external sources. 5 | * 6 | * @param type of de-serialized object 7 | */ 8 | public interface ConfigurationProvider { 9 | 10 | T load(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Configuration/src/main/java/io/riguron/config/provider/StreamConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.config.provider; 2 | 3 | import io.riguron.io.stream.StreamReader; 4 | 5 | public class StreamConfigurationProvider implements ConfigurationProvider { 6 | 7 | private StreamReader streamReader; 8 | 9 | public StreamConfigurationProvider(StreamReader streamReader) { 10 | this.streamReader = streamReader; 11 | } 12 | 13 | @Override 14 | public T load() { 15 | return this.streamReader.read(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Game/build.sh: -------------------------------------------------------------------------------- 1 | mvn -Dmaven.test.skip=true clean compile assembly:single 2 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/GameBootstrapper.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game; 2 | 3 | import io.riguron.game.bootstrap.GameProvider; 4 | import io.riguron.system.plugin.PluginConfiguration; 5 | 6 | public interface GameBootstrapper { 7 | 8 | GameProvider gameProvider(); 9 | 10 | PluginConfiguration gameConfiguration(); 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/bootstrap/GameProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.bootstrap; 2 | 3 | import io.riguron.game.core.GameKind; 4 | 5 | /** 6 | * This class is implemented by plugins of the concrete games to 7 | * provide the configuration for the game framework. 8 | */ 9 | public interface GameProvider { 10 | 11 | GameKind getKind(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/advanced/BlockOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.advanced; 2 | 3 | import lombok.*; 4 | 5 | @SuppressWarnings("unused") 6 | @Getter 7 | @EqualsAndHashCode 8 | @ToString 9 | public class BlockOptions { 10 | 11 | /** 12 | * Whether players are allowed to place blocks. 13 | */ 14 | private boolean canPlace; 15 | 16 | /** 17 | * Whether players are allowed to destroy blocks. 18 | */ 19 | private boolean canBreak; 20 | 21 | /** 22 | * Whether block physics (for example, sand falling) may occur 23 | */ 24 | private boolean blockPhysics; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/advanced/ChangingOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.advanced; 2 | 3 | import lombok.*; 4 | 5 | @SuppressWarnings("unused") 6 | @Getter 7 | @EqualsAndHashCode 8 | @ToString 9 | public class ChangingOptions { 10 | 11 | /** 12 | * Whether the weather changes (for example, may the snow or the rain occur) 13 | */ 14 | private boolean weatherChange; 15 | 16 | /** 17 | * Whether the players' food level changes, i.e players feel hunger. 18 | */ 19 | private boolean foodChange; 20 | 21 | /** 22 | * Whether the time changes (or always stays at the fixed value). 23 | */ 24 | private boolean timeChange; 25 | 26 | /** 27 | * Whether the mobs spawn. 28 | */ 29 | private boolean entitySpawn; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/advanced/DamageOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.advanced; 2 | 3 | import lombok.*; 4 | 5 | @SuppressWarnings("unused") 6 | @Getter 7 | @EqualsAndHashCode 8 | @ToString 9 | public class DamageOptions { 10 | 11 | /** 12 | * Whether the player can be damaged in any way. 13 | */ 14 | private boolean playerDamage; 15 | 16 | /** 17 | * Whether players a damaged by the falling 18 | */ 19 | private boolean fallDamage; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/advanced/ItemOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.advanced; 2 | 3 | import lombok.*; 4 | 5 | @SuppressWarnings("unused") 6 | @Getter 7 | @EqualsAndHashCode 8 | @ToString 9 | public class ItemOptions { 10 | 11 | /** 12 | * Whether players are able to drop items. 13 | */ 14 | private boolean drop; 15 | 16 | /** 17 | * Whether players are able to pickup items. 18 | */ 19 | private boolean pickup; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/advanced/PlayerOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.advanced; 2 | 3 | import io.riguron.game.core.GameState; 4 | import lombok.*; 5 | 6 | @SuppressWarnings("unused") 7 | @Getter 8 | @EqualsAndHashCode 9 | @ToString 10 | public class PlayerOptions { 11 | 12 | /** 13 | * Whether the players are able to move while the game 14 | * is starting (i.e when state of the game is STARTING) 15 | * 16 | * @see GameState 17 | */ 18 | private boolean moveWhileStarting; 19 | 20 | /** 21 | * Whether the players can drag items in their inventories 22 | */ 23 | private boolean inventoryClick; 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/map/MapConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.map; 2 | 3 | import lombok.Data; 4 | import org.bukkit.Location; 5 | import io.riguron.config.Configuration; 6 | 7 | @Data 8 | public class MapConfig implements Configuration { 9 | 10 | private String name; 11 | private Location spectator; 12 | } 13 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/map/solo/SoloMapConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.map.solo; 2 | 3 | import io.riguron.game.config.map.MapConfig; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import org.bukkit.Location; 7 | import io.riguron.game.config.map.MapConfig; 8 | 9 | import java.util.List; 10 | 11 | @Data 12 | @EqualsAndHashCode(callSuper = true) 13 | public class SoloMapConfig extends MapConfig { 14 | 15 | 16 | private List spawnLocations; 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/map/team/TeamLocationConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.map.team; 2 | 3 | import lombok.Data; 4 | import org.bukkit.Location; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class TeamLocationConfig { 10 | 11 | private String teamName; 12 | private List locations; 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/map/team/TeamMapConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.map.team; 2 | 3 | import io.riguron.game.config.map.MapConfig; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import io.riguron.game.config.map.MapConfig; 7 | 8 | import java.util.Map; 9 | 10 | @Data 11 | @EqualsAndHashCode(callSuper = true) 12 | public class TeamMapConfig extends MapConfig { 13 | 14 | 15 | private Map teamLocationConfigs; 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/team/TeamConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.team; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | import org.bukkit.DyeColor; 7 | 8 | @Getter 9 | @EqualsAndHashCode 10 | @ToString 11 | public class TeamConfig { 12 | 13 | private DyeColor color; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/config/team/TeamGameConfig.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.config.team; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | import io.riguron.game.config.GameOptions; 7 | 8 | import java.util.List; 9 | 10 | @Getter 11 | @EqualsAndHashCode(callSuper = true) 12 | @ToString 13 | public class TeamGameConfig extends GameOptions { 14 | 15 | private List teams; 16 | private int teamSize; 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/Game.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core; 2 | 3 | import io.riguron.game.map.GameMap; 4 | import io.riguron.game.map.GameMap; 5 | 6 | public interface Game { 7 | 8 | void start(); 9 | 10 | GameState getState(); 11 | 12 | void end(); 13 | 14 | void setState(GameState gameState); 15 | 16 | GameMap getMap(); 17 | 18 | void setMap(GameMap map); 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/GameDeathType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core; 2 | 3 | public enum GameDeathType { 4 | 5 | /** 6 | * The player does not actually die, he just gets dropped out 7 | * for a short period of time and then joins game again. This is 8 | * called "respawn". 9 | */ 10 | RESPAWN, 11 | 12 | /** 13 | * The player has only one life. Once he dies, he gets dropped out from the 14 | * game and does not participate in it anymore. 15 | */ 16 | DROP_OUT, 17 | 18 | /** 19 | * This is similar to DROP_OUT, but the player has multiple lives "in stock". 20 | * He completely dies when he runs out of lives. 21 | */ 22 | LIVES 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/GameKind.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core; 2 | 3 | public enum GameKind { 4 | 5 | SOLO, TEAM; 6 | } 7 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/decorator/ImmediateStartingGame.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core.decorator; 2 | 3 | import io.riguron.game.core.Game; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.game.core.type.DelegatingGame; 7 | 8 | /** 9 | * Represents a game that starts right after the waiting countdown 10 | * ends. 11 | */ 12 | public class ImmediateStartingGame extends DelegatingGame { 13 | 14 | public ImmediateStartingGame(Game delegate) { 15 | super(delegate); 16 | } 17 | 18 | @Override 19 | public void start() { 20 | super.start(); 21 | super.setState(GameState.ACTIVE); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/decorator/StartStateChangingGame.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core.decorator; 2 | 3 | import io.riguron.game.core.Game; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.game.core.type.DelegatingGame; 7 | 8 | public class StartStateChangingGame extends DelegatingGame { 9 | 10 | public StartStateChangingGame(Game delegate) { 11 | super(delegate); 12 | } 13 | 14 | @Override 15 | public void start() { 16 | super.setState(GameState.ACTIVE); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/core/type/DelegatingGame.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core.type; 2 | 3 | import io.riguron.game.core.Game; 4 | import lombok.experimental.Delegate; 5 | import io.riguron.game.core.Game; 6 | 7 | public class DelegatingGame implements Game { 8 | 9 | @Delegate 10 | private Game delegate; 11 | 12 | public DelegatingGame(Game delegate) { 13 | this.delegate = delegate; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/death/DeathListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.death; 2 | 3 | import io.riguron.game.death.handler.PlayerDeathHandler; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.entity.PlayerDeathEvent; 8 | import io.riguron.game.death.handler.PlayerDeathHandler; 9 | 10 | @RequiredArgsConstructor 11 | public class DeathListener implements Listener { 12 | 13 | private final PlayerDeathHandler playerDeathHandler; 14 | 15 | @EventHandler 16 | public void onDeath(PlayerDeathEvent e) { 17 | playerDeathHandler.onPlayerDeath(e.getEntity().getUniqueId()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/death/handler/DropOutDeathHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.death.handler; 2 | 3 | import io.riguron.game.player.repository.GamePlayerStorage; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.game.player.repository.GamePlayerStorage; 6 | 7 | import java.util.UUID; 8 | 9 | /** 10 | * Player has no second life and drops out from the game after the first death. 11 | */ 12 | @RequiredArgsConstructor 13 | public class DropOutDeathHandler implements PlayerDeathHandler { 14 | 15 | private final GamePlayerStorage gamePlayerStorage; 16 | 17 | @Override 18 | public void onPlayerDeath(UUID playerId) { 19 | gamePlayerStorage 20 | .getPlayer(playerId) 21 | .getStatus() 22 | .dropOut(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/death/handler/PlayerDeathHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.death.handler; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Represents a scenario that happens when a player dies. 7 | * 8 | * @see DropOutDeathHandler 9 | * @see LivesDeathHandler 10 | * @see RespawnDeathHandler 11 | */ 12 | public interface PlayerDeathHandler { 13 | 14 | /** 15 | * An action that happens on player's death. 16 | * 17 | * @param playerId id of player that dies 18 | */ 19 | void onPlayerDeath(UUID playerId); 20 | } 21 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/death/handler/RespawnDeathHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.death.handler; 2 | 3 | import io.riguron.game.death.Respawn; 4 | import io.riguron.game.player.repository.GamePlayerStorage; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.game.death.Respawn; 7 | import io.riguron.game.player.repository.GamePlayerStorage; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Player actually never drops out from the game, he just re-spawns. 13 | */ 14 | @RequiredArgsConstructor 15 | public class RespawnDeathHandler implements PlayerDeathHandler { 16 | 17 | private final Respawn respawn; 18 | private final GamePlayerStorage gamePlayerStorage; 19 | 20 | @Override 21 | public void onPlayerDeath(UUID uuid) { 22 | this.respawn.markForRespawn(gamePlayerStorage.getPlayer(uuid)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/event/GameEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.event; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | public class GameEvent extends Event { 7 | 8 | private static final HandlerList HANDLERS = new HandlerList(); 9 | 10 | @Override 11 | public HandlerList getHandlers() { 12 | return HANDLERS; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/event/GameStartEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.event; 2 | 3 | /** 4 | * This event is called only once, when the game starts. 5 | */ 6 | public class GameStartEvent extends GameEvent { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/event/GameStateChangeEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.event; 2 | 3 | import io.riguron.game.core.Game; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.Value; 6 | import io.riguron.game.core.Game; 7 | import io.riguron.game.core.GameState; 8 | 9 | @Value 10 | @EqualsAndHashCode(callSuper = true) 11 | public class GameStateChangeEvent extends GameEvent { 12 | 13 | private Game game; 14 | private GameState to; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/event/PlayerDropOutEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.event; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Value; 5 | 6 | import java.util.UUID; 7 | 8 | @Value 9 | @EqualsAndHashCode(callSuper = true) 10 | public class PlayerDropOutEvent extends GameEvent { 11 | 12 | private final UUID playerId; 13 | } 14 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/event/PlayerSpectatorEvent.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.event; 2 | 3 | import lombok.EqualsAndHashCode; 4 | import lombok.Value; 5 | import org.bukkit.entity.Player; 6 | 7 | /** 8 | * Event called when a player is made a spectator or, 9 | * on the contrary, returned back from the spectator to the game. 10 | */ 11 | @Value 12 | @EqualsAndHashCode(callSuper = true) 13 | public class PlayerSpectatorEvent extends GameEvent { 14 | 15 | private Player player; 16 | 17 | /** 18 | * True if player is made a spectator, false if he is already 19 | * a spectator and now returned back to the game. 20 | */ 21 | private boolean on; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/KitLoader.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import io.riguron.game.config.GameOptions; 6 | import io.riguron.system.task.startup.PostLoadTask; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Task responsible for loading kits into memory. 12 | */ 13 | @Slf4j 14 | @RequiredArgsConstructor 15 | public class KitLoader implements PostLoadTask { 16 | 17 | private final Kits kits; 18 | private final KitRepository kitRepository; 19 | private final GameOptions gameOptions; 20 | 21 | @Override 22 | public void run() { 23 | List kitList = kitRepository.findKitsByGameName(gameOptions.getGameName()); 24 | log.info("Loaded {} kits", kitList.size()); 25 | kitList.forEach(kits::addKit); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/KitRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit; 2 | 3 | import io.ebean.EbeanServer; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.util.List; 7 | 8 | @RequiredArgsConstructor 9 | public class KitRepository { 10 | 11 | private final EbeanServer ebeanServer; 12 | 13 | public List findKitsByGameName(String gameName) { 14 | return ebeanServer.createQuery(Kit.class) 15 | .fetch("description") 16 | .fetch("kitPermissions") 17 | .fetch("items") 18 | .where().eq("kitInformation.gameName", gameName) 19 | .findList(); 20 | } 21 | 22 | public void save(Kit kit) { 23 | ebeanServer.save(kit); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/KitSelectItem.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit; 2 | 3 | import io.riguron.game.kit.selector.inventory.KitSelectorInterface; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.bukkit.item.executable.ExecutableItem; 6 | import io.riguron.game.kit.selector.inventory.KitSelectorInterface; 7 | import org.bukkit.entity.Player; 8 | 9 | /** 10 | * Kit selector item listener. 11 | */ 12 | @RequiredArgsConstructor 13 | public class KitSelectItem implements ExecutableItem { 14 | 15 | private final KitSelectorInterface selectorInterface; 16 | 17 | @Override 18 | public void execute(Player player) { 19 | selectorInterface.displayTo(player); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/Kits.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Simple in-memory kit storage. 7 | */ 8 | public class Kits { 9 | 10 | private Map kitData = new HashMap<>(); 11 | private Kit defaultKit; 12 | 13 | public void addKit(Kit kit) { 14 | kitData.put(kit.getKitInformation().getName(), kit); 15 | if (kit.getKitInformation().isDefaultKit()) { 16 | this.defaultKit = kit; 17 | } 18 | } 19 | 20 | public List getAllKits() { 21 | return new ArrayList<>(kitData.values()); 22 | } 23 | 24 | public Kit getDefaultKit() { 25 | return defaultKit; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/permissions/AnyoneKitPermissions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | import io.riguron.system.internalization.Message; 4 | 5 | import javax.persistence.Entity; 6 | 7 | @Entity 8 | public class AnyoneKitPermissions extends KitPermissions { 9 | 10 | @Override 11 | public boolean isAvailableTo(KitChallenger challenger) { 12 | return true; 13 | } 14 | 15 | @Override 16 | public Message unavailabilityMessage(KitChallenger challenger) { 17 | throw new KitAvailabilityException("This kit is available to anyone"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/permissions/KitAvailabilityException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | public class KitAvailabilityException extends RuntimeException { 4 | 5 | KitAvailabilityException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/permissions/KitChallenger.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | public interface KitChallenger { 4 | 5 | boolean hasPermission(String permission); 6 | 7 | long getCoins(); 8 | 9 | boolean hasPurchase(int purchaseId); 10 | } 11 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/permissions/KitChallengerAdapter.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.player.PlayerProfile; 5 | 6 | @RequiredArgsConstructor 7 | public class KitChallengerAdapter implements KitChallenger { 8 | 9 | private final PlayerProfile playerProfile; 10 | 11 | @Override 12 | public boolean hasPermission(String permission) { 13 | return playerProfile.hasPermission(permission); 14 | } 15 | 16 | @Override 17 | public long getCoins() { 18 | return playerProfile.getCoins(); 19 | } 20 | 21 | @Override 22 | public boolean hasPurchase(int purchaseId) { 23 | return playerProfile.getPurchases().hasPurchase(purchaseId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/kit/permissions/KitPermissions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | import io.riguron.system.internalization.Message; 4 | 5 | import javax.persistence.*; 6 | 7 | @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 8 | @Entity 9 | public abstract class KitPermissions { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.AUTO) 13 | private int id; 14 | 15 | public abstract boolean isAvailableTo(KitChallenger challenger); 16 | 17 | public abstract Message unavailabilityMessage(KitChallenger challenger); 18 | 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/ListenerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener; 2 | 3 | import lombok.Value; 4 | import io.riguron.game.core.GameState; 5 | import org.bukkit.event.Listener; 6 | 7 | import java.util.List; 8 | 9 | @Value 10 | public class ListenerRegistration { 11 | 12 | /** 13 | * The native bukkit listener. 14 | */ 15 | private Listener listener; 16 | 17 | /** 18 | * States during which the listener is active. 19 | */ 20 | private List states; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/ListenerUnregister.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.bukkit.event.Listener; 5 | 6 | public class ListenerUnregister { 7 | 8 | public void unregister(Listener listener) { 9 | HandlerList.unregisterAll(listener); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/change/GameEndListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.change; 2 | 3 | import io.riguron.game.winner.WinningHandler; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.game.event.GameStateChangeEvent; 7 | import io.riguron.game.winner.WinningHandler; 8 | 9 | @RequiredArgsConstructor 10 | public class GameEndListener extends SingleStateChangeListener { 11 | 12 | private final WinningHandler winningHandler; 13 | 14 | @Override 15 | protected void onGameStateChange(GameStateChangeEvent gameStateChangeEvent) { 16 | winningHandler.gameFinished(); 17 | } 18 | 19 | @Override 20 | protected GameState getTriggerState() { 21 | return GameState.END; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/change/SingleStateChangeListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.change; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.Listener; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.game.event.GameStateChangeEvent; 7 | 8 | public abstract class SingleStateChangeListener implements Listener { 9 | 10 | @EventHandler 11 | public void listen(GameStateChangeEvent gameStateChangeEvent) { 12 | if (gameStateChangeEvent.getTo() == getTriggerState()) { 13 | this.onGameStateChange(gameStateChangeEvent); 14 | } 15 | } 16 | 17 | abstract void onGameStateChange(GameStateChangeEvent gameStateChangeEvent); 18 | 19 | abstract GameState getTriggerState(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/restrictions/ClickListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.restrictions; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.config.advanced.AdvancedGameOptions; 5 | import io.riguron.game.listener.state.active.ActiveStateListener; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.inventory.InventoryClickEvent; 8 | 9 | @RequiredArgsConstructor 10 | public class ClickListener extends ActiveStateListener { 11 | 12 | private final AdvancedGameOptions gameOptions; 13 | 14 | @EventHandler 15 | public void onInventoryClick(InventoryClickEvent e) { 16 | if (!gameOptions.getPlayerOptions().isInventoryClick()) { 17 | e.setCancelled(true); 18 | e.getWhoClicked().closeInventory(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/restrictions/TimeChangeRunner.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.restrictions; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.config.advanced.AdvancedGameOptions; 5 | import io.riguron.system.task.TaskFactory; 6 | import io.riguron.system.task.startup.PostLoadTask; 7 | import org.bukkit.Server; 8 | 9 | @RequiredArgsConstructor 10 | public class TimeChangeRunner implements PostLoadTask { 11 | 12 | private final AdvancedGameOptions advancedGameOptions; 13 | private final TaskFactory taskFactory; 14 | private final Server server; 15 | 16 | @Override 17 | public void run() { 18 | if (advancedGameOptions.getChangingOptions().isTimeChange()) { 19 | taskFactory.newRepeatingTask(() -> server.getWorlds().forEach(world -> world.setTime(0)), 10); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/start/GameStartListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.start; 2 | 3 | import io.riguron.game.core.Game; 4 | import io.riguron.game.event.GameStartEvent; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.game.core.Game; 7 | import io.riguron.game.event.GameStartEvent; 8 | import io.riguron.system.task.timer.Timer; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.Listener; 11 | 12 | @RequiredArgsConstructor 13 | public class GameStartListener implements Listener { 14 | 15 | private final Timer gameEndingTimer; 16 | private final Game game; 17 | 18 | @EventHandler 19 | public void onGameStart(GameStartEvent event) { 20 | gameEndingTimer.start(); 21 | game.getMap().teleportPlayers(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/start/TeamGameStartListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.start; 2 | 3 | import io.riguron.game.team.client.TeamAssigner; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.game.event.GameStartEvent; 6 | import io.riguron.game.team.client.TeamAssigner; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | 10 | @RequiredArgsConstructor 11 | public class TeamGameStartListener implements Listener { 12 | 13 | private final TeamAssigner teamAssigner; 14 | 15 | @EventHandler 16 | public void onGameStart(GameStartEvent e) { 17 | teamAssigner.assignRemaining(); 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/StateDependentListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state; 2 | 3 | import org.bukkit.event.Listener; 4 | import io.riguron.game.core.GameState; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Represents a listener that is active only while game is in a certain list 10 | * of states. 11 | */ 12 | public interface StateDependentListener extends Listener { 13 | 14 | /** 15 | * List of game states while this listener is active. 16 | * 17 | * @return states of the current listener 18 | */ 19 | List states(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/active/ActiveJoinListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.active; 2 | 3 | import io.riguron.game.player.spectator.Spectator; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import io.riguron.game.player.spectator.Spectator; 8 | 9 | @RequiredArgsConstructor 10 | public class ActiveJoinListener extends ActiveStateListener { 11 | 12 | private final Spectator spectator; 13 | 14 | @EventHandler 15 | public void onJoin(PlayerJoinEvent playerJoinEvent) { 16 | spectator.set(playerJoinEvent.getPlayer(), true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/active/ActiveStateListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.active; 2 | 3 | import io.riguron.game.listener.state.StateDependentListener; 4 | import io.riguron.game.core.GameState; 5 | import io.riguron.game.listener.state.StateDependentListener; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public class ActiveStateListener implements StateDependentListener { 11 | 12 | @Override 13 | public List states() { 14 | return Arrays.asList(GameState.STARTING, GameState.ACTIVE, GameState.END); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/active/DropoutQuitListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.active; 2 | 3 | import io.riguron.game.player.repository.GamePlayerStorage; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.player.PlayerQuitEvent; 7 | import io.riguron.game.player.repository.GamePlayerStorage; 8 | 9 | @RequiredArgsConstructor 10 | public class DropoutQuitListener extends ActiveStateListener { 11 | 12 | private final GamePlayerStorage playerStorage; 13 | 14 | @EventHandler 15 | public void onQuit(PlayerQuitEvent event) { 16 | playerStorage 17 | .getPlayer(event.getPlayer().getUniqueId()) 18 | .getStatus() 19 | .dropOut(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/active/PlayerSpectatorListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.active; 2 | 3 | import io.riguron.game.event.PlayerSpectatorEvent; 4 | import io.riguron.game.player.spectator.Spectator; 5 | import lombok.RequiredArgsConstructor; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import io.riguron.game.event.PlayerSpectatorEvent; 9 | import io.riguron.game.player.spectator.Spectator; 10 | 11 | @RequiredArgsConstructor 12 | public class PlayerSpectatorListener implements Listener { 13 | 14 | private final Spectator spectator; 15 | 16 | @EventHandler 17 | public void onPlayerSetSpectator(PlayerSpectatorEvent playerSpectatorEvent) { 18 | spectator.set(playerSpectatorEvent.getPlayer(), playerSpectatorEvent.isOn()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/starting/StartingBlockingListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.starting; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.config.advanced.AdvancedGameOptions; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.player.PlayerMoveEvent; 7 | 8 | @RequiredArgsConstructor 9 | public class StartingBlockingListener extends StartingStateListener { 10 | 11 | 12 | private final AdvancedGameOptions gameOptions; 13 | 14 | @EventHandler 15 | public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { 16 | if (!gameOptions.getPlayerOptions().isMoveWhileStarting()) { 17 | playerMoveEvent.setCancelled(true); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/starting/StartingStateListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.starting; 2 | 3 | import io.riguron.game.listener.state.StateDependentListener; 4 | import io.riguron.game.core.GameState; 5 | import io.riguron.game.listener.state.StateDependentListener; 6 | 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | public class StartingStateListener implements StateDependentListener { 11 | @Override 12 | public List states() { 13 | return Collections.singletonList(GameState.STARTING); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/waiting/WaitingItemsListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.waiting; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.bukkit.item.join.JoinItems; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | 8 | @RequiredArgsConstructor 9 | public class WaitingItemsListener extends WaitingStateListener { 10 | 11 | private final JoinItems joinItems; 12 | 13 | @EventHandler 14 | public void onJoin(PlayerJoinEvent event) { 15 | joinItems.giveTo(event.getPlayer()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/waiting/WaitingMoveListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.waiting; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.player.PlayerMoveEvent; 6 | import io.riguron.game.config.GameOptions; 7 | 8 | @RequiredArgsConstructor 9 | public class WaitingMoveListener extends WaitingStateListener { 10 | 11 | private final GameOptions gameOptions; 12 | 13 | @EventHandler 14 | public void onPlayerMove(PlayerMoveEvent playerMoveEvent) { 15 | if (playerMoveEvent.getTo().getY() < 0) { 16 | playerMoveEvent.getPlayer().teleport(gameOptions.getLobby()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/waiting/WaitingOnlineIndexer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.waiting; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.bukkit.server.OnlineIndexer; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | 9 | @RequiredArgsConstructor 10 | public class WaitingOnlineIndexer extends WaitingStateListener { 11 | 12 | private final OnlineIndexer onlineIndexer; 13 | 14 | @EventHandler 15 | public void join(PlayerJoinEvent e) { 16 | onlineIndexer.increment(); 17 | } 18 | 19 | @EventHandler 20 | public void quit(PlayerQuitEvent e) { 21 | onlineIndexer.decrement(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/listener/state/waiting/WaitingStateListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.state.waiting; 2 | 3 | import io.riguron.game.core.GameState; 4 | import io.riguron.game.listener.state.StateDependentListener; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.game.listener.state.StateDependentListener; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | public class WaitingStateListener implements StateDependentListener { 12 | @Override 13 | public List states() { 14 | return Arrays.asList(GameState.WAITING, GameState.COUNTDOWN); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/GameMap.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map; 2 | 3 | import java.util.UUID; 4 | 5 | public interface GameMap { 6 | 7 | String getName(); 8 | 9 | /** 10 | * Teleports all online players to the locations of this map. 11 | */ 12 | void teleportPlayers(); 13 | 14 | /** 15 | * Teleports single player to the one of map locations (picked randomly). 16 | * 17 | * @param playerId id of the players for the teleport. 18 | */ 19 | void teleportPlayer(UUID playerId); 20 | } 21 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/GameMaps.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map; 2 | 3 | import java.util.List; 4 | import java.util.NavigableMap; 5 | import java.util.Optional; 6 | import java.util.TreeMap; 7 | 8 | /** 9 | * Container storing all maps of the game. 10 | */ 11 | public class GameMaps { 12 | 13 | private NavigableMap gameMapStorage = new TreeMap<>(); 14 | 15 | public GameMaps(List loadedMaps) { 16 | loadedMaps.forEach(gameMap -> gameMapStorage.put(gameMap.getName(), gameMap)); 17 | } 18 | 19 | public Optional getMap(String key) { 20 | return Optional.ofNullable(gameMapStorage.get(key)); 21 | } 22 | 23 | public GameMap getArbitraryMap() { 24 | return gameMapStorage.firstEntry().getValue(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/type/AbstractGameMap.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map.type; 2 | 3 | import io.riguron.game.map.GameMap; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.game.map.GameMap; 6 | 7 | @RequiredArgsConstructor 8 | public abstract class AbstractGameMap implements GameMap { 9 | 10 | private final String name; 11 | 12 | @Override 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/vote/result/MapVotingResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map.vote.result; 2 | 3 | import java.util.List; 4 | 5 | public interface MapVotingResult { 6 | 7 | List description(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/vote/result/SuccessfulVoteResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map.vote.result; 2 | 3 | import lombok.Value; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | @Value 9 | public class SuccessfulVoteResult implements MapVotingResult { 10 | 11 | private int votes; 12 | private String mapName; 13 | 14 | @Override 15 | public List description() { 16 | return Arrays.asList("map.vote.success", String.valueOf(votes), mapName); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/map/vote/result/UnknownMapResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.map.vote.result; 2 | 3 | import lombok.Value; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | @Value 9 | public class UnknownMapResult implements MapVotingResult { 10 | 11 | private String map; 12 | 13 | @Override 14 | public List description() { 15 | return Arrays.asList("map.vote.unknown", map); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/module/GameBootstrapModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.module; 2 | 3 | import com.google.inject.AbstractModule; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.game.bootstrap.GameProvider; 6 | 7 | @RequiredArgsConstructor 8 | public class GameBootstrapModule extends AbstractModule { 9 | 10 | private final GameProvider gameProvider; 11 | 12 | @Override 13 | protected void configure() { 14 | bind(GameProvider.class).toInstance(gameProvider); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/module/game/StartingModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.module.game; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Singleton; 5 | import com.google.inject.multibindings.ProvidesIntoSet; 6 | import io.riguron.game.config.advanced.AdvancedGameOptions; 7 | import io.riguron.game.listener.state.StateDependentListener; 8 | import io.riguron.game.listener.state.starting.StartingBlockingListener; 9 | 10 | public class StartingModule extends AbstractModule { 11 | 12 | @ProvidesIntoSet 13 | @Singleton 14 | public StateDependentListener startingListener(AdvancedGameOptions advancedGameOptions) { 15 | return new StartingBlockingListener(advancedGameOptions); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This module represents a plain game framework. 3 | */ 4 | package io.riguron.game; -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/GamePlayer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player; 2 | 3 | import org.bukkit.Location; 4 | 5 | import java.util.UUID; 6 | 7 | public interface GamePlayer { 8 | 9 | String getName(); 10 | 11 | void teleport(Location location); 12 | 13 | GamePlayerStatus getStatus(); 14 | 15 | GameScore getScore(); 16 | 17 | UUID getId(); 18 | 19 | GamePlayerKit getKit(); 20 | } 21 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/GamePlayerKit.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player; 2 | 3 | import lombok.Data; 4 | import io.riguron.game.kit.Kit; 5 | 6 | @Data 7 | public class GamePlayerKit { 8 | 9 | private Kit currentKit; 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/GamePlayerStatus.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player; 2 | 3 | public interface GamePlayerStatus { 4 | 5 | /** 6 | * Drops the player out of the game. 7 | */ 8 | void dropOut(); 9 | 10 | /** 11 | * Marks player as a spectator (or returns player to the game by removing the 12 | * spectator mode for this player). 13 | * 14 | * @param spectator true for making player a spectator, false for returning player to the game 15 | */ 16 | void setSpectator(boolean spectator); 17 | 18 | boolean isAlive(); 19 | 20 | boolean isSpectator(); 21 | 22 | /** 23 | * Time in millis when the player was dropped out. 24 | * 25 | * @return time of player's drop out. 26 | */ 27 | int getDropOutTime(); 28 | } 29 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/GameScore.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Score holder. 7 | */ 8 | @Data 9 | public class GameScore implements Comparable { 10 | 11 | private int value; 12 | 13 | public void increment() { 14 | this.value++; 15 | } 16 | 17 | @Override 18 | public int compareTo(GameScore o) { 19 | return Integer.compare(getValue(), o.getValue()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/factory/GamePlayerFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.factory; 2 | 3 | import io.riguron.game.player.GamePlayer; 4 | import org.bukkit.entity.Player; 5 | import io.riguron.game.player.GamePlayer; 6 | 7 | public interface GamePlayerFactory { 8 | 9 | T createPlayer(Player source); 10 | } 11 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/factory/StandardPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.factory; 2 | 3 | import io.riguron.game.player.BasicGamePlayer; 4 | import io.riguron.game.player.GamePlayer; 5 | import io.riguron.game.player.GamePlayer; 6 | import org.bukkit.entity.Player; 7 | import io.riguron.game.player.BasicGamePlayer; 8 | 9 | public class StandardPlayerFactory implements GamePlayerFactory { 10 | @Override 11 | public GamePlayer createPlayer(Player source) { 12 | return new BasicGamePlayer(source); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/factory/TeamPlayerFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.factory; 2 | 3 | import io.riguron.game.player.team.TeamPlayer; 4 | import io.riguron.game.player.team.TeamPlayerBasic; 5 | import io.riguron.game.player.team.TeamPlayer; 6 | import org.bukkit.entity.Player; 7 | import io.riguron.game.player.team.TeamPlayerBasic; 8 | 9 | public class TeamPlayerFactory implements GamePlayerFactory { 10 | 11 | @Override 12 | public TeamPlayer createPlayer(Player source) { 13 | return new TeamPlayerBasic(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/repository/GamePlayerStorage.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.repository; 2 | 3 | import io.riguron.game.player.GamePlayer; 4 | 5 | import java.util.Collection; 6 | import java.util.UUID; 7 | 8 | public interface GamePlayerStorage

{ 9 | 10 | P getPlayer(UUID playerId); 11 | 12 | void addPlayer(UUID player, P gamePlayer); 13 | 14 | void removePlayer(UUID player); 15 | 16 | Collection

getAllPlayers(); 17 | 18 | long getAlivePlayerCount(); 19 | 20 | boolean contains(UUID uuid); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/status/PlayerLives.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.status; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.UUID; 6 | 7 | /** 8 | * Container class storing data for players' lives. 9 | */ 10 | public class PlayerLives { 11 | 12 | private static final int TOTAL_LIVES = 5; 13 | 14 | private Map livesData = new HashMap<>(); 15 | 16 | public Integer getPlayerLives(UUID uuid) { 17 | return livesData.computeIfAbsent(uuid, x -> TOTAL_LIVES); 18 | } 19 | 20 | public Integer decrementLives(UUID uuid) { 21 | return livesData.merge(uuid, TOTAL_LIVES - 1, (x, y) -> x - 1); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/player/team/TeamPlayer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.player.team; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.player.GamePlayer; 5 | import io.riguron.game.team.Team; 6 | 7 | public interface TeamPlayer extends GamePlayer { 8 | 9 | Team getTeam(); 10 | 11 | void setTeam(Team team); 12 | 13 | boolean isInTeam(); 14 | 15 | boolean isTeamMate(TeamPlayer other); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/plugin/module/ModuleConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.plugin.module; 2 | 3 | import com.google.inject.Module; 4 | 5 | import java.util.List; 6 | 7 | public interface ModuleConfiguration { 8 | 9 | List getModules(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/server/GameServerUnregister.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.server; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.common.shutdown.ShutdownHook; 5 | import io.riguron.server.ServerName; 6 | import io.riguron.server.repository.ServerFieldType; 7 | import io.riguron.server.repository.ServerRepository; 8 | 9 | @RequiredArgsConstructor 10 | public class GameServerUnregister implements ShutdownHook { 11 | 12 | private final ServerRepository serverRepository; 13 | private final ServerName serverName; 14 | 15 | @Override 16 | public void run() { 17 | serverRepository.set(serverName.get(), ServerFieldType.ACTIVE, false); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/setup/MapSetup.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.setup; 2 | 3 | import org.bukkit.Location; 4 | import io.riguron.game.config.map.MapConfig; 5 | 6 | public interface MapSetup { 7 | 8 | /** 9 | * Resets all defined locations. 10 | */ 11 | void reset(); 12 | 13 | MapConfig getConfig(); 14 | 15 | void setSpectator(Location location); 16 | 17 | void setName(String name); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/setup/command/SoloAddSpawnCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.setup.command; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.bukkit.Server; 5 | import org.bukkit.entity.Player; 6 | import io.riguron.command.base.Command; 7 | import io.riguron.command.base.CommandExecution; 8 | import io.riguron.game.setup.SoloMapSetup; 9 | 10 | @RequiredArgsConstructor 11 | public class SoloAddSpawnCommand implements Command { 12 | 13 | private final SoloMapSetup soloMapSetup; 14 | private final Server server; 15 | 16 | @Override 17 | public void execute(CommandExecution execution) { 18 | Player player = server.getPlayer(execution.getSender().getId()); 19 | player.sendMessage("Added location"); 20 | soloMapSetup.addLocation(player.getLocation()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/setup/module/SoloSetupModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.setup.module; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Provides; 5 | import com.google.inject.Singleton; 6 | import io.riguron.game.setup.MapSetup; 7 | import io.riguron.game.setup.SoloMapSetup; 8 | 9 | public class SoloSetupModule extends AbstractModule { 10 | 11 | @Provides 12 | @Singleton 13 | public MapSetup soloMapSetup() { 14 | return new SoloMapSetup(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/setup/module/TeamSetupModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.setup.module; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Provides; 5 | import com.google.inject.Singleton; 6 | import io.riguron.game.setup.MapSetup; 7 | import io.riguron.game.setup.TeamMapSetup; 8 | 9 | public class TeamSetupModule extends AbstractModule { 10 | 11 | @Provides 12 | @Singleton 13 | public MapSetup teamMapSetup() { 14 | return new TeamMapSetup(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/shop/KitPurchasableAdapter.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.shop; 2 | 3 | import io.riguron.game.kit.Kit; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.system.shop.Purchasable; 6 | import io.riguron.game.kit.Kit; 7 | 8 | @RequiredArgsConstructor 9 | public class KitPurchasableAdapter implements Purchasable { 10 | 11 | private final Kit kit; 12 | 13 | @Override 14 | public int getId() { 15 | return kit.getId(); 16 | } 17 | 18 | @Override 19 | public long getPrice() { 20 | return kit.getKitInformation().getPrice(); 21 | } 22 | 23 | @Override 24 | public String getDescription() { 25 | return "Kit [" + kit.getKitInformation().getName() + "]"; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/Team.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team; 2 | 3 | import org.bukkit.DyeColor; 4 | import io.riguron.game.player.GameScore; 5 | 6 | public interface Team { 7 | 8 | /** 9 | * Color of the team. Displayed in the chat, scoreboard, 10 | * tab list, etc. 11 | * 12 | * @return team's color. 13 | */ 14 | DyeColor getColor(); 15 | 16 | String getName(); 17 | 18 | TeamPlayers getPlayers(); 19 | 20 | /** 21 | * Whether at least one of players in the team is alive. 22 | * 23 | * @return whether the team has alive players. 24 | */ 25 | boolean isAlive(); 26 | 27 | default boolean isFull() { 28 | return getPlayers().count() == getPlayers().max(); 29 | } 30 | 31 | GameScore getScore(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/TeamPlayers.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team; 2 | 3 | import io.riguron.game.team.add.TeamAddResult; 4 | import io.riguron.game.player.team.TeamPlayer; 5 | import io.riguron.game.team.add.TeamAddResult; 6 | 7 | import java.util.Set; 8 | 9 | public interface TeamPlayers { 10 | 11 | Set list(); 12 | 13 | int count(); 14 | 15 | int max(); 16 | 17 | long alive(); 18 | 19 | TeamAddResult add(TeamPlayer player); 20 | 21 | boolean remove(TeamPlayer gamePlayer); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/add/AbstractAddResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.add; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.team.Team; 5 | import io.riguron.game.team.Team; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | @RequiredArgsConstructor 11 | public abstract class AbstractAddResult implements TeamAddResult { 12 | 13 | private final Team team; 14 | 15 | @Override 16 | public List description() { 17 | return Arrays.asList(messageDescription(), team.getName()); 18 | } 19 | 20 | abstract String messageDescription(); 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/add/AlreadyInCurrentTeam.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.add; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.team.Team; 5 | 6 | public class AlreadyInCurrentTeam extends AbstractAddResult { 7 | 8 | public AlreadyInCurrentTeam(Team team) { 9 | super(team); 10 | } 11 | 12 | @Override 13 | String messageDescription() { 14 | return "teams.add.already_in_team"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/add/SuccessfulAdd.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.add; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.team.Team; 5 | 6 | public class SuccessfulAdd extends AbstractAddResult { 7 | 8 | public SuccessfulAdd(Team team) { 9 | super(team); 10 | } 11 | 12 | @Override 13 | String messageDescription() { 14 | return "teams.add.success"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/add/TeamAddResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.add; 2 | 3 | import java.util.List; 4 | 5 | public interface TeamAddResult { 6 | 7 | List description(); 8 | } 9 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/add/TeamIsFull.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.add; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.team.Team; 5 | 6 | public class TeamIsFull extends AbstractAddResult { 7 | 8 | public TeamIsFull(Team team) { 9 | super(team); 10 | } 11 | 12 | @Override 13 | String messageDescription() { 14 | return "team.add.is_full"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/client/TeamAssigner.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.client; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.player.repository.GamePlayerStorage; 5 | import io.riguron.game.player.team.TeamPlayer; 6 | import io.riguron.game.team.repository.Teams; 7 | 8 | @RequiredArgsConstructor 9 | public class TeamAssigner { 10 | 11 | private final GamePlayerStorage gamePlayerStorage; 12 | private final Teams teams; 13 | 14 | public void assignRemaining() { 15 | gamePlayerStorage.getAllPlayers().forEach(teamPlayer -> { 16 | if (!teamPlayer.isInTeam()) { 17 | teams.getMostFreeTeam().getPlayers().add(teamPlayer); 18 | } 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/team/repository/Teams.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.team.repository; 2 | 3 | import io.riguron.game.team.Team; 4 | 5 | import java.util.Optional; 6 | import java.util.Set; 7 | 8 | public interface Teams { 9 | 10 | Optional getByName(String name); 11 | 12 | Set getTeamNames(); 13 | 14 | Team getMostFreeTeam(); 15 | 16 | void addTeam(Team team); 17 | 18 | Set getAllTeams(); 19 | 20 | int getAliveTeams(); 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/timer/GameEndingCountdown.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.timer; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.system.internalization.Message; 6 | import io.riguron.system.stream.Broadcast; 7 | import io.riguron.system.task.timer.CountdownTask; 8 | 9 | @RequiredArgsConstructor 10 | public class GameEndingCountdown implements CountdownTask { 11 | 12 | private final Game game; 13 | private final Broadcast broadcast; 14 | 15 | @Override 16 | public void onTick(long tick) { 17 | if (tick % 30 == 0 || tick <= 10) { 18 | broadcast.broadcast(new Message("game.state.ending", tick)); 19 | } 20 | } 21 | 22 | @Override 23 | public void complete() { 24 | game.end(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/timer/GameStartingCountdown.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.timer; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.system.internalization.Message; 6 | import io.riguron.system.stream.Broadcast; 7 | import io.riguron.system.task.timer.CountdownTask; 8 | 9 | /** 10 | * Waiting countdown. 11 | */ 12 | @RequiredArgsConstructor 13 | public class GameStartingCountdown implements CountdownTask { 14 | 15 | private final Game game; 16 | private final Broadcast broadcast; 17 | 18 | @Override 19 | public void onTick(long tick) { 20 | broadcast.broadcast(new Message("game.state.ready", tick)); 21 | } 22 | 23 | @Override 24 | public void complete() { 25 | this.game.start(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/timer/StartManagingTimer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.timer; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.game.core.GameState; 6 | import io.riguron.system.task.timer.Timer; 7 | 8 | @RequiredArgsConstructor 9 | public class StartManagingTimer implements Timer { 10 | 11 | private final Game game; 12 | private final Timer delegate; 13 | 14 | @Override 15 | public void start() { 16 | game.setState(GameState.COUNTDOWN); 17 | delegate.start(); 18 | } 19 | 20 | @Override 21 | public void stop() { 22 | game.setState(GameState.WAITING); 23 | delegate.stop(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/WinningHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner; 2 | 3 | public interface WinningHandler { 4 | 5 | /** 6 | * Represents an action that happens when the game ends, 7 | * including winner calculation, stats saving and so forth. 8 | */ 9 | void gameFinished(); 10 | } 11 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/solo/SoloResultCalculation.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.solo; 2 | 3 | import io.riguron.game.winner.solo.order.Place; 4 | import io.riguron.game.winner.solo.order.Place; 5 | 6 | import java.util.List; 7 | 8 | public interface SoloResultCalculation { 9 | 10 | List getPlaces(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/solo/order/Place.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.solo.order; 2 | 3 | import lombok.Value; 4 | import io.riguron.game.player.GamePlayer; 5 | 6 | @Value 7 | public class Place { 8 | 9 | private int index; 10 | private GamePlayer gamePlayer; 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/solo/order/PlaceOrderBy.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.solo.order; 2 | 3 | import io.riguron.game.player.GamePlayer; 4 | 5 | import java.util.function.Function; 6 | 7 | public interface PlaceOrderBy extends Function { 8 | 9 | Integer apply(GamePlayer gamePlayer); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/solo/order/PlaceOrderByDropout.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.solo.order; 2 | 3 | import io.riguron.game.player.GamePlayer; 4 | 5 | public class PlaceOrderByDropout implements PlaceOrderBy { 6 | 7 | @Override 8 | public Integer apply(GamePlayer gamePlayer) { 9 | return gamePlayer.getStatus().getDropOutTime(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/solo/order/PlaceOrderByScore.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.solo.order; 2 | 3 | import io.riguron.game.player.GamePlayer; 4 | 5 | public class PlaceOrderByScore implements PlaceOrderBy { 6 | 7 | @Override 8 | public Integer apply(GamePlayer gamePlayer) { 9 | return gamePlayer.getScore().getValue(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/team/AlivePlayersResultCalculation.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.team; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.team.repository.Teams; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.game.team.Team; 7 | import io.riguron.game.team.repository.Teams; 8 | 9 | @RequiredArgsConstructor 10 | public class AlivePlayersResultCalculation implements TeamResultCalculation { 11 | 12 | private final Teams teams; 13 | 14 | @Override 15 | public Team calculateWinningTeam() { 16 | return teams 17 | .getAllTeams() 18 | .stream() 19 | .filter(Team::isAlive) 20 | .findFirst() 21 | .orElseThrow(IllegalStateException::new); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/team/ScoreTeamResultCalculation.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.team; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.team.repository.Teams; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.game.team.Team; 7 | import io.riguron.game.team.repository.Teams; 8 | 9 | import java.util.Comparator; 10 | 11 | @RequiredArgsConstructor 12 | public class ScoreTeamResultCalculation implements TeamResultCalculation { 13 | 14 | private final Teams teams; 15 | 16 | @Override 17 | public Team calculateWinningTeam() { 18 | return teams 19 | .getAllTeams() 20 | .stream() 21 | .max(Comparator.comparing(Team::getScore)) 22 | .orElseThrow(IllegalStateException::new); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/team/TeamResultCalculation.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.team; 2 | 3 | import io.riguron.game.team.Team; 4 | 5 | public interface TeamResultCalculation { 6 | 7 | Team calculateWinningTeam(); 8 | } 9 | -------------------------------------------------------------------------------- /Game/src/main/java/io/riguron/game/winner/team/TeamWinningHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.winner.team; 2 | 3 | import io.riguron.game.team.Team; 4 | import io.riguron.game.winner.WinningHandler; 5 | import lombok.RequiredArgsConstructor; 6 | import io.riguron.game.team.Team; 7 | import io.riguron.game.winner.WinningHandler; 8 | import io.riguron.system.internalization.Message; 9 | import io.riguron.system.stream.Broadcast; 10 | 11 | @RequiredArgsConstructor 12 | public class TeamWinningHandler implements WinningHandler { 13 | 14 | private final TeamResultCalculation teamResultCalculation; 15 | private final Broadcast broadcast; 16 | 17 | @Override 18 | public void gameFinished() { 19 | Team team = teamResultCalculation.calculateWinningTeam(); 20 | broadcast.broadcast(new Message("game.winning.team", team.getName())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Game/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Game 2 | version: 1.1 3 | author: riguron 4 | main: io.riguron.game.plugin.GamePlugin 5 | -------------------------------------------------------------------------------- /Game/src/test/java/io/riguron/game/core/decorator/ImmediateStartingGameTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core.decorator; 2 | 3 | import io.riguron.game.core.Game; 4 | import io.riguron.game.core.GameState; 5 | import org.junit.Test; 6 | import io.riguron.game.core.Game; 7 | import io.riguron.game.core.GameState; 8 | 9 | import static org.mockito.Mockito.mock; 10 | import static org.mockito.Mockito.verify; 11 | 12 | public class ImmediateStartingGameTest { 13 | 14 | @Test 15 | public void start() { 16 | 17 | Game delegate = mock(Game.class); 18 | ImmediateStartingGame immediateStartingGame = new ImmediateStartingGame(delegate); 19 | immediateStartingGame.start(); 20 | 21 | verify(delegate).start(); 22 | verify(delegate).setState(GameState.ACTIVE); 23 | 24 | 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /Game/src/test/java/io/riguron/game/core/decorator/StartStateChangingGameTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.core.decorator; 2 | 3 | import org.junit.Test; 4 | import io.riguron.game.core.Game; 5 | import io.riguron.game.core.GameState; 6 | 7 | import static org.mockito.Mockito.mock; 8 | import static org.mockito.Mockito.times; 9 | import static org.mockito.Mockito.verify; 10 | 11 | public class StartStateChangingGameTest { 12 | 13 | @Test 14 | public void start() { 15 | Game delegate = mock(Game.class); 16 | StartStateChangingGame startStateChangingGame = new StartStateChangingGame(delegate); 17 | startStateChangingGame.start(); 18 | 19 | verify(delegate, times(0)).start(); 20 | verify(delegate).setState(GameState.ACTIVE); 21 | } 22 | } -------------------------------------------------------------------------------- /Game/src/test/java/io/riguron/game/kit/permissions/AnyoneKitPermissionsTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.kit.permissions; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertTrue; 6 | import static org.mockito.Mockito.mock; 7 | 8 | public class AnyoneKitPermissionsTest { 9 | 10 | @Test 11 | public void isAvailableTo() { 12 | AnyoneKitPermissions anyoneKitPermissions = new AnyoneKitPermissions(); 13 | assertTrue(anyoneKitPermissions.isAvailableTo(mock(KitChallenger.class))); 14 | } 15 | 16 | @Test(expected = KitAvailabilityException.class) 17 | public void unavailabilityMessage() { 18 | AnyoneKitPermissions anyoneKitPermissions = new AnyoneKitPermissions(); 19 | anyoneKitPermissions.unavailabilityMessage(mock(KitChallenger.class)); 20 | } 21 | } -------------------------------------------------------------------------------- /Game/src/test/java/io/riguron/game/listener/change/GameCountdownListenerTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.game.listener.change; 2 | 3 | public class GameCountdownListenerTest { 4 | 5 | } -------------------------------------------------------------------------------- /Game/src/test/resources/advanced.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Game/src/test/resources/database.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jolice/MinecraftNetwork/7ed43098a5ba7574e2fb19509e363c3cf124fc0b/Game/src/test/resources/database.properties -------------------------------------------------------------------------------- /Game/src/test/resources/game.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Game/src/test/resources/maps/map.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MyMap" 3 | } -------------------------------------------------------------------------------- /IO/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | MinecraftNetwork 7 | io.riguron 8 | 1.0 9 | 10 | 4.0.0 11 | 12 | io 13 | 1.0 14 | 15 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/factory/DataFormat.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.factory; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @RequiredArgsConstructor 7 | public enum DataFormat { 8 | 9 | JSON("json"), YAML("yaml"); 10 | 11 | @Getter 12 | private final String extension; 13 | 14 | public String append(String fileName) { 15 | return fileName + "." + extension; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/factory/stream/StreamProviderFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.factory.stream; 2 | 3 | import io.riguron.io.provider.InputStreamProvider; 4 | import io.riguron.io.provider.OutputStreamProvider; 5 | 6 | public interface StreamProviderFactory { 7 | 8 | InputStreamProvider newInputStreamProvider(String source); 9 | 10 | OutputStreamProvider newOutputStreamProvider(String target); 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/file/ResourceInputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.file; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.io.provider.InputStreamProvider; 5 | 6 | import java.io.InputStream; 7 | 8 | @RequiredArgsConstructor 9 | public class ResourceInputStreamProvider implements InputStreamProvider { 10 | 11 | private final String resource; 12 | 13 | @Override 14 | public InputStream getInputStream() { 15 | final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(resource); 16 | if (resourceAsStream == null) { 17 | throw new IllegalArgumentException("Resource not found: " + resource); 18 | } 19 | return resourceAsStream; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/list/DirectoryList.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.list; 2 | 3 | import java.util.List; 4 | 5 | public interface DirectoryList { 6 | 7 | /** 8 | * Returns list of files in the specified directory. 9 | * 10 | * @param directory target directory 11 | * @return names of files residing in the target directory 12 | */ 13 | List listDirectory(String directory); 14 | } 15 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/list/FileDirectoryList.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.list; 2 | 3 | import java.io.IOException; 4 | import java.io.UncheckedIOException; 5 | import java.nio.file.Files; 6 | import java.nio.file.Path; 7 | import java.nio.file.Paths; 8 | import java.util.List; 9 | import java.util.stream.Collectors; 10 | import java.util.stream.Stream; 11 | 12 | public class FileDirectoryList extends GenericDirectoryList { 13 | 14 | @Override 15 | List getFiles(String directory) { 16 | try (Stream files = Files.list(Paths.get(directory))) { 17 | return files.map(Path::toString).collect(Collectors.toList()); 18 | } catch (IOException e) { 19 | throw new UncheckedIOException(e); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/list/GenericDirectoryList.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.list; 2 | 3 | import io.riguron.io.util.RemoveExtension; 4 | 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | 8 | public abstract class GenericDirectoryList implements DirectoryList { 9 | 10 | @Override 11 | public List listDirectory(String directory) { 12 | return getFiles(directory) 13 | .stream() 14 | .map(new RemoveExtension()) 15 | .collect(Collectors.toList()); 16 | } 17 | 18 | abstract List getFiles(String directory); 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple framework for I/O operations. 3 | */ 4 | package io.riguron.io; -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/provider/InputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.provider; 2 | 3 | import java.io.InputStream; 4 | 5 | public interface InputStreamProvider { 6 | 7 | InputStream getInputStream(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/provider/OutputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.provider; 2 | 3 | import java.io.OutputStream; 4 | 5 | public interface OutputStreamProvider { 6 | 7 | OutputStream getOutputStream(); 8 | } 9 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/provider/file/FileInputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.provider.file; 2 | 3 | import lombok.AllArgsConstructor; 4 | import io.riguron.io.provider.InputStreamProvider; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.UncheckedIOException; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | 12 | @AllArgsConstructor 13 | public class FileInputStreamProvider implements InputStreamProvider { 14 | 15 | private Path path; 16 | 17 | @Override 18 | public InputStream getInputStream() { 19 | try { 20 | return Files.newInputStream(path); 21 | } catch (IOException e) { 22 | throw new UncheckedIOException(e); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/provider/url/URLInputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.provider.url; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.io.provider.InputStreamProvider; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.UncheckedIOException; 9 | import java.net.URL; 10 | 11 | @RequiredArgsConstructor 12 | public class URLInputStreamProvider implements InputStreamProvider { 13 | 14 | private final URL url; 15 | 16 | @Override 17 | public InputStream getInputStream() { 18 | try { 19 | return url.openStream(); 20 | } catch (IOException e) { 21 | throw new UncheckedIOException(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/provider/url/URLOutputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.provider.url; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.io.provider.OutputStreamProvider; 5 | 6 | import java.io.IOException; 7 | import java.io.OutputStream; 8 | import java.io.UncheckedIOException; 9 | import java.net.URL; 10 | 11 | @RequiredArgsConstructor 12 | public class URLOutputStreamProvider implements OutputStreamProvider { 13 | 14 | private final URL url; 15 | 16 | @Override 17 | public OutputStream getOutputStream() { 18 | try { 19 | return url.openConnection().getOutputStream(); 20 | } catch (IOException e) { 21 | throw new UncheckedIOException(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/stream/StreamReader.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.stream; 2 | 3 | public interface StreamReader { 4 | 5 | T read(); 6 | } 7 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/stream/StreamWriter.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.stream; 2 | 3 | public interface StreamWriter { 4 | 5 | void write(Object target); 6 | } 7 | -------------------------------------------------------------------------------- /IO/src/main/java/io/riguron/io/util/RemoveExtension.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.util; 2 | 3 | import java.util.function.Function; 4 | 5 | public class RemoveExtension implements Function { 6 | 7 | @Override 8 | public String apply(String value) { 9 | return value.contains(".") ? value.substring(0, value.lastIndexOf('.')) : value; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /IO/src/test/java/io/riguron/io/util/RemoveExtensionTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.io.util; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class RemoveExtensionTest { 8 | 9 | @Test 10 | public void apply() { 11 | RemoveExtension removeExtension = new RemoveExtension(); 12 | String result = removeExtension.apply("str.txt"); 13 | assertEquals("str", result); 14 | } 15 | } -------------------------------------------------------------------------------- /IO/src/test/resources/in.txt: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/Message.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging; 2 | 3 | /** 4 | * Marker interface for objects transferred over the network. 5 | */ 6 | public interface Message { 7 | } 8 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/MessagingChannels.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.NoArgsConstructor; 5 | 6 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 7 | public class MessagingChannels { 8 | 9 | /** 10 | * The channel that all proxies listen to 11 | */ 12 | public static final String PROXY = "Proxy"; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/MessagingException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging; 2 | 3 | public class MessagingException extends RuntimeException { 4 | 5 | public MessagingException(Throwable e) { 6 | super(e); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/MessagingService.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging; 2 | 3 | public interface MessagingService { 4 | 5 | /** 6 | * Transfers a message to another server through its channel. 7 | * 8 | * @param message object being sent 9 | * @param receiver server (or group of servers) that receive a message 10 | */ 11 | void send(Message message, String receiver); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/amqp/AMQPException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.amqp; 2 | 3 | public class AMQPException extends RuntimeException { 4 | 5 | public AMQPException(Throwable cause) { 6 | super(cause); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/handler/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.handler; 2 | 3 | import java.lang.reflect.Type; 4 | 5 | /** 6 | * Class responsible for handling incoming messages of a certain type. 7 | * 8 | * @param type of the messages the handler handles 9 | */ 10 | public interface MessageHandler { 11 | 12 | /** 13 | * Message handling logic. 14 | * 15 | * @param message body of message 16 | */ 17 | void accept(T message); 18 | 19 | /** 20 | * Type of the message. 21 | * 22 | * @return message type. 23 | */ 24 | Type getMessageType(); 25 | } 26 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/Alert.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class Alert implements Message { 11 | 12 | private String message; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/KickProxyCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class KickProxyCommand implements Message { 11 | 12 | private String playerName; 13 | private String reason; 14 | } 15 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/PrivateMessageCommand.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | 7 | @Data 8 | @Setter(AccessLevel.NONE) 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class PrivateMessageCommand implements Message { 12 | 13 | private String from; 14 | private String text; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/RegisterServer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class RegisterServer implements Message { 11 | 12 | private String name; 13 | private String address; 14 | private int port; 15 | private int maxPlayers; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/party/PartyChat.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message.party; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | 7 | @Data 8 | @Setter(AccessLevel.NONE) 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class PartyChat implements Message { 12 | 13 | private String receiver; 14 | private String text; 15 | private String from; 16 | } 17 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/party/PartyDisband.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message.party; 2 | 3 | import io.riguron.messaging.Message; 4 | import lombok.*; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class PartyDisband implements Message { 11 | 12 | private String memberName; 13 | } 14 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/party/PartyInvite.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message.party; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class PartyInvite implements Message { 11 | 12 | private String owner; 13 | private String invited; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/message/party/PartyTeleport.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.message.party; 2 | 3 | import lombok.*; 4 | import io.riguron.messaging.Message; 5 | 6 | @Data 7 | @Setter(AccessLevel.NONE) 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class PartyTeleport implements Message { 11 | 12 | private String player; 13 | private String targetServer; 14 | } 15 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Module responsible for communications between independent 3 | * servers. 4 | */ 5 | package io.riguron.messaging; -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/serialize/MessageData.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.serialize; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class MessageData { 7 | 8 | private String type; 9 | private String content; 10 | } 11 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/serialize/MessageDataExtractor.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.serialize; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | 5 | public class MessageDataExtractor { 6 | 7 | /** 8 | * Extracts message type and body from the raw serialized string. 9 | * 10 | * @param payload serialized message with type prefix 11 | * @return object containing message type and data 12 | */ 13 | public MessageData getMessageData(byte[] payload) { 14 | String dataString = new String(payload, StandardCharsets.UTF_8); 15 | int separator = dataString.indexOf(':'); 16 | return new MessageData(dataString.substring(0, separator), dataString.substring(separator + 1, dataString.length())); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/serialize/MessageDeserializer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.serialize; 2 | 3 | import com.google.gson.Gson; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.lang.reflect.Type; 7 | 8 | @RequiredArgsConstructor 9 | public class MessageDeserializer { 10 | 11 | private final Gson gson; 12 | 13 | public T deserialize(String json, Type type) { 14 | return gson.fromJson(json, type); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Messaging/src/main/java/io/riguron/messaging/serialize/MessageSerializer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.serialize; 2 | 3 | import com.google.gson.Gson; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.messaging.Message; 6 | 7 | 8 | @RequiredArgsConstructor 9 | public class MessageSerializer { 10 | 11 | private final Gson gson; 12 | 13 | /** 14 | * Serializes a message with accordance to the following format: 15 | *

16 | * "Name of Java message type:json message body" 17 | * 18 | * @param message body of the message 19 | * @return serialized string 20 | */ 21 | public byte[] serialize(Message message) { 22 | String json = gson.toJson(message); 23 | return (message.getClass().getSimpleName() + ":" + json).getBytes(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Messaging/src/test/java/io/riguron/messaging/serialize/MessageDataExtractorTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.messaging.serialize; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class MessageDataExtractorTest { 8 | 9 | @Test 10 | public void getMessageData() { 11 | String src = "io.riguron.type.T:{some serialized object}"; 12 | MessageDataExtractor extractor = new MessageDataExtractor(); 13 | MessageData messageData = extractor.getMessageData(src.getBytes()); 14 | assertEquals("io.riguron.type.T",messageData.getType()); 15 | assertEquals("{some serialized object}", messageData.getContent()); 16 | } 17 | } -------------------------------------------------------------------------------- /Persistence/db-drop-all.sql: -------------------------------------------------------------------------------- 1 | alter table client_parent drop constraint if exists fk_client_parent_client; 2 | 3 | alter table client_parent drop constraint if exists fk_client_parent_parent; 4 | 5 | drop table if exists client; 6 | 7 | drop table if exists client_parent; 8 | 9 | drop table if exists parent; 10 | 11 | -------------------------------------------------------------------------------- /Persistence/src/main/java/io/riguron/persistence/CachingRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.persistence; 2 | 3 | /** 4 | * Represents a cache-capable repository. 5 | * 6 | * @param type of the primary key 7 | * @param type of the object stored in the repository. 8 | */ 9 | public interface CachingRepository { 10 | 11 | void invalidate(I id); 12 | 13 | T get(I id); 14 | 15 | void put(I id, T t); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Persistence/src/main/java/io/riguron/persistence/ebean/EbeanPatch.java: -------------------------------------------------------------------------------- 1 | package io.riguron.persistence.ebean; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | public class EbeanPatch { 6 | 7 | private EbeanPatch() { 8 | } 9 | 10 | /** 11 | * Workaround that just makes Ebean work. Should be fixed. 12 | */ 13 | public static void apply() { 14 | try { 15 | final Field skip = Class.forName("io.ebean.PrimaryServer").getDeclaredField("skip"); 16 | skip.setAccessible(true); 17 | skip.set(null, true); 18 | } catch (Exception ex) { 19 | throw new IllegalArgumentException(ex); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Persistence/src/main/java/io/riguron/persistence/entity/EntityGroup.java: -------------------------------------------------------------------------------- 1 | package io.riguron.persistence.entity; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | @RequiredArgsConstructor 10 | @Getter 11 | public class EntityGroup { 12 | 13 | private final List> entities; 14 | 15 | public List> getEntities() { 16 | return Collections.unmodifiableList(entities); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Persistence/src/main/java/io/riguron/persistence/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Module containing all persistence-related stuff. 3 | */ 4 | package io.riguron.persistence; -------------------------------------------------------------------------------- /Persistence/src/main/java/io/riguron/persistence/specification/Specification.java: -------------------------------------------------------------------------------- 1 | package io.riguron.persistence.specification; 2 | 3 | import io.ebean.Query; 4 | 5 | /** 6 | * Specification pattern adapted for the Ebean ORM. 7 | * See https://en.wikipedia.org/wiki/Specification_pattern for more details. 8 | */ 9 | public interface Specification { 10 | 11 | Query append(Query query); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Persistence/src/main/resources/datasource.properties: -------------------------------------------------------------------------------- 1 | jdbcUrl=jdbc:h2:mem:test 2 | driverClassName=org.h2.Driver -------------------------------------------------------------------------------- /ServerData/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jolice/MinecraftNetwork/7ed43098a5ba7574e2fb19509e363c3cf124fc0b/ServerData/dump.rdb -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/ConvertingServerGroup.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | /** 6 | * A ServerGroup implementation that transforms server's name to the name 7 | * of its group. 8 | */ 9 | @RequiredArgsConstructor 10 | public class ConvertingServerGroup implements ServerGroup { 11 | 12 | private final String serverName; 13 | 14 | public ConvertingServerGroup(ServerName serverName) { 15 | this(serverName.get()); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | int separatorIndex = serverName.indexOf('-'); 21 | if (separatorIndex > 0) { 22 | return serverName.substring(0, separatorIndex); 23 | } 24 | return serverName; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/NoFreeServersException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | /** 4 | * Exception to indicate the case when there are no servers that a given player 5 | * may join at the moment. 6 | */ 7 | public class NoFreeServersException extends RuntimeException { 8 | } 9 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/ServerGroup.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | /** 4 | * Represents group of similar servers (lobby servers, specific game servers and so on). 5 | * Name of each server in the group starts with group name, followed by hyphen and the server 6 | * number. For example: 7 | *

8 | * "bw-11" belongs to server group "bw", or 9 | * "lobby-1" belongs to server group "lobby". 10 | */ 11 | public interface ServerGroup { 12 | 13 | /** 14 | * Name of the group. Must be a latin string without any special characters, 15 | * for example, "bw" or "lobby". 16 | */ 17 | String getName(); 18 | } 19 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/ServerName.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import java.nio.file.Paths; 4 | 5 | /** 6 | * Simple singleton holder of the server's name. 7 | */ 8 | public enum ServerName { 9 | 10 | INSTANCE; 11 | 12 | /** 13 | * Name is equal to the name of the directory which the server process is running in. 14 | */ 15 | private final String name = Paths.get(System.getProperty("user.dir")).toFile().getAbsoluteFile().getName(); 16 | 17 | public String get() { 18 | return name; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/ServerProfile.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import lombok.Value; 4 | 5 | /** 6 | * Class that pairs group and name of the server. 7 | */ 8 | @Value 9 | public class ServerProfile { 10 | 11 | private final ServerGroup serverGroup; 12 | private final ServerName serverName; 13 | 14 | public final String getServerName() { 15 | return serverName.get(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/ServerType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import lombok.Getter; 4 | 5 | public enum ServerType implements ServerGroup { 6 | 7 | BEDWARS("bw"), SKYWARS("sw"), LOBBY("lobby"), ARCADE("arcade"); 8 | 9 | @Getter 10 | private String tag; 11 | 12 | ServerType(String tag) { 13 | this.tag = tag; 14 | } 15 | 16 | public boolean matches(String name) { 17 | return name.startsWith(tag); 18 | } 19 | 20 | @Override 21 | public String getName() { 22 | return tag; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/StaticServerGroup.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | /** 6 | * Plain ServerGroup implementation that just holds static group 7 | * value and doesn't perform any conversion logic. 8 | */ 9 | @RequiredArgsConstructor 10 | public class StaticServerGroup implements ServerGroup { 11 | 12 | private final String name; 13 | 14 | @Override 15 | public String getName() { 16 | return name; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This module is primarily responsible for organizing of storing 3 | * the data related to the servers. It introduces multiple repositories 4 | * that store actual "live" state of the servers throughout the network. 5 | */ 6 | package io.riguron.server; -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/redis/RedisModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.redis; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Provides; 5 | import com.google.inject.Singleton; 6 | import redis.clients.jedis.JedisPool; 7 | 8 | public class RedisModule extends AbstractModule { 9 | 10 | @Provides 11 | @Singleton 12 | public RedisTransactions redisTransactions(JedisPool jedisPool) { 13 | return new RedisTransactions(jedisPool); 14 | } 15 | 16 | @Provides 17 | @Singleton 18 | public JedisPool jedisPool() { 19 | return new JedisPool(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/redis/RedisTransactions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.redis; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import redis.clients.jedis.Jedis; 5 | import redis.clients.jedis.JedisPool; 6 | 7 | import java.util.function.Consumer; 8 | import java.util.function.Function; 9 | 10 | @RequiredArgsConstructor 11 | public class RedisTransactions { 12 | 13 | private final JedisPool jedisPool; 14 | 15 | public T runTransaction(Function action) { 16 | try (Jedis jedis = jedisPool.getResource()) { 17 | return action.apply(jedis); 18 | } 19 | } 20 | 21 | public void runTransaction(Consumer action) { 22 | try (Jedis jedis = jedisPool.getResource()) { 23 | action.accept(jedis); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/repository/FreeServersQueryOptions.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.repository; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | /** 7 | * Represents query for the list of servers with minimum players online (instant join). 8 | */ 9 | @RequiredArgsConstructor 10 | @Getter 11 | public class FreeServersQueryOptions { 12 | 13 | /** 14 | * Minimum count of servers that must be returned 15 | */ 16 | private final int min; 17 | 18 | /** 19 | * Maximum count of servers that must be returned 20 | */ 21 | private final int max; 22 | 23 | /** 24 | * Count of servers that must be returned 25 | */ 26 | private final int count; 27 | 28 | public FreeServersQueryOptions(int max, int count) { 29 | this(1, max, count); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/repository/ServerFieldType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.repository; 2 | 3 | public enum ServerFieldType { 4 | 5 | MAP("map"), ACTIVE("active"), ENABLED("enabled"), ONLINE("onlinePlayers"); 6 | 7 | private String fieldName; 8 | 9 | ServerFieldType(String fieldName) { 10 | this.fieldName = fieldName; 11 | } 12 | 13 | public String getFieldName() { 14 | return fieldName; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ServerData/src/main/java/io/riguron/server/type/Server.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.type; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Represents plain server, for example, lobby. 7 | */ 8 | @Data 9 | public class Server { 10 | 11 | private String name; 12 | private boolean enabled; 13 | 14 | /** 15 | * Current count of players on the server. 16 | */ 17 | private int onlinePlayers; 18 | 19 | /** 20 | * Count of slots. 21 | */ 22 | private int maxPlayers; 23 | 24 | public Server(String name, boolean enabled, int onlinePlayers, int maxPlayers) { 25 | this.name = name; 26 | this.enabled = enabled; 27 | this.onlinePlayers = onlinePlayers; 28 | this.maxPlayers = maxPlayers; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ServerData/src/test/java/io/riguron/server/ConvertingServerGroupTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class ConvertingServerGroupTest { 8 | 9 | @Test 10 | public void whenPartOfGroup() { 11 | 12 | ServerGroup group = new ConvertingServerGroup("bw-1"); 13 | assertEquals("bw", group.getName()); 14 | } 15 | 16 | @Test 17 | public void whenNotPart() { 18 | 19 | ServerGroup serverGroup = new ConvertingServerGroup("creative"); 20 | assertEquals("creative", serverGroup.getName()); 21 | } 22 | } -------------------------------------------------------------------------------- /ServerData/src/test/java/io/riguron/server/mapper/StandardServerMapperTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.server.mapper; 2 | 3 | import io.riguron.server.type.Server; 4 | import org.junit.Test; 5 | 6 | import java.util.Map; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | public class StandardServerMapperTest { 11 | 12 | @Test 13 | public void deserialize() { 14 | Server server = new Server( 15 | "name", 16 | true, 17 | 10, 18 | 100 19 | ); 20 | ServerMapper mapper = new StandardServerMapper(); 21 | Map serialized = mapper.serialize(server); 22 | assertEquals(server, mapper.deserialize(serialized)); 23 | } 24 | } -------------------------------------------------------------------------------- /System/dump.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jolice/MinecraftNetwork/7ed43098a5ba7574e2fb19509e363c3cf124fc0b/System/dump.rdb -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/chat/ChatModule.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.chat; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.google.inject.Provides; 5 | import com.google.inject.Singleton; 6 | import io.riguron.system.player.PlayerProfileRepository; 7 | import io.riguron.system.player.PlayerProfileRepository; 8 | 9 | public class ChatModule extends AbstractModule { 10 | 11 | @Provides 12 | @Singleton 13 | public ChatFormatter chatFormatter(PlayerProfileRepository repository) { 14 | return new ChatFormatter(repository); 15 | } 16 | 17 | @Provides 18 | @Singleton 19 | public ChatCooldowns cooldowns() { 20 | return new ChatCooldowns(3); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/MessageSendResponse.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog; 2 | 3 | public enum MessageSendResponse { 4 | 5 | OK, IGNORING, OFFLINE, DISABLED, MUTED; 6 | } 7 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/PrivateMessage.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog; 2 | 3 | import lombok.Value; 4 | 5 | import java.util.UUID; 6 | 7 | @Value 8 | public class PrivateMessage { 9 | 10 | private final UUID from; 11 | private final String toName; 12 | private final String text; 13 | private final String fromName; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/PrivateMessageProjection.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog; 2 | 3 | import lombok.Value; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | @Value 8 | public class PrivateMessageProjection { 9 | 10 | private String from; 11 | private String to; 12 | private String text; 13 | private LocalDateTime dateTime; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/ignore/IgnoreHistoryElement.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog.ignore; 2 | 3 | import lombok.Value; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | /** 8 | * DTO for the ignore history. 9 | */ 10 | @Value 11 | public class IgnoreHistoryElement { 12 | 13 | /** 14 | * Player being ignored. 15 | */ 16 | private final String target; 17 | 18 | /** 19 | * Date when player started ignoring the target, 20 | * i.e the date of record creation. 21 | */ 22 | private final LocalDateTime date; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/ignore/IgnoreRemoveResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog.ignore; 2 | 3 | public enum IgnoreRemoveResult { 4 | 5 | NOT_IGNORING, REMOVED_IGNORE 6 | } 7 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/dialog/ignore/IgnoreResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.dialog.ignore; 2 | 3 | public enum IgnoreResult { 4 | 5 | ALREADY_IGNORING, IGNORED, NOT_FOUND; 6 | } 7 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/exception/PlayerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.exception; 2 | 3 | public class PlayerNotFoundException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/internalization/InvalidMessageFormatException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.internalization; 2 | 3 | public class InvalidMessageFormatException extends RuntimeException { 4 | 5 | public InvalidMessageFormatException(Throwable cause) { 6 | super(cause); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/internalization/Localizable.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.internalization; 2 | 3 | import java.util.Locale; 4 | 5 | /** 6 | * Represents any object that may have a locale. 7 | */ 8 | public interface Localizable { 9 | 10 | Locale getLocale(); 11 | } 12 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/internalization/SendMessage.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.internalization; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * Implementations of this interface are responsible of sending text messages to 7 | * different targets. 8 | */ 9 | public interface SendMessage { 10 | 11 | /** 12 | * Sends an internalized message. Target receives a 13 | * translated message. 14 | * 15 | * @param uuid message receiver 16 | * @param message message body 17 | */ 18 | void to(UUID uuid, Message message); 19 | 20 | /** 21 | * Sends raw text message. 22 | * 23 | * @param uuid message receiver 24 | * @param message message body 25 | */ 26 | void to(UUID uuid, String message); 27 | } 28 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/listener/ConditionalListener.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.listener; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Getter; 5 | import lombok.Value; 6 | 7 | /** 8 | * Represents listener that must be registered only if a certain condition 9 | * evaluates to true. 10 | * 11 | * @param type of the listener 12 | */ 13 | @Value 14 | @Getter(AccessLevel.NONE) 15 | public class ConditionalListener { 16 | 17 | private T listener; 18 | 19 | /** 20 | * Condition that must match true to register the listener 21 | */ 22 | private boolean condition; 23 | 24 | public T getListener() { 25 | return listener; 26 | } 27 | 28 | public boolean register() { 29 | return condition; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/listener/ListenerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.listener; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * Implementations of this interface are responsible of registering listeners. 7 | * It's typically done by delegating the registration operation to the underlying 8 | * environment API. 9 | * 10 | * @param type of the Listener interface, depending on the environment 11 | */ 12 | public interface ListenerRegistration { 13 | 14 | void registerListener(T listener); 15 | 16 | default void registerAll(Collection listeners) { 17 | listeners.forEach(this::registerListener); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/login/LoginDetails.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.login; 2 | 3 | import lombok.Value; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Simple value class holding user's ID and name 9 | */ 10 | @Value 11 | public class LoginDetails { 12 | 13 | private UUID uuid; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/login/chain/LoginChainExecutor.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.login.chain; 2 | 3 | import java.util.UUID; 4 | import java.util.function.Consumer; 5 | 6 | /** 7 | * Class responsible for executing login chain, i.e performing all steps 8 | * of the chain and handling exceptions. 9 | */ 10 | public interface LoginChainExecutor { 11 | 12 | /** 13 | * Dispatches the login chain. 14 | * 15 | * @param uuid ID of player that joins the server 16 | * @param name name of the player 17 | * @param errorHandler callback that accepts a error message from the chain 18 | */ 19 | void execute(UUID uuid, String name, Consumer errorHandler); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/login/chain/LoginProcessingException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.login.chain; 2 | 3 | /** 4 | * Exception that indicates the login failure, i.e that player that is being 5 | * logged in can not be processed for some reason (he is banned, database error has occurred, etc.) 6 | */ 7 | public class LoginProcessingException extends RuntimeException { 8 | 9 | public LoginProcessingException(Throwable cause) { 10 | super(cause); 11 | } 12 | 13 | public LoginProcessingException(String message) { 14 | super(message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * One of the core modules of the entire project. It provides API to many 3 | * system services that is used in concrete server environments (either Spigot 4 | * or BungeeCord). 5 | */ 6 | package io.riguron.system; -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/party/result/CreateResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.party.result; 2 | 3 | public enum CreateResult implements Result { 4 | 5 | /** 6 | * Indicates successful creation 7 | */ 8 | CREATED, 9 | 10 | /** 11 | * A player tried to create a party, but he already participates in another party and 12 | * must leave it in order to create a new one 13 | */ 14 | ALREADY_IN_PARTY, 15 | 16 | /** 17 | * A player tried to create a party, but he is already an owner of a part and must 18 | * disband it first in order to create another one 19 | */ 20 | DISBAND_FIRST; 21 | 22 | @Override 23 | public String path() { 24 | return "create"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/party/result/RemoveResult.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.party.result; 2 | 3 | public enum RemoveResult implements Result { 4 | 5 | /** 6 | * A player that was attempted to be removed actually 7 | * is not a party member. 8 | */ 9 | NOT_PARTY_MEMBER, 10 | 11 | /** 12 | * Indicates successful removal. 13 | */ 14 | REMOVED, 15 | 16 | /** 17 | * A player attempted to remove another player from the party, 18 | * but failed due to lack of permissions, since only a party owner 19 | * may kick members from the owned party. 20 | */ 21 | NOT_AN_OWNER; 22 | 23 | @Override 24 | public String path() { 25 | return "remove"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/player/PlayerAssociation.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.player; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @RequiredArgsConstructor 7 | public enum PlayerAssociation { 8 | 9 | PREFERENCES("playerPreferences"), PURCHASES("purchases.data"); 10 | 11 | @Getter 12 | private final String path; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/player/exception/InsufficientFundsException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.player.exception; 2 | 3 | public class InsufficientFundsException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/player/exception/PlayerProcessingException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.player.exception; 2 | 3 | public class PlayerProcessingException extends RuntimeException { 4 | 5 | public PlayerProcessingException(Throwable e) { 6 | super(e); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/player/specification/PlayerNameSpecification.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.player.specification; 2 | 3 | import io.ebean.Query; 4 | import lombok.AccessLevel; 5 | import lombok.Data; 6 | import lombok.Setter; 7 | import io.riguron.persistence.specification.Specification; 8 | 9 | /** 10 | * Allows for searching a player by his name. 11 | */ 12 | @Data 13 | @Setter(AccessLevel.NONE) 14 | public class PlayerNameSpecification implements Specification { 15 | 16 | private final String name; 17 | 18 | @Override 19 | public Query append(Query query) { 20 | return query.where().eq("name", name).query(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/player/specification/UUIDSpecification.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.player.specification; 2 | 3 | import io.ebean.Query; 4 | import lombok.AccessLevel; 5 | import lombok.Data; 6 | import lombok.Setter; 7 | import io.riguron.persistence.specification.Specification; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Allows for searching a player by his UUID. 13 | */ 14 | @Data 15 | @Setter(AccessLevel.NONE) 16 | public class UUIDSpecification implements Specification { 17 | 18 | private final UUID uuid; 19 | 20 | @Override 21 | public Query append(Query query) { 22 | return query.where().eq("uuid", uuid).query(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/plugin/PluginConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.plugin; 2 | 3 | import com.google.inject.Module; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Interface implemented by custom server plugins to provide 9 | * hooks that used by the system to activate the plugin. 10 | */ 11 | public interface PluginConfiguration { 12 | 13 | /** 14 | * All Guice modules involved in the plugin. 15 | * 16 | * @return plugin's DI modules 17 | */ 18 | List modules(); 19 | 20 | /** 21 | * JPA entities operated by the plugin. 22 | * 23 | * @return list of plugin's entities. 24 | */ 25 | List> entities(); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/preferences/PreferencesRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.preferences; 2 | 3 | import io.ebean.EbeanServer; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.persistence.specification.Specification; 6 | 7 | import java.util.Optional; 8 | 9 | @RequiredArgsConstructor 10 | public class PreferencesRepository { 11 | 12 | private final EbeanServer ebeanServer; 13 | 14 | public Optional findBy(Specification specification) { 15 | return specification.append(ebeanServer.find(PlayerPreferences.class)).findOneOrEmpty(); 16 | } 17 | 18 | public void update(PlayerPreferences playerPreferences) { 19 | ebeanServer.update(playerPreferences); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/preferences/specification/PlayerNameSpecification.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.preferences.specification; 2 | 3 | import io.ebean.Query; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.persistence.specification.Specification; 6 | 7 | @RequiredArgsConstructor 8 | public class PlayerNameSpecification implements Specification { 9 | 10 | private final String name; 11 | 12 | @Override 13 | public Query append(Query query) { 14 | return query.where().eq("profile.name", name).query(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/model/ActivePunishmentType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.model; 2 | 3 | import lombok.Getter; 4 | import io.riguron.system.punishment.model.type.PunishmentType; 5 | 6 | public enum ActivePunishmentType { 7 | 8 | BAN(PunishmentType.BAN), MUTE(PunishmentType.MUTE); 9 | 10 | @Getter 11 | private PunishmentType mainType; 12 | 13 | ActivePunishmentType(PunishmentType mainType) { 14 | this.mainType = mainType; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/model/type/PunishmentType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.model.type; 2 | 3 | import lombok.Getter; 4 | 5 | public enum PunishmentType { 6 | 7 | BAN("banned"), KICK("kicked"), MUTE("muted"), WARN("warned"); 8 | 9 | @Getter 10 | private String description; 11 | 12 | PunishmentType(String description) { 13 | this.description = description; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes in this package are responsible for implementing punishment 3 | * system (bans, mutes, warns, kick and so on). 4 | */ 5 | package io.riguron.system.punishment; -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/param/PunishmentParameters.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.param; 2 | 3 | import lombok.Value; 4 | 5 | import java.time.Duration; 6 | 7 | @Value 8 | public class PunishmentParameters { 9 | 10 | /** 11 | * Player that is punished. 12 | */ 13 | private String targetName; 14 | 15 | /** 16 | * A player that applied the punishment (or console). 17 | */ 18 | private String punisher; 19 | 20 | /** 21 | * Reason of the punishment (or empty if none). 22 | */ 23 | private String reason; 24 | 25 | /** 26 | * Duration of the punishment, if it's not permanent. 27 | */ 28 | private Duration duration; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/type/PunishResultType.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.type; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public enum PunishResultType { 7 | 8 | OK("Punishment applied"), NOT_FOUND("Profile not found"); 9 | 10 | private final String description; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/type/Punishment.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.type; 2 | 3 | import io.riguron.system.punishment.param.PunishmentParameters; 4 | 5 | public interface Punishment { 6 | 7 | PunishResult punish(PunishmentParameters punishmentParameters); 8 | } 9 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/punishment/type/active/ActivePunishment.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.punishment.type.active; 2 | 3 | import io.riguron.system.punishment.type.Punishment; 4 | import io.riguron.system.punishment.type.Punishment; 5 | 6 | import java.util.UUID; 7 | 8 | public interface ActivePunishment extends Punishment { 9 | 10 | /** 11 | * Removes an active punishment from a player. 12 | * 13 | * @param uuid uuid of the player to be excused 14 | */ 15 | void excuse(UUID uuid); 16 | } 17 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/rank/RankLoader.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.rank; 2 | 3 | import io.riguron.system.task.startup.PostLoadTask; 4 | import io.riguron.system.task.startup.PostLoadTask; 5 | 6 | /** 7 | * Post-load task responsible for loading Ranks into the memory 8 | */ 9 | public class RankLoader implements PostLoadTask { 10 | 11 | private final Ranks ranks; 12 | 13 | public RankLoader(Ranks ranks) { 14 | this.ranks = ranks; 15 | } 16 | 17 | @Override 18 | public void run() { 19 | ranks.loadRanks(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/rank/RankRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.rank; 2 | 3 | import io.ebean.EbeanServer; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.util.List; 7 | 8 | @RequiredArgsConstructor 9 | public class RankRepository { 10 | 11 | private final EbeanServer ebeanServer; 12 | 13 | public void save(Rank rank) { 14 | ebeanServer.save(rank); 15 | } 16 | 17 | public List findAll() { 18 | return ebeanServer.find(Rank.class) 19 | .fetch("permissions") 20 | .fetch("child") 21 | .findList(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/shop/AlreadyPurchasedException.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.shop; 2 | 3 | public class AlreadyPurchasedException extends RuntimeException{ 4 | } 5 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/shop/Purchasable.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.shop; 2 | 3 | /** 4 | * Represents any server item that can be purchased. 5 | */ 6 | public interface Purchasable { 7 | 8 | /** 9 | * Internal ID of the purchase. Must be constant and unique. 10 | * 11 | * @return id of the purchase 12 | */ 13 | int getId(); 14 | 15 | /** 16 | * Service description of the purchase that is displayed to players. 17 | * 18 | * @return purchase description 19 | */ 20 | String getDescription(); 21 | 22 | long getPrice(); 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/shop/PurchaseRepository.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.shop; 2 | 3 | import io.ebean.EbeanServer; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | @RequiredArgsConstructor 7 | public class PurchaseRepository { 8 | 9 | private final EbeanServer ebeanServer; 10 | 11 | public void update(PlayerPurchases purchases) { 12 | ebeanServer.update(purchases); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/stream/Broadcast.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.stream; 2 | 3 | import io.riguron.system.internalization.Message; 4 | import io.riguron.system.internalization.Message; 5 | 6 | 7 | public interface Broadcast { 8 | 9 | /** 10 | * Sends a message to all online players. 11 | * 12 | * @param message raw message 13 | */ 14 | void broadcast(String message); 15 | 16 | /** 17 | * Sends an internalized to all online players. 18 | * Each player will receive a translation of the message 19 | * depending on his language. 20 | * 21 | * @param message internalized message 22 | */ 23 | void broadcast(Message message); 24 | } 25 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/ExecutionStrategy.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | public interface ExecutionStrategy { 4 | 5 | /** 6 | * Executes task. 7 | * 8 | * @param runnable task 9 | * @return task id returned by the native scheduler 10 | */ 11 | int execute(Runnable runnable); 12 | } 13 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/FixedRepeatingAction.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | /** 4 | * Represents an action that runs repeatedly, at a fixed interval of time, 5 | * either synchronously or asynchronously. 6 | */ 7 | public interface FixedRepeatingAction extends Runnable { 8 | 9 | /** 10 | * The action. 11 | */ 12 | void run(); 13 | 14 | /** 15 | * Interval between the task executions 16 | * 17 | * @return interval of execution 18 | */ 19 | int getInterval(); 20 | } 21 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/FixedRepeatingTaskRunner.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | import com.google.inject.Inject; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * Class responsible for starting fixed repeating task after the server startup. 9 | */ 10 | public class FixedRepeatingTaskRunner { 11 | 12 | private final TaskFactory taskFactory; 13 | 14 | @Inject 15 | public FixedRepeatingTaskRunner(TaskFactory taskFactory) { 16 | this.taskFactory = taskFactory; 17 | } 18 | 19 | @Inject(optional = true) 20 | public void runTasks(Set actionSet) { 21 | actionSet.forEach(fixedRepeatingAction -> taskFactory 22 | .newRepeatingTask(fixedRepeatingAction, fixedRepeatingAction.getInterval()) 23 | .start()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/SchedulerTask.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | /** 4 | * A wrapper for native scheduler task. 5 | */ 6 | public interface SchedulerTask { 7 | 8 | /** 9 | * Returns a task ID from native scheduler, or 0 10 | * if the task is not started yet. 11 | * 12 | * @return native task id 13 | */ 14 | int getTaskId(); 15 | 16 | /** 17 | * Stops the task. 18 | */ 19 | void cancel(); 20 | 21 | /** 22 | * Starts the task and assigns the task ID. 23 | */ 24 | void start(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/Task.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | public interface Task { 4 | 5 | void execute(); 6 | } 7 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/TimerFactory.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task; 2 | 3 | import io.riguron.system.task.timer.CountdownTask; 4 | import io.riguron.system.task.timer.TaskOptions; 5 | import io.riguron.system.task.timer.Timer; 6 | 7 | public interface TimerFactory { 8 | 9 | Timer newTimer(CountdownTask countdownTask, TaskOptions taskOptions); 10 | } 11 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/async/Callback.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.async; 2 | 3 | public interface Callback { 4 | 5 | void call(T t); 6 | } 7 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/repeating/RepeatingAction.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.repeating; 2 | 3 | import io.riguron.system.task.SchedulerTask; 4 | 5 | public interface RepeatingAction { 6 | 7 | /** 8 | * Tact of the task. This method represents the repeating 9 | * action each self. 10 | * 11 | * @param owner parent task, i.e action executor 12 | */ 13 | void run(SchedulerTask owner); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/repeating/RepeatingRunnable.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.repeating; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import io.riguron.system.task.SchedulerTask; 5 | 6 | @RequiredArgsConstructor 7 | public class RepeatingRunnable implements RepeatingAction { 8 | 9 | private final Runnable runnable; 10 | 11 | @Override 12 | public void run(SchedulerTask owner) { 13 | this.runnable.run(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/repeating/RepeatingTask.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.repeating; 2 | 3 | /** 4 | * Represents a task that repeatedly executes some action at a certain time interval. 5 | * By default, implementations of this interface are not reusable, i.e task can not be 6 | * started again after it is stopped. 7 | * 8 | * @see ReusableRepeatingTask reusable implementation 9 | */ 10 | public interface RepeatingTask { 11 | 12 | /** 13 | * Starts repeating task. From now on, the task action will be executed repeatedly 14 | * until the task is stopped. 15 | */ 16 | void start(); 17 | 18 | /** 19 | * Terminates the task. Repeating action will no longer run (or will run the last time 20 | * after this method is executed). 21 | */ 22 | void stop(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/startup/PostLoadTask.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.startup; 2 | 3 | import io.riguron.common.shutdown.ShutdownHook; 4 | 5 | /** 6 | * A task that runs right after the server startup. Players are not able to join 7 | * the server until all tasks are completed. 8 | * 9 | * @see ShutdownHook an antonym 10 | */ 11 | public interface PostLoadTask { 12 | 13 | void run(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/startup/PostLoadTaskRunner.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.startup; 2 | 3 | import com.google.inject.Inject; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Class responsible for executing post-load tasks. 10 | */ 11 | @Slf4j 12 | public class PostLoadTaskRunner { 13 | 14 | @Inject(optional = true) 15 | public void run(List tasks) { 16 | log.info("Running {} post-load tasks", tasks.size()); 17 | tasks.forEach(PostLoadTask::run); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/timer/Countdown.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.timer; 2 | 3 | import io.riguron.system.task.repeating.RepeatingAction; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.system.task.SchedulerTask; 6 | import io.riguron.system.task.repeating.RepeatingAction; 7 | 8 | @RequiredArgsConstructor 9 | public class Countdown implements RepeatingAction { 10 | 11 | private final CountdownTask countdownTask; 12 | private final TaskOptions taskOptions; 13 | 14 | private long timesExecuted; 15 | 16 | @Override 17 | public void run(SchedulerTask owner) { 18 | countdownTask.onTick(++timesExecuted); 19 | if (timesExecuted == taskOptions.getTimesToRun()) { 20 | countdownTask.complete(); 21 | owner.cancel(); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/timer/CountdownTask.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.timer; 2 | 3 | public interface CountdownTask { 4 | 5 | /** 6 | * Represents countdown step. In case of the countdown from X to 0, 7 | * this method is called exactly X times. 8 | * 9 | * @param tick time left until the end of the countdown 10 | */ 11 | void onTick(long tick); 12 | 13 | /** 14 | * Action performed when the countdown ends. This method is always triggered 15 | * once, when the countdown reaches zero. 16 | */ 17 | void complete(); 18 | } 19 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/timer/Timer.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.timer; 2 | 3 | import io.riguron.system.task.repeating.RepeatingTask; 4 | import io.riguron.system.task.repeating.RepeatingTask; 5 | 6 | /** 7 | * {@inheritDoc} 8 | */ 9 | public interface Timer extends RepeatingTask { 10 | 11 | /** 12 | * {@inheritDoc} 13 | */ 14 | void start(); 15 | 16 | /** 17 | * {@inheritDoc} 18 | */ 19 | void stop(); 20 | } 21 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/timer/TimerAdapter.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.timer; 2 | 3 | import io.riguron.system.task.repeating.RepeatingTask; 4 | import lombok.RequiredArgsConstructor; 5 | import io.riguron.system.task.repeating.RepeatingTask; 6 | 7 | @RequiredArgsConstructor 8 | public class TimerAdapter implements Timer { 9 | 10 | private final RepeatingTask delegate; 11 | 12 | @Override 13 | public void start() { 14 | delegate.start(); 15 | } 16 | 17 | @Override 18 | public void stop() { 19 | delegate.stop(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /System/src/main/java/io/riguron/system/task/util/SecondsToTicks.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.util; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | 5 | @RequiredArgsConstructor 6 | public class SecondsToTicks { 7 | 8 | private static final long TICKS_PER_SECOND = 20L; 9 | 10 | private final int seconds; 11 | 12 | public long convert() { 13 | return seconds * TICKS_PER_SECOND; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /System/src/main/resources/ebean.mf: -------------------------------------------------------------------------------- 1 | entity-packages: io.riguron 2 | transactional-packages: io.riguron 3 | -------------------------------------------------------------------------------- /System/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /System/src/main/resources/selector.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /System/src/test/java/io/riguron/system/task/util/SecondsToTicksTest.java: -------------------------------------------------------------------------------- 1 | package io.riguron.system.task.util; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class SecondsToTicksTest { 8 | 9 | @Test 10 | public void convert() { 11 | SecondsToTicks secondsToTicks = new SecondsToTicks(1); 12 | assertEquals(20, secondsToTicks.convert()); 13 | } 14 | } -------------------------------------------------------------------------------- /build-game.sh: -------------------------------------------------------------------------------- 1 | mvn -Dmaven.test.skip=true clean install && cd Game && sh build.sh 2 | -------------------------------------------------------------------------------- /start-redis.sh: -------------------------------------------------------------------------------- 1 | echo Starting Redis instance 2 | redis-server --daemonize yes 3 | 4 | -------------------------------------------------------------------------------- /stop-redis.sh: -------------------------------------------------------------------------------- 1 | echo Stopping redis instance 2 | redis-cli shutdown 3 | --------------------------------------------------------------------------------